Grasshopper

algorithmic modeling for Rhino

Hi,

I am wondering if it is possible to get a GUID of a geometry (a point in this case) within the script itself - I know I can get the GUID of an input geometry if I change the type hint in the inputs of the GHPython component; however, here I am just trying to move the point created within the script to have a line then connecting them (I'd much rather implement something more like a Line SDL component method but I can't seem to figure out how to do that in a rhinoscriptsyntax context).

Please find attached the GH file, and the problem I am referring to happens in the end in the line that I am declaring the variable "endPt".

Error copied here:

Runtime error (TypeErrorException): Parameter must be a Guid or string representing a Guid
Traceback:
line 495, in coerceguid, "C:\Users\user\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\utility.py"
line 1140, in TransformObjects, "C:\Users\user\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\object.py"
line 405, in MoveObjects, "C:\Users\user\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\object.py"
line 391, in MoveObject, "C:\Users\user\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\object.py"
line 34, in script

Thanks a lot for the help,

Tim

Views: 2711

Attachments:

Replies to This Discussion

Hi Timothy,

EvaluateCurve returns a Point3d, which is a RhinoCommon point object. It is similar to Vector3d, and it is not a "visible" part of a document, it's just an entity. As such, MoveObject() will not work, because this takes an object in the document, saves the location in the undo stack, and then adds a new object which is translated.

You can however use the rhinoscriptsyntax point methods, like PointAdd() etc, or, if you have a point and a vector, just use the + operator.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Attachments:

Hi Giulio,

Thank you for the response.

I have realized that later last night, and did indeed call on the rs.VectorCreate method,

but have followed that with this line of command:

crvCp_vect = rs.VectorCreate(ctr_2, ccx[0])
endPt = rc.Geometry.Point3d.Add(crvCp, crvCp_vect)

instead of the + operator you suggested.

I am guessing using the + operator would be more "efficient"?

And probably better not to mix rc methods in?

Thanks again,

Tim

Hi Timothy,

the + operator is just like calling the Add() static method, it's not particularly more optimized. It's nice because it's shorter, though.

You can mix RhinoCommon and rs methods together, it's fine, as long as you know what you are doing :)

rs.PointAdd(pt, vctr) allows to do the same, using only rhinoscriptsyntax, which is nice.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi Giulio,

I see, thanks!

I also realized I can do this, too - actually adding the point into the doc through scriptcontext methods and thus get the GUID of the object:

crvCp = rs.EvaluateCurve(cir_min[0], crvCp_par)
crvCp_vect = rs.VectorCreate(ctr_2, ccx[0])
crvCp_GUID = sc.doc.Objects.AddPoint(crvCp)
endPt = rs.MoveObject(crvCp_GUID, crvCp_vect)

And once again, would this be less optimized because it is going through more actions?

Thanks,

Tim

Yes adding it will be slightly less optimized.

I see, thanks a lot again - am understanding this better now!

Hi Tim,

Did you end up figuring this : "I'd much rather implement something more like a Line SDL component method but I can't seem to figure out how to do that in a rhinoscriptsyntax context)"

I am building a script for an extrusion with a draft angle from any closed curved in any plan that's why I need the Line SDL because it gives me the normal and the distance. Then I can access the end point of the normal and get my extrusion.

This is my first script ever in python and rhinoscript for grasshopper. No coding background, so I am on my own and can't find any solution on forums. I attached the script for you.

Thanks for your help,

Kevin

Attachments:

Hi Kevin,

I opened your file but the geometries are not internalized, so I can't really see what you're trying to do. But, from your description, it sounds like you might be able to just use the "Extrude" component in grasshopper where you could just supply your desired vector and length? Also, this forum is obsolete and you recommend you to ask your questions on the McNeel Forum (https://discourse.mcneel.com/).

Tim

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service