Extruding polylines and creating masses from a cad file

Ok, I will try to fix them. Thank you very much!

  1. Disable all geometry preview up unitl the first node with a warning.
  2. expand the data preview of all nodes connected to the first node with a warning, and the first node with a warning.
  3. Export the canvas as an image after zooming in with the data previews expanded
  4. Copy the warning to your clipboard (use graph node manager, available in the extension tab to do this)
  5. post the preview geometry, the exported canvas, and warning

My guess is your have 3 curves meeting at one point, which is a no-no. Likely the DWG doens’t have this, so moving back into a “run a prep method to extract the data in the native DWG format so polycurve data is not lost” is the easy way forward.

1 Like

Hi,

for info, Revit import Cad curves as PolyLine, we can get them directly

import clr 
import sys 
import System 
# Add references 
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

# Add references to 'RevitNodes' and 'RevitServices' for Revit-specific functionality
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

def purge_points(coords_xyz):
    out_pts = []
    for c_xyz in coords_xyz:
        if all(p.DistanceTo(c_xyz) > 0.001 for p in out_pts):
            out_pts.append(c_xyz)
    return out_pts

def get_Curves_from_CAD(importinstance, lst_layerName=[]):
    datas = []  
    opt = Options()
    # get the geometry of the import instance
    geoSet = importinstance.get_Geometry(opt)
    for geo in geoSet:
        if isinstance(geo, GeometryInstance):
            for g in geo.GetInstanceGeometry():
                if isinstance(g, DB.PolyLine):
                    # get the graphics style and name of the current polyline
                    gStyle = doc.GetElement(g.GraphicsStyleId)
                    gstyleName = gStyle.GraphicsStyleCategory.Name
                    # check if the layer name is in the specified list
                    if gstyleName in lst_layerName:
                        purge_coordinates = purge_points(g.GetCoordinates())
                        # create a DesignScript polycurve from the polyline
                        ds_polycurve = DS.PolyCurve.ByPoints([p.ToPoint() for p in purge_coordinates], True)
                        datas.append(ds_polycurve)
                        
    return datas


importinstance = UnwrapElement(IN[0])
lst_layerName = IN[1]

OUT = get_Curves_from_CAD(importinstance, lst_layerName)
2 Likes

Good morning! I have tried again with this script, after adjusting the geometry. It works, but it seems that you have to repeat it for every single polygon (in this case I tried 3). Is there a way to select them all at the same time?

I solved it. I had not noticed an error in the script. Thanks again to everyone!

1 Like

I have another matter to resolve. Why is it that once the script is executed, when I close dynamo, the objects created disappear?

hi,
you have to use DynamoPlayer

cordially
christian.stan

For now, I don’t know how to do as previously said, recurrence and python are too complicated for my current skills

cordially
christian.stan