This is an example of DraggedOffset Property LABEL
Thanks everyone for the help
I hope to make a follow-up to accept several AECC_STRUCTURE_LABEL
It works with all LABELS
Thank
This is an example of DraggedOffset Property LABEL
Thanks everyone for the help
I hope to make a follow-up to accept several AECC_STRUCTURE_LABEL
It works with all LABELS
Thank
Python Script
import clr
#forum.dynamobim.com/t/create-corridor-surface-python/49010/8
# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')
clr.AddReference('Civil3DNodes')
# Add standard Python references
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import os
import math
# Add references to manage arrays, collections and interact with the user
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox
# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp
# 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 for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
# Import references for Dynamo for Civil 3D
from Autodesk.Civil.DynamoNodes import Alignment as DynAlignment
adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor
civdoc = CivilApplication.ActiveDocument
#SS= IN[0]
XX= IN[1]
YY= IN[2]
i = 0
DynamoProfileView = IN[0]
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)
cor = t.GetObject(DynamoProfileView[0], OpenMode.ForWrite)
BX= cor.LabelLocation.X
BY= cor.LabelLocation.Y
#cor = t.GetObject(IN[0], OpenMode.ForWrite)
cor.UpgradeOpen()
cor.LabelLocation = Point3d(BX + XX, BY + YY, cor.LabelLocation.Z)
t.Commit()
#return
#XX= IN[0]
#YY= IN[1]
# Assign your output to the OUT variable.
Fantastic post. Thanks mate!!!
[quote=“hosneyalaa, post:2, topic:65826”]
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)
cor = t.GetObject(DynamoProfileView[0], OpenMode.ForWrite)
BX= cor.LabelLocation.X
BY= cor.LabelLocation.Y
#cor = t.GetObject(IN[0], OpenMode.ForWrite)
cor.UpgradeOpen()
cor.LabelLocation = Point3d(BX + XX, BY + YY, cor.LabelLocation.Z)
t.Commit()
#return
Can you help writing the code as a function?
To work on multiple LABELS
As in dynamo
Thank you
Hi @hosneyalaa
Is this what you need?
Hello @Kulkul
Yes, this is what I want
Is it possible to share the file?
@hosneyalaa below is the function:
import clr
# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')
clr.AddReference('Civil3DNodes')
# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp
# 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 for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor
civdoc = CivilApplication.ActiveDocument
XX= IN[1]
YY= IN[2]
objects = IN[0]
def move_labels(ids,xx,yy):
if not hasattr(xx, "__iter__"):
xx = [xx]
if not hasattr(yy, "__iter__"):
yy = [yy]
if not hasattr(ids, "__iter__"):
ids = [ids]
error_report = None
res = []
try:
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)
for i in ids:
obj = t.GetObject(i, OpenMode.ForWrite)
BX= obj.LabelLocation.X+xx[0]
BY= obj.LabelLocation.Y+yy[0]
BZ = obj.LabelLocation.Z
obj.UpgradeOpen()
obj.LabelLocation = Point3d(BX,BY,BZ)
res.append('Success')
t.Commit()
except:
import traceback
error_report = traceback.format_exc()
if error_report is None:
return res
else:
return error_report
OUT = move_labels(objects,XX,YY)
@Kulkul Thanks
for help
I can’t dynamo
I will try to be the change on DraggedOffset properties
instead of label location
Will be better
Thank you
Hello @Kulkul Kulkul,
Thanks for the script
@hosneyalaa @Kulkul @Tiago.Caldeira @manrajan.kalimuthu check out Camber, my new package for Civil 3D. There are nodes available for setting label properties, including dragged offset.
Hello @mzjensen ,
I hope you’re doing well.
I had tried with camber for structure label dragging. I couldn’t able to find the right node to form the graph.
Drag label.dwg (941.4 KB)
DragStructureLabel v0.03.dyn (39.3 KB)
@manrajan.kalimuthu it looks like you are using another package in addition to Camber for working with Structure labels.
This will not work because the object types used in that package can’t be combined with the object types in Camber. I haven’t implemented functionality for Pipe and Structure labels in Camber yet, but it is on the roadmap.
@hosneyalaa
Is this possible to move all labels one time instead of one by one ?
Can you attach any example drawing and example dyn file for your ideas
And
check out Camber package There are nodes available for setting label properties, including dragged offset.