Hi
I am new to Civil 3D API. Now I am trying to use some of the Civil 3D command with python inside Revit Dynamo or Rhino.Inside Grasshopper.
I have somehow established a connection to the Civil 3D active document inside Revit Dynamo or grasshopper. However when I get to use this command Alignment.PointLocation(station, offset, easting, northing), the python editor returned nothing although no error occurred.
Can anyone with this experience give me any hint on this?
Thanks in advance
Hi @Josh.Wang,
I don’t have much experience with Grasshopper, but I can help with the Civil 3D side. Are you able to get the alignment names correctly? In other words, is it just that particular method that isn’t working?
Also, I’m pretty sure for that method you need to pass the easting and northing by reference.
Hi
Never tried it before Inside the Revit program
Do you use this method to connect?
You can try this method in the link
Hi @zachri.jensen Zachri
Thanks for your speedy reply.
I guess it’s more of a python syntax issue as i am not entirely sure how to pass reference objects onto a method to get updated values for those objects with python.
For your question, i can get the alignment names correctly and the starting/ending station value.
It will be great if you can provide a python version of using this particular method.
Many thanks
Hi @hosneyalaa
Thanks for sharing. I am indeed using this method to establish the connection. Just need to update the m_sAcadProdID and m_sAeccAppProgId to corresponding Civil3D version, then should be able to connect.
You should be able to just do something like this:
easting, northing = align.PointLocation(station, elevation, 0, 0)
Then use easting
and northing
for whatever you need after that. Also note that the method throws a PointNotOnEntityException when the station is outside the alignment’s station range, so it might be good to handle that.
Thanks again, @zachri.jensen
I have tried this method using the .Net API inside Civil 3D Dynamo python scriptor and it worked.
However, when I tried that in the Dynamo/Grasshopper of Revit, the interpreter just returned a error message. After checking the type of the alignment object, it indicated ‘ComObject’. So i guess that’s probably why you introduced the command ‘InternalDBObject’ to somehow ‘unwrap’ the ComObject in the first place. But I am not too sure how to unwrap the ComObject with the COM API.
Oh wow, I don’t know how I overlooked that
Yes, COM is being used in this case since we are outside of AutoCAD. I’ll try to share some more info later this morning.
OK nevermind, I thought maybe the method signature was different in the COM API but it looks the same. Now that I see the error a little clearer, it looks like oAeccDb.AlignmentsSiteless
is none?
I don’t have much experience with Grasshopper, but it looks like maybe it uses IronPython? This might help:
Try
align.PointLocation(station, elevation,easting , northing)
Points =list (easting , northing)
Thanks @zachri.jensen.
Your sharing link offered great help to solve the problem.
The source of the issue was that i didn’t introduce the by-reference objects in IronPython to the .Net method requesting by-ref parameters. Then I tried the steps from the Rhino.Python guides and the problem got resolved. Now I am on the fly.
The script example is as in the following pic if anyone wants to make a connection to Active Civil3D document outside Civil 3D and play around with the API. This might be a good thing to try from the perspective of developer.
1 Like