Extrusion from a Block

Hi,
I’m trying to extrude the curves contained in a block instance, but it does not seem possible?
How can I extract the geometry, and extrude as a closed polysurface? (solid)
(My bloc contains only the curves I need)

Thanks for helping

To extrude the curves in a block, you will need to do the following:

1.) Get the block (instance reference).
2.) Get the block’s definition (instance definition)
3.) Obtain the instance definition geometry.
4.) Transform the instance definition geometry using the instance definition’s transformation.
5.) Extrude the curves.

Does this help?

Ive found that you can extrude curves in a block without exploding or anything, just run extrude, and select your curves then hit enter. The problem is that it wont visually show you that the curves are being selected (wont turn yellow) but it does work.

Try doing a bounding box around them when you select. You can also extude srf edges in a block this way, but same problem they dont show up as you select them.

Thanks Dale, but I still don’t get it:

            MyBlocInstance = doc.Objects.Find(BlocID)
            Dim MyBlocDefinition As Rhino.DocObjects.InstanceDefinition
            MyBlocDefinition = MyBlocInstance.InstanceDefinition

The instancedefinition object don’t have a geometry property.

I also tried to explode the block instance instead, but I don’t know how to join the curves I got from the explode:

Dim MyProfile As Rhino.Geometry.Curve
        
MyBlocInstance = doc.Objects.Find(BlocID)

Dim myCurves() As Rhino.DocObjects.RhinoObject
            Dim TpPiecesAttributes() As Rhino.DocObjects.ObjectAttributes
            Dim TpTransform() As Rhino.Geometry.Transform
            MyBlocInstance.Explode(True, myCurves, TpPiecesAttributes, TpTransform)
            For Each tp As Rhino.DocObjects.RhinoObject In myCurves
                If tp.ObjectType = DocObjects.ObjectType.Curve Then

                End If
            Next

 Dim MyExtrusion As Rhino.Geometry.Extrusion = Rhino.Geometry.Extrusion.CreateExtrusion(MyProfile, PlanNormalVector)
            doc.Objects.AddExtrusion(MyExtrusion)

Thanks nscross, but I am trying to do this in vb.net

Dim t As DocObjects.InstanceDefinition = doc.InstanceDefinitions.Find(BlocID, True)
Dim objs() As DocObjects.RhinoObject = t.GetObjects
For Each o In objs
// filter your curve
Next

You are looking in the Objects library. Not in int InstanceDefinitions :wink:

You can join the curves if you got them in an array. like

Dim CurveArray() as Geometry.Curve = CurveList.ToArray //Defined somewhere else
Dim JoinedCrv() as Geometry.Cruve = Geometry.Curve.JoinCurves(CurveArray, 2.5 * doc.AbsoluteTollerance)

I don’t get why I would need the instance reference? The instance object has a geometry, that should do?
I can’t find how to get a list of curves from a list of objects.

Anyway, I tried something easier with the runscript:

For Each SelectedObj In doc.Objects.GetSelectedObjects(True, True) SelectedObj.Select(False) Next MyBlocInstance = doc.Objects.Find(BlocID) MyBlocInstance.Select(True) Rhino.RhinoApp.RunScript("-_Explode ENTER", False) Rhino.RhinoApp.RunScript("-_ExtrudeCrv Bothsides=Yes 200 ENTER", False) Rhino.RhinoApp.RunScript("-_delete", False) Rhino.RhinoApp.RunScript("-_selLast DeselectOthersBeforeSelect=Yes ENTER", False) Dim MyExtrusion As Rhino.DocObjects.RhinoObject For Each SelectedObj In doc.Objects.GetSelectedObjects(False, False) MyExtrusion = SelectedObj Next

Well its possible that one file has multiple of the same blocks. You get the block 1 time. Get the curves, extrude and update the block. If you have, for example, 10 of the same blocks with 10 curves. You now have to do 100 extrusions. If you update the block you only have to do 10 extrusions because you update the block itself.

I thought you wanted to have the extrusions inside of the block. Thats the main idea of a block instance. So you dont have to redraw things 10 times.

Sorry for not being clear enough.
I’m am just using the blocks as a storage for a sketch.
I’m doing the extrusion, then removing the block instance and the instance reference.

Oke no problem. Does this help?

Dim crvList As New List(Of Geometry.Curve)
For Each obj As DocObjects.RhinoObject In doc.Objects.GetSelectedObjects(True, True)
     If obj.ObjectType = DocObjects.ObjectType.Curve Then
         Dim refObj As New DocObjects.ObjRef(obj.Id)
         crvList.Add(refObj.Curve)
     End If
Next

Dim vector As New Geometry.Vector3d(0, 0, -100)

For Each crv As Geometry.Curve In crvList
     Dim extrudeSrf As Surface = Geometry.Extrusion.CreateExtrusion(crv, vector)
     doc.Objects.AddSurface(extrudeSrf)
Next

doc.Views.Redraw()

Yes thanks