Thanks @c.poupin,
I tried to translate the examples you provided to work with my code and unfortunatley I am either not getting it OR there is another issue that is stopping this from working.
Please see my amended snippet of my previous attempt:
global adoc
global cdoc
s1 = "station" #dummy inputs as per advice on other threads
o1 = "offset"
# use float as no longer able to use
# - strongbox functionality as per ironpython i.e. Double #clr.Reference[float]()
station = 1.23
offset = 1.23
output = []
nm=[]
sta=[]
offs=[]
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)
alignment = None
for ind,x in enumerate(name):
#ind=name.index(i)
for oid in cdoc.GetSitelessAlignmentIds():
al = t.GetObject(oid, OpenMode.ForRead)
if al.Name == name[ind]:
alignment = al
# so trying to use 'dummy' inputs and station offset will be returned to assigned float vars?
station,offset=alignment.StationOffset(easting[ind], northing[ind],s1,o1)
sta.append(station)
offs.append(offset)
break
# Couldn't find the alignment with the given name
if alignment is None:
return
#need to allow for start and and points and for flipping osl and os right points
return [sta, offs]
OUT = get_soe_by_en(names, northings, eastings)
This crashes Civil 3d with unhandled Type Error.
Any further feedback appreciated, maybe @Paolo_Emilio_Serra1 could advise to correct solution here is possible, thanks.
@c.poupin Was there ever a solution/workaround for the family load code you pasted a while back? Iâm trying to get that exact same code to work in CPython3 and am having the same issue you experienced (âinterface takes exactly one arguementâŚâ). Thanks!
any update on that issue? Could you solve it or is there no way to fix that?
I ran into the same problem unfortunatelyâŚ
Thank you in advance for your answer!
no, I have the impression that PythonNet 2.5.2 fails to Release all resources for some Revit Objects created.
Iâm waiting for PythonNet 3.0 hoping that fixes the problem.
Since CPython is running in C, and the COM apis are running in C#, I think youâll need to explicitly import the windows COM client (win32com). If that doesnât work then it may be that youâd have to go through the process of building the COM interop at the level which the Python engine is executing. However before you consider that, Iâll quote a stack exchange post:
implementing or using COM components in C requires a horrendous amount of work, but higher-level languages like Visual Basic have done a lot to ease the implementation and use of COM components
Assuming that is out, and you canât find a way to interact with the win32com client directly, then you still ahve options.
Install the DynamoIronPython2.7 package. This will give you IronPython and ensure previous code works, at the cost of having a possible security risk on the system.
Switch out of the COM api and utilize the .net api directly. This would be the direction Iâd recommend, as your code will be faster and more reliable than the COM library youâre using, and youâre already in the same tool so you need not marshal data between processes.
In the longer term, there is an IronPython implementation of a supported Python version which may be ported over to Dynamo in the future. Make no purchasing decisions, but Iâll be a proponent of this.
I looked at the win32com module. It seems that module is not installed with Dynamo in Revit so that is an additional issue. How would you use/install that module and make sure that other users have it too?
Option 1 is possible but I rather would use it as a last resort.
Option 2 is not possible because I want to talk with Civil 3D from inside Dynamo in Revit. Iâm not in the same tool so I do need to marshal data between processes (Civil 3D and Revit), or am I that wrong?
I know about the CivilConnection package but I already created my own custom nodes and scripts before that package was widely available.
Maybe I do have to use this package or create my own .NET nodes.
And hi Hosneyalaa,
It seems you didnât read my question that well.
It doesnât matter which Civil 3D I want to use.
I am unable to import ANY âAutodesk.AutoCAD.xxxâ or âAutodesk.AECC.xxxâ module with CPython3.
this allows you to abandon Python2.7 and switch to python3 through the 2 python engines (Ironpython3 and CPython3/Pythonnet) which each have advantages (as example IronPython is Net native)