malix 发表于 2022-7-6 22:06:45

创建弧长尺寸时出错

我正在用VB写一个项目。net中,我在多段线的每一段上放置了一些尺寸,一切都很顺利,直到我尝试为曲线段声明一个弧尺寸。
 
例如,我得到:
Dim linearDim作为新的对齐尺寸
Dim radDim作为新的RadialDimension
Dim ANGLE Dim As New LineAngularDimension2
 
这些都很好,我能够创建维度并将其放置在需要的地方。但当我这么做的时候:
 
Dim arcDim作为新的ArcDimension
 
它导致以下错误-错误1重载解析失败,因为没有可访问的“New”接受此数量的参数。
 
这是我第一次在中使用维度。我被难住了。我在文档中没有看到任何会导致弧长维度的处理与其他维度有任何不同的地方。有什么想法吗?

BlackBox 发表于 2022-7-6 22:43:04

 
我认为您收到了这个错误,因为您没有向构造函数提供任何参数;例子:
 

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry

<CommandMethod("CreateArcLengthDimension")> _
Public Sub CreateArcLengthDimension()
   '' Get the current database
   Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
   Dim acCurDb As Database = acDoc.Database

   '' Start a transaction
   Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()

       '' Open the Block table for read
       Dim acBlkTbl As BlockTable
       acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, _
                                    OpenMode.ForRead)

       '' Open the Block table record Model space for write
       Dim acBlkTblRec As BlockTableRecord
       acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                       OpenMode.ForWrite)

       '' Create an arc length dimension
       Using acArcDim As ArcDimension = New ArcDimension(New Point3d(4.5, 1.5, 0), _
                                                         New Point3d(8, 4.25, 0), _
                                                         New Point3d(0, 2, 0), _
                                                         New Point3d(5, 7, 0), _
                                                         "<>", _
                                                         acCurDb.Dimstyle)

         '' Add the new object to Model space and the transaction
         acBlkTblRec.AppendEntity(acArcDim)
         acTrans.AddNewlyCreatedDBObject(acArcDim, True)
       End Using

       '' Commit the changes and dispose of the transaction
       acTrans.Commit()
   End Using
End Sub

 
 
 
干杯

malix 发表于 2022-7-6 22:55:45

谢谢
 
虽然我真的不明白为什么有必要对ArcDimension这样做,但对其他维度却没有必要。在所有其他维度类型中,我首先声明它们,然后设置值。

BlackBox 发表于 2022-7-6 23:11:19

 
不客气;我很乐意帮忙。
 
我能告诉你的就是AutoCAD完整性的一致性。NET API不是它应该是的,Visual Studio的intellisense将在编码时显示可用的构造函数重载。。。例如,比较AlignedDimension类型的2个构造函数重载中的1个。
 
此外,您可以将光标放在任何符号内,然后点击F12查看相同符号的元数据。
 
干杯
页: [1]
查看完整版本: 创建弧长尺寸时出错