Jump to content

Error creating arc length dimension?


malix

Recommended Posts

I'm writing a project in VB.net where I'm placing some dimensions on each segment of a polyline, and everything was going great until I tried to declare an ArcDimension for the curved segments.

 

So for example I've got :

Dim linearDim As New AlignedDimension

Dim radDim As New RadialDimension

Dim angleDim As New LineAngularDimension2

 

And these are all working fine, I'm able to create the dimensions and place them where they need to be. But when I do this:

 

Dim arcDim As New ArcDimension

 

It's causing the following error - Error 1 Overload resolution failed because no accessible 'New' accepts this number of arguments.

 

This is my first time working with dimensions in .net and I'm stumped. I don't see anything in the documentation that would cause an arc length dimension to be handled any differently from the others. Any ideas?

Edited by malix
Link to comment
Share on other sites

... these are all working fine, I'm able to create the dimensions and place them where they need to be. But when I do this:

 

Dim arcDim As New ArcDimension

 

It's causing the following error -

 

Error	1 Overload resolution failed because no accessible 'New' accepts this number of arguments.

 

This is my first time working with dimensions in .net and I'm stumped. I don't see anything in the documentation that would cause an arc length dimension to be handled any differently from the others. Any ideas?

 

Methinks you're receiving that error, as you've supplied no arguments to the constructor; example:

 

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([color="red"]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[/color])

           '' 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

 

 

 

Cheers

Link to comment
Share on other sites

Thanks!

 

That worked, although I don't really understand why it's necessary to do it that way for the ArcDimension but not for the others. In all the other dimension types I declared them first and set the values later.

Link to comment
Share on other sites

Thanks!

 

That worked, although I don't really understand why it's necessary to do it that way for the ArcDimension but not for the others. In all the other dimension types I declared them first and set the values later.

 

You're welcome; I'm happy to help.

 

All I can tell you is that consistency of completeness for the AutoCAD .NET API is not what it should be, and Visual Studio's intellisense will display what constructor overloads are available whilst coding... As example, compare the 1 of 2 constructor overloads for AlignedDimension Type.

 

Also, you can place your cursor within any symbol, and hit F12 to view metadata for same.

 

Cheers

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...