Import DXF and Manipulate in Grasshopper

It’s possible to attach DXF files as worksessions. Usually worksessions are 3dm files, however if you set your default import options, rhino will attach without asking for options.

I use python code similar to below for attaching worksessions in grasshopper.

https://discourse.mcneel.com/t/batch-rhino-grasshopper-automation-with-worksessions/77985

#P is a list of filepaths to attach to worksession 
for p in P: 
#command must be surrounded with '' so that file path can e surrounded with "" 
#this ensures that paths with spaces still work 
    rs.Command('-Worksession Attach "{}" _Enter'.format(p))

After the worksessions are attached, you can use elefront to reference by layer name.
Use the full layer name including file name.
This will ensure that if you have many files with identical layer names, you will still be able to identify and reference them uniquely.
Eg from file1.dxf you want a layer named “fold”
Reference by layer name should take file1.dxf::fold

If this doesn’t help I can put together an example when I’m at a computer.

1 Like