Extract Solids for Multiple Corridors

Soo, there has been some progress I guess.

2 Likes

I believe that there is light at the end of the tunnel.

1 Like

That means no way to extract solids for multiple corridors

Please if you have any thing to help me
Thanks in advance

Good news everyone!
This is now covered in the 2023.2 Update API.

Here’s a test script:

# 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 *

from System import Array

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

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

corridorin = IN[0]
exludedcodesin = IN[1]

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

        with db.TransactionManager.StartTransaction() as t:
            # Place your code below
            for i in range(len(corridorin)):
				exlcodes = Array[str](exludedcodesin[i])
				#for i in range(len(exludedcodesin)):
				#exlcode = Array[str](exludedcodesin)
				#exlcodes.Append(exlcode)
				#exlcodes = ["0", "Top"]
				corridorId = corridorin[i].InternalObjectId
				# Open corridor object
				corridor = t.GetObject(corridorId, OpenMode.ForWrite)
				param = ExportCorridorSolidsParams()
				param.ExcludedCodes = exlcodes
				export = corridor.ExportSolids(param,db)
            # Commit before end transaction
            t.Commit()
            pass

# Assign your output to the OUT variable.
OUT = exludedcodesin[0]

Included or excluded codes have to be defined in the ExportCorridorSolidsParams() Class
These should be string arrays.

11 Likes

Can you please give me an example with a dyn script & C3D files, as I unfortunately failed to run the above python script.

I put some comments in the script.
Note that this is a rough test script it handles basically nothing as I din’t have time to improve it :smiley:
So it is working with multiple corridors, but all inputs must be on the correct level, can’t be empty etc.
If you want to define inlcuded codes not the excluded, then change param.ExcludedCodes to param.IncludedCodes
And if you want to export only shapes or links add:
param.ExportLinks = false
param.ExportShapes = false
exportcorridorsolids.dwg (6.5 MB)
exportcorridorsolids.dyn (26.1 KB)

2 Likes

Hi, Thanks for the topic, struggling to find a solution for this as well.

I’ve tried to extract solids by node “Solid.ByLoft”, everything seems to work, but I can’t see any solids inserted into drawing.


What am I missing here?

I’m using Civil 2021 still.

Thanks in advance!
Eno

You have to return Dynamo solids from loft Nodes to C3D Geometry inside your DWG. Try use Object.byGeometry Node.

1 Like

Hi All,

I have updated the script. Removed the exlcodes = Arraystr and changed the line 'param.ExcludedCodes = exlcodes to param.ExcludedCodes = exludedcodesin[i].

  • Added error handler to the python script.
  • Added export solids and body’s to a new drawing.
    exportcorridorsolids.dyn (65.0 KB)
7 Likes

Oh, cool stuff, will def test it later. Thanks.

Hi All,

If i try to use:
param.ExportLinks = false and commented the line param.ExcludedCodes = exludedcodesin[i]

Then I get the following error:
image

Hi all,

Got the scrypt running, it handles some times pretty well sometimes it doesn’t. But my question is a bit different. In Civil 3D we have a command to extract solids - Extract Corridor Solids - which works brilliantly, but all the work is manual. Isn’t there / Can’t there be a node which can allow us to select diffrent shapes, set layers, colors via this command and automate the whole process? At the moment with the custom node introduced above, we first create solids in Dynamo and then return them to C3D which is difficult when the geometry of a solid is complicated.

Hello All ,

I am having the same error ,

Does anyone else has tested this dynmo scripts and knows how to resolve this error ?

Hello All ,

I am having the same error ,

Does anyone else has tested this dynmo scripts and knows how to resolve this error ?

Make sure that you’re using C3D 2023 or above.

Hello Kovacsv ,

This is Sara , I am new with code world and I am facing the same situation of having multiple coordiors to extracted as solid , After a few search I came a cross of this code and seems to be the solution , May you able to help me and let me know how to use this code on my civil 3d , thanks you

Hello All ,

I am having the same error ,

image

Does anyone else has tested this dynmo scripts and knows how to resolve this error ?

As noted above by @Ahmed.Kamal.Moussa - make sure you’re in Civil 3D 2023.2 or later.

Often the specific failure message is a result of attempting to commit data into a block which was not opened for write access, but without seeing everything you’ve attempted we cannot confirm. Post a sample file with the DYN you’re using currently (here or if your account is too new use a 3rd party hosting service such as drop box, Google drive, box, onedrive, etc.).

Hi Jacob ,

Thanks for your reply , I am using Civil3D 2023 , here is the link of Google drive which has my Civil 3d File having around 50 Cooridors and the Dynamo I downloaded from here ,

https://drive.google.com/drive/folders/1s7ptVtoYsjMOs8r_yxdBwprro4kCebzV?usp=share_link