Hello,
I am trying to import .dxf file via grasshopper with c# component. Everytime I run the script dialog box is opened to select a path. What I am looking for is…
a) it shall take file path as an input and import it without opening dialog box.
b) I do not know if it is possible, but I want to have the imported .dxf inside grasshopper and not in rhino so only if it is necessary i ll bake it.
Any help is this regard would be great!
here is the code i used to import
Rhino.RhinoApp.RunScript("_Import", false); // and the it opens up the dialog box to select path
That runs the command in UI mode. If you prefix a hyphen, you’ll run the command in command-line mode which allows you to compose the command fully in text:
Or something along those lines, you’ll hae to try in the Rhino command line first what sequence of commands actually works. Don’t forget to surround your filepath by double-quotes lest the spaces in it terminate the command early.
@DavidRutten
Can you also suggest anything for this. I have many profiles of mullions(around 100.dxf files). I dont need .dxf file in rhino every time I import (I want to read the .dxf and display it in viewport using grasshopper).
what I did is, I referenced “.netDxf” library in c# and tried reading the file
however it does read the file but does not show the geometry in the viewport, not sure if this is the right way.
@stevebaer there was talk about exposing the file import/export plugins in the SDK by having them populate separate File3dm instances. Is that available in Rhino6? I couldn’t find anything in the api docs.
Yes, I was writing up a “headless doc” sample for you and found that the DXF importer hangs on the command line when reading a doc. I’m working on a fix for this now.
The code creates a temporary Rhino document that doesn’t replace the active document. All of the geometry and attributes that you would get from a normal document are available.
Sorry for that , let me rephrase.
For example, when I’m calling RhinoDoc.Export to export a dwg file, I can still see command line asking me for export options and the Export method is stuck until I type enter in the command line window.
It seems due to many plugins literally interprets FileWriteOptions.SuppressDialogBoxes as suppressing dialog boxes, so they ask options on the command line.
I can understand importer/exporter plugins will be updated eventually but it seems a big project.
This is exactly what I’m cleaning up when we find out about it. Initially we are just eliminating all coomand line and dialog input and choosing ‘default’ options. Over time we can add file format specific options/functions to RhinoCommon as needed.
Thank you for this script in latest wip, I succeed in collecting the dxf files I want, how to extract their respective layer structure, and filter the objects to be processed? I join sample dxf files:Limon1Gche.DXF (19.9 KB) Limon2Dte.DXF (22.1 KB) Limon2Gche.DXF (19.0 KB)
Thank you very much mr. @stevebaer,
It looks really promising method since I’m trying import dxf files on rhino.compute locally.
But when I try to use it it gives me some error:
Error (CS1502): The best overloaded method match for 'Rhino.RhinoDoc.Import(string)' has some invalid arguments (line 59)
Error (CS1503): Argument 1: cannot convert from 'object' to 'string' (line 59)