TransientBRep - Options for converting surface to solid

TransientBRep - Options for converting surface to solid

LukeDavenport
Collaborator Collaborator
611 Views
6 Replies
Message 1 of 7

TransientBRep - Options for converting surface to solid

LukeDavenport
Collaborator
Collaborator

 

Hi All,

There are lots of simple examples for creating ruled surfaces etc using the TransientBRep, but I can't find any options for converting these to Solid SurfaceBodies once created. I'm thinking of the API (transient) equivalent of the UI sculpt command (which allows you to create a solid from the enclosed area of workplanes, surfaces etc).

 

The help file shows how to create a transient 'Block' body using vertices, edgeloopdefinitions etc, but this is a bit too long-winded for me.

 

My ideal scenario would be to create a transient ruled surface, and then 'cap' this off with a couple of planes, and then convert this to a transient SurfaceBody. Is something like this possible?

 

Any comments gratefully received.

Luke

0 Likes
612 Views
6 Replies
Replies (6)
Message 2 of 7

LukeDavenport
Collaborator
Collaborator

No TransientBRep gurus out there? I will probably have to bite the bullet with creating a transient block the long way round. Happy days 🙂

0 Likes
Message 3 of 7

tiago.pereiraGB2J9
Enthusiast
Enthusiast

@LukeDavenport have you reach some answer?  I have the same problem, trying to crate a cylinder with VBA in Inventor. 

0 Likes
Message 4 of 7

LukeDavenport
Collaborator
Collaborator

Hi, you can just use the TransientBRep.CreateSolidCylinderCone method for that. Below is the sample from the API help. Luke

Public Sub ClientGraphics3DPrimitives()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument

    ' Set a reference to component definition of the active document.
    ' This assumes that a part or assembly document is active.
    Dim oCompDef As ComponentDefinition
    Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition

    ' Check to see if the test graphics data object already exists.
    ' If it does clean up by removing all associated of the client graphics
    ' from the document. If it doesn't create it.
    On Error Resume Next
    Dim oClientGraphics As ClientGraphics
    Set oClientGraphics = oCompDef.ClientGraphicsCollection.Item("Sample3DGraphicsID")
    If Err.Number = 0 Then
        On Error GoTo 0
        ' An existing client graphics object was successfully obtained so clean up.
        oClientGraphics.Delete

        ' update the display to see the results.
        ThisApplication.ActiveView.Update
    Else
        Err.Clear
        On Error GoTo 0

        ' Set a reference to the transient geometry object for user later.
        Dim oTransGeom As TransientGeometry
        Set oTransGeom = ThisApplication.TransientGeometry

        ' Create the ClientGraphics object.
        Set oClientGraphics = oCompDef.ClientGraphicsCollection.Add("Sample3DGraphicsID")

        ' Create a new graphics node within the client graphics objects.
        Dim oSurfacesNode As GraphicsNode
        Set oSurfacesNode = oClientGraphics.AddNode(1)

        Dim oTransientBRep As TransientBRep
        Set oTransientBRep = ThisApplication.TransientBRep

        ' Create a point representing the center of the bottom of the cone
        Dim oBottom As Point
        Set oBottom = ThisApplication.TransientGeometry.CreatePoint(0, 0, 0)

        ' Create a point representing the tip of the cone
        Dim oTop As Point
        Set oTop = ThisApplication.TransientGeometry.CreatePoint(0, 10, 0)

        ' Create a transient cone body
        Dim oBody As SurfaceBody
        Set oBody = oTransientBRep.CreateSolidCylinderCone(oBottom, oTop, 5, 5, 0)

        ' Reset the top point indicating the center of the top of the cylinder
        Set oTop = ThisApplication.TransientGeometry.CreatePoint(0, -40, 0)

        ' Create a transient cylinder body
        Dim oCylBody As SurfaceBody
        Set oCylBody = oTransientBRep.CreateSolidCylinderCone(oBottom, oTop, 2.5, 2.5, 2.5)

        ' Union the cone and cylinder bodies
        Call oTransientBRep.DoBoolean(oBody, oCylBody, kBooleanTypeUnion)

        ' Create client graphics based on the transient body
        Dim oSurfaceGraphics As SurfaceGraphics
        Set oSurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oBody)

        ' Update the view to see the resulting curves.
        ThisApplication.ActiveView.Update
    End If
End Sub

  

0 Likes
Message 5 of 7

tiago.pereiraGB2J9
Enthusiast
Enthusiast

@LukeDavenport ,

 

Thanks so much for your answer!

I´ve found this sample code before on Autodesk site, but it seems it creates a surface object, I don't know.
When I ran this macro, it appear only the cylinder, but it´s not a solid object. Iám attaching some prints of the screen, so maybe you know how to help me. 

 

Attachments:

 

  • cylinder.png-> The output of the vba code that you send me
  • Objectif.png -> The objectif is to create one vba code that can build one structure like this, only replicating the "cylinder" code. 

Thanks for your attention!

0 Likes
Message 6 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

The sample above only creates a client graphic which is transient and not shown in model browser. You need to create a solid as NonParametricBaseFeature. Below a modified sample from API help.

I'm not sure this way is the right one. Will all these pieces exist in one part document as multi body? Isn't it a job for frame generator?

 

Public Sub CreateBRep()
    ' Create a new part document, using the default part template.
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.ActiveDocument

    ' Set a reference to the component definition.
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition

    ' Set a reference to the TransientBRep object.
    Dim oTransientBRep As TransientBRep
    Set oTransientBRep = ThisApplication.TransientBRep
    
    ' Create bottom and top points for a cylinder.
    Dim oBottomPt As Point
    Set oBottomPt = ThisApplication.TransientGeometry.CreatePoint(0, 1, 0)
    
    Dim oTopPt As Point
    Set oTopPt = ThisApplication.TransientGeometry.CreatePoint(0, 3, 0)
    
    ' Create the cylinder body.
    Dim oCylinder As SurfaceBody
    Set oCylinder = oTransientBRep.CreateSolidCylinderCone(oBottomPt, oTopPt, 0.5, 0.5, 0.5)
    
    ' Create a base feature with the result body.
    Dim oBaseFeature As NonParametricBaseFeature
    Set oBaseFeature = oCompDef.Features.NonParametricBaseFeatures.Add(oCylinder)
End Sub

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 7 of 7

tiago.pereiraGB2J9
Enthusiast
Enthusiast

Thanks so much for your answer @Ralf_Krieg!

 

I agree about the frame generator, it´s exaclty what i´m looking for. I still have one question:

 

  • I´m trying to build a hole offshore plataform, so it´s a big model. Can I automate the frame generator with VBA or iLogic? So I can build the hole plataform with only one command. 

Thank you again!

 

 

0 Likes