Create ArcDimension in autocad

I need create ArcDimension for Arc of Polyline , but I can not find node to do this.
I have write python but it do not work.

Load the Python Standard and DesignScript Libraries

import sys
import clr

Add Assemblies for AutoCAD and Civil3D

clr.AddReference(‘AcMgd’)
clr.AddReference(‘AcCoreMgd’)
clr.AddReference(‘AcDbMgd’)
clr.AddReference(‘AecBaseMgd’)
clr.AddReference(‘AecPropDataMgd’)
clr.AddReference(‘AeccDbMgd’)

Import references from AutoCAD

from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

Import references from Civil3D

from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

import Autodesk.Autocad.DynamoNodes as DA
import Autodesk.Civil.DynamoNodes as DC
import Autodesk.DesignScript.Geometry as DG

The inputs to this node will be stored as a list in the IN variables.

dataEnteringNode = IN

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

def create_arc_dimension(center,xline1,xline2,arcpoint,style = None):

global adoc

if center and isinstance(center, DG.Point):
   center = DA.GeometryConversion.DynamoToAutoCad.ToPoint3d(center)
   
if xline1 and isinstance(xline1, DG.Point):
   xline1 = DA.GeometryConversion.DynamoToAutoCad.ToPoint3d(xline1)  

if xline2 and isinstance(xline2, DG.Point):
   xline2 = DA.GeometryConversion.DynamoToAutoCad.ToPoint3d(xline2)

if arcpoint and isinstance(arcpoint, DG.Point):
   arcpoint = DA.GeometryConversion.DynamoToAutoCad.ToPoint3d(arcpoint)
   
if not center or not xline1 or not xline2 or not arcpoint:
   return

dim = None

with adoc.LockDocument():
with adoc.Database as db:

         with db.TransactionManager.StartTransaction() as t:
              bt=t.GetObject(db.BlockTableId, OpenMode.ForWrite)
              btr=t.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite)
              
              styleid = ObjectId.Null
              dst=t.GetObject(db.DimStyleTableId,OpenMode.ForRead)
              
              if style is not None and dst.Has(style):
                 styleid=dst[style]
              else:
                 styleid=db.Dimstyle
                 
              dim=ArcDimension(center,xline1,xline2,arcpoint,"",styleid)
              
              btr.AppendEntity(dim)
              t.AddNewlyCreatedDBObject(dim, true)
              
              t.Commit()

return dim
OUT = create_arc_dimension(IN[0],IN[1],IN[2],IN[3],IN[4])
Can you help me ?
Thank you !

You could take a look in the Arkance Systems Node Library, that contains several nodes for creating dimensions.

2 Likes


I can not find Dimension Length for Arc in the Arkance Systems Node Library.

Agreed. It seems like the closest thing is the Angular Dimension Node. Here is my first attempt at using @Anton_Huizinga’s Dimension nodes.
Dimension Polylines.dyn (55.0 KB)


1 Like

I found a python solution that seems easy but my CAD keeps crashing and giving me a very weird error and I seem to be unable to treat the block table like a list or get the model space block in any way… very odd. May make a separate thread if the issue persists.

I’ll put it on the wishlist.

2 Likes

Next release will have that node:

image

I think it will be released within a few weeks.

3 Likes

Here is a solution with python. For me, the entities this script is creating are invisible, for some reason I have to select and copy them to make them visible. Not sure if anyone else has seen this behavior before when creating objects. No idea why this is happening. Not going to admit how long it took me to figure out how to do this but a big thanks to @mzjensen for his help with my error earlier and for a few other posts I found on the forum that he had answered that led me to the solution.

**Edit: After closing and re-opening the drawing, the entities are no longer invisible when created. So I don’t think others will have the same issue.

Dimension Polylines-V2.dyn (56.4 KB)

# Load the Python Standard and DesignScript Libraries
import sys
import clr
import itertools

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

"""
centerPoint = Point3d(4.5, 1.5, 0)
startPoint = Point3d(8, 4.25, 0)
endPoint = Point3d(0, 2, 0)
arcPoint = Point3d(5, 7, 0)
dimensionTextProp = "<>"
"""

autocadCenterPoints = IN[0]
autocadStartPoints = IN[1]
autocadEndPoints = IN[2]
autocadArcPoints = IN[3]



#convert designscript points to geometry.point3d points
centerPoints = [Point3d(autocadCenterPoint.X, autocadCenterPoint.Y, autocadCenterPoint.Z) for autocadCenterPoint in autocadCenterPoints]

startPoints = [Point3d(autocadStartPoint.X, autocadStartPoint.Y, autocadStartPoint.Z) for autocadStartPoint in autocadStartPoints]

endPoints = [Point3d(autocadEndPoint.X, autocadEndPoint.Y, autocadEndPoint.Z) for autocadEndPoint in autocadEndPoints]

arcPoints = [Point3d(autocadArcPoint.X, autocadArcPoint.Y, autocadArcPoint.Z) for autocadArcPoint in autocadArcPoints]

dimensionTextProp = "<>"


adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

with adoc.LockDocument():
    with adoc.Database as db:
        with db.TransactionManager.StartTransaction() as t:
            bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
            btrID = bt.get_Item("*Model_Space")
            btr = t.GetObject(btrID, OpenMode.ForWrite)
            
            for centerPoint, startPoint, endPoint, arcPoint in zip(centerPoints, startPoints, endPoints, arcPoints):
                dimension = ArcDimension(centerPoint, startPoint, endPoint, arcPoint, dimensionTextProp, db.Dimstyle)
            
                btr.AppendEntity(dimension)
                t.AddNewlyCreatedDBObject(dimension, True)

                

            t.Commit()
            pass

# Assign your output to the OUT variable.
OUT = 0

2 Likes

Thank you very much !

1 Like