Transient B-Rep allows you to define B-Rep data from scratch and one of the enhancements to the Inventor 2013 API allows you to define a new wire body. In the previous release you could only build surfaces and solids. One reason to create a wire body is for input to other modeling operations.
New 2013 object, properties and method used to create a wire body ruled surface:
- WireDefinition Object
- FaceShellDefinition.WireDefinitions Property
- WireDefinition.WireEdgeDefinitions Property
- TransientBRep.CreateRuledSurface Method
VBA Example:
Please keep in mind that we only recommend using VBA for prototyping and learning the API but do not recommend using VBA in production).
This example shows how to use this new functionality to create a ruled surface. After running this procedure a NonParametricBaseFeature will be added to the part file.
VBA Code:
' Demonstrate creating a transient ruled surface.
' This sample uses all straight line segments
' for each of the sections.
' A part document must be open.
Public Sub RuledSurf()
' Get the transient B-Rep and Geometry objects.
Dim tBRep As TransientBRep
Set tBRep = ThisApplication.TransientBRep
Dim tg As TransientGeometry
Set tg = ThisApplication.TransientGeometry
' Create a new surface body definition.
Dim bodyDef As SurfaceBodyDefinition
Set bodyDef = tBRep.CreateSurfaceBodyDefinition
' Add a lump, shell, and wire.
Dim lumpDef As LumpDefinition
Set lumpDef = bodyDef.LumpDefinitions.Add
Dim shellDef As FaceShellDefinition
Set shellDef = lumpDef.FaceShellDefinitions.Add
Dim wireDef As WireDefinition
Set wireDef = shellDef.WireDefinitions.Add
' Create coordinate points and use those
' to create vertex definitions.
Dim pnts(2) As Point
Set pnts(0) = tg.CreatePoint(0, 0, 0)
Set pnts(1) = tg.CreatePoint(10, 3, 0)
Set pnts(2) = tg.CreatePoint(20, 0, 0)
Dim vertexDefs(2) As VertexDefinition
Set vertexDefs(0) = _
bodyDef.VertexDefinitions.Add(pnts(0))
Set vertexDefs(1) = _
bodyDef.VertexDefinitions.Add(pnts(1))
Set vertexDefs(2) = _
bodyDef.VertexDefinitions.Add(pnts(2))
' Create two wire edges, passing through the
' three vertices.
Call wireDef.WireEdgeDefinitions.Add _
(vertexDefs(0), vertexDefs(1), _
tg.CreateLineSegment(pnts(0), pnts(1)))
Call wireDef.WireEdgeDefinitions.Add _
(vertexDefs(1), vertexDefs(2), _
tg.CreateLineSegment(pnts(1), pnts(2)))
' Create a second wire definition.
Dim wireDef2 As WireDefinition
Set wireDef2 = shellDef.WireDefinitions.Add
' Create coordinate points and use those to
' create vertex definitions.
Set pnts(0) = tg.CreatePoint(-5, 0, 10)
Set pnts(1) = tg.CreatePoint(10, 6, 10)
Set pnts(2) = tg.CreatePoint(25, 0, 10)
Set vertexDefs(0) = _
bodyDef.VertexDefinitions.Add(pnts(0))
Set vertexDefs(1) = _
bodyDef.VertexDefinitions.Add(pnts(1))
Set vertexDefs(2) = _
bodyDef.VertexDefinitions.Add(pnts(2))
' Create two edges, passing through the
' three vertices.
Call wireDef2.WireEdgeDefinitions.Add _
(vertexDefs(0), vertexDefs(1), _
tg.CreateLineSegment(pnts(0), pnts(1)))
Call wireDef2.WireEdgeDefinitions.Add _
(vertexDefs(1), vertexDefs(2), _
tg.CreateLineSegment(pnts(1), pnts(2)))
' Create a body using the defined wires.
Dim errors As NameValueMap
Set errors = ThisApplication.TransientObjects. _
CreateNameValueMap
Dim body1 As SurfaceBody
Set body1 = bodyDef. _
CreateTransientSurfaceBody(errors)
' Create a ruled surface between the two
' wire bodies.
Dim ruled As SurfaceBody
Set ruled = tBRep.CreateRuledSurface _
(body1.Wires.Item(1), body1.Wires.Item(2))
' Get the part component definition of the
' active document.
Dim partDoc As PartDocument
Set partDoc = ThisApplication.ActiveDocument
Dim partDef As PartComponentDefinition
Set partDef = partDoc.ComponentDefinition
' Create a base body feature of the
' transient body.
Dim baseBody As NonParametricBaseFeature
Set baseBody = _
partDef.Features. _
NonParametricBaseFeatures.Add(ruled)
' Change the result work surface so
' it's not translucent.
baseBody.SurfaceBodies.Item(1). _
Parent.Translucent = False
ThisApplication.ActiveView.Fit
End Sub
-Wayne


Subscribe