Is it possible to open a dwg or dxf in dynamo sandbox?
I want to use it to bring solids inside forma.
I found this old thread for Dynamo studio:
but I wonder if there is anything similar for sandbox.
The reason I dont want to do it in Revit is because we are long way to get to r2024.
Not readily at the moment. There is work underway to add more basic file functionality out of the box which might make importing DWGs doable in sandbox in the future.
For now you might be able to use the LinkDWG package or LinkDWG2 package, or BriMohareb package, all of which will require you open a particular version of Civil 3D or AutoCAD to make things work. Alternatively you can look at using Dynamo for Civil 3D for more direct DWG interaction.
Hi Jacob, thanks for letting me know.
Hi,
if 3DSolids can be converted to Meshes (in Autocad), you can use libraries such as netDxf to read and convert entities
# Load the Python Standard and DesignScript Libraries
import sys
import clr
import System
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry as DS
from Autodesk.DesignScript.Geometry import *
lib_dxf_path = IN[0]
outDxfpath = IN[1]
lib_dxf_dir_path = System.IO.Path.GetDirectoryName(lib_dxf_path)
sys.path.append(lib_dxf_dir_path)
clr.AddReference('netDxf.netstandard')
import netDxf
from netDxf import *
from netDxf.Blocks import *
from netDxf.Collections import *
from netDxf.Entities import *
from netDxf.Tables import *
out_solids = []
doc_dxf = DxfDocument()
doc_dxf = netDxf.DxfDocument.Load(outDxfpath)
lstBlk = doc_dxf.Blocks
lstBlkName = [x.Name for x in lstBlk]
lstM_text = doc_dxf.MTexts
lst_text = doc_dxf.Texts
meshs = doc_dxf.Meshes
for m in meshs:
faces_indices = m.Faces
lst_vertices = list(m.Vertexes)
lst_array_pts = [[lst_vertices[idx] for idx in group ] for group in faces_indices ]
lst_array_pts = [[DS.Point.ByCoordinates(vect3.X, vect3.Y, vect3.Z) for vect3 in group] for group in lst_array_pts ]
lst_surface = [DS.Surface.ByPerimeterPoints(groupPts) for groupPts in lst_array_pts ]
ds_solid = DS.Solid.ByJoinedSurfaces(lst_surface)
out_solids.append(ds_solid)
OUT = out_solids