export dxf from ghpython - Grasshopper2024-03-29T05:58:56Zhttps://www.grasshopper3d.com/forum/topics/export-dxf-from-ghpython?commentId=2985220%3AComment%3A1070494&feed=yes&xn_auth=noHi Rustboy
Rhino does not kno…tag:www.grasshopper3d.com,2014-05-20:2985220:Comment:10732422014-05-20T11:42:34.301ZGiulio Piacentinohttps://www.grasshopper3d.com/profile/GiulioPiacentino
<p>Hi Rustboy</p>
<p>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.</p>
<p>So, if you are using rhinoscriptsyntax, for a line, you have to get fromX and fromY using:</p>
<p>fromX = rs.CurveStartPoint(crv_id).X<br></br>fromY = rs.CurveStartPoint(crv_id).Y</p>
<p>etc..</p>
<p>Does it help?<br></br>As you can see, there is some work. Also, you need to…</p>
<p>Hi Rustboy</p>
<p>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.</p>
<p>So, if you are using rhinoscriptsyntax, for a line, you have to get fromX and fromY using:</p>
<p>fromX = rs.CurveStartPoint(crv_id).X<br/>fromY = rs.CurveStartPoint(crv_id).Y</p>
<p>etc..</p>
<p>Does it help?<br/>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.</p>
<p>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)</p>
<p></p>
<p>Giulio</p>
<p><span>--</span><br/><span>Giulio Piacentino</span><br/><span>for Robert McNeel & Associates</span><br/><span>giulio@mcneel.com</span></p> Hi Giulio, thanks for the rep…tag:www.grasshopper3d.com,2014-05-19:2985220:Comment:10727992014-05-19T19:06:48.780ZRustBoyhttps://www.grasshopper3d.com/profile/RustBoy
<p>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…</p>
<p>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?</p>
<p>much appreciated</p>
<p><a target="_self" href="http://storage.ning.com/topology/rest/1.0/file/get/2768890777?profile=original"><img width="721" class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2768890777?profile=RESIZE_1024x1024" width="721"/></a><a target="_self" href="http://storage.ning.com/topology/rest/1.0/file/get/2768893257?profile=original"><img width="721" class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2768893257?profile=RESIZE_1024x1024" width="721"/></a></p> Hi Rustboy
this works pretty…tag:www.grasshopper3d.com,2014-05-19:2985220:Comment:10725552014-05-19T07:46:04.278ZGiulio Piacentinohttps://www.grasshopper3d.com/profile/GiulioPiacentino
<p>Hi Rustboy</p>
<p>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.</p>
<p>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)…</p>
<p>Hi Rustboy</p>
<p>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.</p>
<p>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.</p>
<p>Does it help?<br/>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.</p>
<p>Thanks,</p>
<p>Giulio</p>
<p>--<br/>Giulio Piacentino<br/>for Robert McNeel & Associates<br/>giulio@mcneel.com</p> Success! Now I would like to…tag:www.grasshopper3d.com,2014-05-18:2985220:Comment:10724132014-05-18T19:20:52.298ZRustBoyhttps://www.grasshopper3d.com/profile/RustBoy
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2768890466?profile=original" target="_self"><img class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2768890466?profile=RESIZE_1024x1024" width="721"></img></a> Success! Now I would like to work out how to use the component inputs for <span style="text-decoration: underline;">gh</span> geometry instead of generating it inside the component. I wonder if anyone has some simple examples I could refer…</p>
<p><a target="_self" href="http://storage.ning.com/topology/rest/1.0/file/get/2768890466?profile=original"><img width="721" class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2768890466?profile=RESIZE_1024x1024" width="721"/></a>Success! Now I would like to work out how to use the component inputs for <span style="text-decoration: underline;">gh</span> geometry instead of generating it inside the component. I wonder if anyone has some simple examples I could refer to?</p>
<p>thanks</p> thanks Giulio, I will give th…tag:www.grasshopper3d.com,2014-05-15:2985220:Comment:10704942014-05-15T14:03:23.962ZRustBoyhttps://www.grasshopper3d.com/profile/RustBoy
<p>thanks Giulio, I will give this a try tonight and move on to the next step.</p>
<p>cheers</p>
<p>thanks Giulio, I will give this a try tonight and move on to the next step.</p>
<p>cheers</p> Hi,
there was a missing close…tag:www.grasshopper3d.com,2014-05-15:2985220:Comment:10704572014-05-15T06:30:01.796ZGiulio Piacentinohttps://www.grasshopper3d.com/profile/GiulioPiacentino
<p>Hi,</p>
<p>there was a missing closed parenthesis, ) , at the end of line 7.</p>
<p>Also, you need to specify a folder more precisely. Other than that, it seems to work nicely here.</p>
<p>I hope this helps,</p>
<p><span>Giulio</span><br/><span>--</span><br/><span>Giulio Piacentino</span><br/><span>for Robert McNeel & Associates</span><br/><span>giulio@mcneel.com</span></p>
<p>Hi,</p>
<p>there was a missing closed parenthesis, ) , at the end of line 7.</p>
<p>Also, you need to specify a folder more precisely. Other than that, it seems to work nicely here.</p>
<p>I hope this helps,</p>
<p><span>Giulio</span><br/><span>--</span><br/><span>Giulio Piacentino</span><br/><span>for Robert McNeel & Associates</span><br/><span>giulio@mcneel.com</span></p> This is a question that many…tag:www.grasshopper3d.com,2014-05-15:2985220:Comment:10705912014-05-15T06:20:57.986ZGiulio Piacentinohttps://www.grasshopper3d.com/profile/GiulioPiacentino
<p>This is a question that many people starting with Python have :)</p>
<p><a href="https://docs.python.org/2/tutorial/modules.html#the-module-search-path" target="_blank">https://docs.python.org/2/tutorial/modules.html#the-module-search-path</a></p>
<p>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.</p>
<p>Giulio<br></br>--<br></br>Giulio…</p>
<p>This is a question that many people starting with Python have :)</p>
<p><a href="https://docs.python.org/2/tutorial/modules.html#the-module-search-path" target="_blank">https://docs.python.org/2/tutorial/modules.html#the-module-search-path</a></p>
<p>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.</p>
<p>Giulio<br/>--<br/>Giulio Piacentino<br/>for Robert McNeel & Associates<br/>giulio@mcneel.com</p> further to my question, when…tag:www.grasshopper3d.com,2014-05-15:2985220:Comment:10705522014-05-15T03:36:30.800ZRustBoyhttps://www.grasshopper3d.com/profile/RustBoy
further to my question, when you download then import dxfwrite into the code, how does python know where to look for it? I was surprised there seems to be no need to supply a path when importing.
further to my question, when you download then import dxfwrite into the code, how does python know where to look for it? I was surprised there seems to be no need to supply a path when importing.