Hello!
I’m hoping to create a python node that outputs the arrowhead coordinates of selected mleaders. Is this possible?
Hello!
I’m hoping to create a python node that outputs the arrowhead coordinates of selected mleaders. Is this possible?
Have you checked the Camber nodes? In any case here is the API for MLeader: Help
I don’t use them much so I dont know if the Block position will correspond to the arrowhead coordinates. I will say that it depends what the insertion point is for block but will expect it to be something like the arrowhead.
I did, sadly the BlockPosition node gets the position of content block (like a hex tag) instead of the leader arrowhead position.
You can write a lisp routine to get leader head location per the Autodesk Forum.
I assume you can do the same in Dynamo and the documentation states that a Leader.FirstVertex Property exists for a leader, but my attempts to make a python node to obtain the first vertex point have failed so far.
Can you share those attempts?
You bet! See my test script attached.
Mleader Arrowhead Point.dyn (6.3 KB)
Presuming you would select an object with the Dynamo Select Object node you can get the vertex via Dynamo with the following:
def get_selected_leader(dyn_object):
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
res = None
if isinstance(dyn_object.InternalDBObject, MLeader):
obj = t.GetObject(dyn_object.InternalObjectId, OpenMode.ForRead)
res = obj.GetFirstVertex(0) #get First vertex of first leader of the multileader
return res
OUT = get_selected_leader(IN[0])
you also might want to go for all leaders:
def get_all_leaders():
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
bt = t.GetObject(db.BlockTableId,OpenMode.ForRead)
btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead)
lst = []
for oid in btr:
if oid.ObjectClass.Name == "AcDbMLeader":
obj = t.GetObject(oid, OpenMode.ForRead)
lst.append(obj.GetFirstVertex(0)) #get First vertex of first leader of the multileader
pass
return lst
OUT = get_all_leaders()
Output is a Point3d type (AutoCAD). You might want to convert output to DS point:
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry as DS
point3d = get_selected_leader(IN[0])
ds_point = DS.Point.ByCoordinates(point3d[0],point3d[1],point3d[2])
OUT = ds_point
@mparks8G2XN I added a new node to Camber for you. I’ll try to get the new version out soon.
Awesome mzjensen! Thanks everyone for the help!
A post was merged into an existing topic: Camber Feedback Thread
@mparks8G2XN this is available in v4.2.0.
This new MLeader.LeaderPoints node v4.2.0 is exactly what I’m looking for! Thank you @zachri.jensen!
Hi @zachri.jensen,
I’m using the MLeader.LeaderPoints node but I’m not sure which node to input into it. When I use select objects, it reads this…
You’ll need a Convert to Camber Object node first.
Thanks!
Is there a scaling issue with this node? It seems to not work with larger coordinate systems…(3 mil)
Do you have Dynamo’s geometry scaling set to Medium?