algorithmic modeling for Rhino
Hi, please excuse my noobness.. I'm attempting to export geometry from gh using a custom ghpython component. I've imported dxfwrite
(from here: https://pypi.python.org/pypi/dxfwrite/1.2.0#downloads
but I receive this msg when trying to run their sample code:
My hope is to be able to export groups of rectangles as a dxf file with multiple layers for use with a cnc machine. Any help pointing me in the right direction would be much appreciated.
thanks
Tags:
This is a question that many people starting with Python have :)
https://docs.python.org/2/tutorial/modules.html#the-module-search-path
In Rhino there's also a visual editor for that. You can manually add folders in the Tools -> Options menu. GhPython, additionally, adds the folder where you have your .ghx (Grasshopper) file saved.
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Hi,
there was a missing closed parenthesis, ) , at the end of line 7.
Also, you need to specify a folder more precisely. Other than that, it seems to work nicely here.
I hope this helps,
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
thanks Giulio, I will give this a try tonight and move on to the next step.
cheers
Hi Rustboy
this works pretty much like in the _EditPythonScript editor. If 'Type Hint' for inputs is unchanged, x will be a rhinoscript Guid, with which you can use rs.CurveStartPoint(x), etc... y, z will be strings, u will be a Boolean True/False value.
This is because Python is dynamic, that we can just start using variables. If you need to force some special type to inputs, you can change 'type hint'. Please note: Line, Curve, etc are RhinoCommon (import Rhino) types.
Does it help?
There are several more examples on the forum, too, but don't be afraid to open a new discussion and ask about new specific things.
Thanks,
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Hi Giulio, thanks for the reply. I left the type hint unchanged as you said, and tried to insert the rectangle into the code using dxfwrite (shown in attached image). I can't tell if this is something the dxfwrite library was designed to do - I only see examples for creating geometry within python - not importing gh geometry which is what I want to do. You can see in the image that "GUID has no attribut dxf.." It recognizes the x input so I'm making progress but I need to bring in exisiting rectangles from gh. Is there possibly some code from Rhino I could insert to accomplish this?
much appreciated
Hi Rustboy
Rhino does not know about dxfwrite, and dxfwrite does not know about Rhino. This means that you will have to translate types yourself. You can see that dxf.line((fromX,fromY), (toX,toY)) creates a line.
So, if you are using rhinoscriptsyntax, for a line, you have to get fromX and fromY using:
fromX = rs.CurveStartPoint(crv_id).X
fromY = rs.CurveStartPoint(crv_id).Y
etc..
Does it help?
As you can see, there is some work. Also, you need to decide how to handle the Z component of point coordinates, if you use that specific call.
I am actually curious why you would want to start with that specific library - Rhino can export dxf with one click, right? (just making sure you are aware of that)
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by