I want to select an object I have in brep format. How can I do this using Rhino module or rhinoscriptsyntax module?
You can select by name (if you know the name), the guid (same there, if you know it’s guid), or by layer, or by color, or by any property that the object has.
If the property is not unique (like a name or guid) you may filter on combined properties, like location, volume, area, color, whatever. There are many options.
To learn more about GetObject() or GetObjects() and filtering the result, search this forum and/or the RhinoCommon documentation (the documentation takes some getting used to to find you way in, but there are many examples on the forum
Hello - it depends on the context - for instance if the script has made the brep then you should have a guid you can track.
I have the guid of two edges of two different surfaces. Now I want to index those specific edges from brep.Edges. How do I achieve this?
edge_guid1 = (contains some edge guid)
edge_guid2 = (contains some edge guid)
srf_A_GUID = rs.GetObject(“select 1st surface”, filter = rs.filter.surface)
srf_B_GUID = rs.GetObject(“select 2nd surface”, filter = rs.filter.surface)
brep_A = rs.coercebrep(srf_A_GUID)
brep_B = rs.coercebrep(srf_B_GUID)
face_A = brep_A.Faces
edge_A = brep_A.Edges
face_B = brep_B.Faces
edge_B = brep_B.Edges
Instead of using index 3, I want to index the edge with edge_guid1 from face_A and edge_guid2 from face_B automatically.
So… edges do not have guids in the same way that top level objects have - in what form are these in the script?
I have extracted the edges using rs.DuplicateEdgeCurves() and stored them in a list.
So, then at this point these are top level curves as curves and no longer edges - they are no longer connected to the brep in any way. The thing to do, in my view at least, is to get the edges as edges with a filtered selection:
import Rhino import scriptcontext as sc def SelectAnEdge(): go = Rhino.Input.Custom.GetObject() go.DisablePreSelect() go.SetCommandPrompt("Select an edge") go.GeometryFilter = Rhino.DocObjects.ObjectType.EdgeFilter result = go.Get() if( go.CommandResult() != Rhino.Commands.Result.Success ): return if result == Rhino.Input.GetResult.Object: objref = go.Object(0) idx = objref.GeometryComponentIndex.Index Id = objref.ObjectId brep = objref.Brep() edge = brep.Edges[idx] edgeCrv = edge.ToNurbsCurve() SelectAnEdge()
Thank you for the information.
What should I do if I don’t want to select it manually from the object? Is there any way to do that?
You mean something like this:
import rhinoscriptsyntax as rs import scriptcontext as sc import Rhino srf_A_GUID = rs.AddSrfPt(([-5,-5,0],[5,-5,0],[5,5,0],[-5,5,0])) srf_B_GUID = rs.AddSrfPt(([15,5,5],[25,5,5],[25,-5,5],[15,-5,5])) edgeGuid_A = rs.AddLine([5,-5,0], [5,5,0]) edgeGuid_B = rs.AddLine([15,-5,5], [15,5,5]) brep_A = rs.coercebrep(srf_A_GUID) brep_B = rs.coercebrep(srf_B_GUID) face_A = brep_A.Faces for edge in brep_A.Edges: edgeMid = edge.ToNurbsCurve().PointAtNormalizedLength(0.5) edgeGuidMid = rs.CurveMidPoint(edgeGuid_A) if edgeMid.DistanceTo(edgeGuidMid) == 0: edge_A = edge ival_A = edge_A.ToNurbsCurve().Domain cont_A = Rhino.Geometry.BlendContinuity.Curvature face_B = brep_B.Faces for edge in brep_B.Edges: edgeMid = edge.ToNurbsCurve().PointAtNormalizedLength(0.5) edgeGuidMid = rs.CurveMidPoint(edgeGuid_B) if edgeMid.DistanceTo(edgeGuidMid) == 0: edge_B = edge ival_B = edge_B.ToNurbsCurve().Domain cont_B = Rhino.Geometry.BlendContinuity.Curvature rcs = Rhino.Geometry.Brep.CreateBlendSurface(face_A, edge_A, ival_A, True, cont_A, face_B, edge_B, ival_B, True, cont_B) for rc in rcs: sc.doc.Objects.AddBrep(rc) sc.doc.Views.Redraw()
Satadeep.py (1.2 KB)