Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am trying to create a lot of cylinders bodies in the same VBA code. I´ve found the sample code on AutoDesk site, but when I tried to create more than 1 solid body, it seems that create a surface body instead of solid. Does anyone have any idea about it? I´m attaching the VBA code and a picture of the output of my code.
Thanks so much!
Sub mymacro3()
' Create a new part document, using the default part template.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
' 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 the first 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 bottom and top points for the second cylinder.
Dim oBottomPt2 As Point
Set oBottomPt2 = ThisApplication.TransientGeometry.CreatePoint(0, 5 ,0)
Dim oTopPt2 As Point
Set oTopPt2 = ThisApplication.TransientGeometry.CreatePoint(0, 7, 0)
' Create the cylinder body.
Dim oCylinder As SurfaceBody
Set oCylinder = oTransientBRep.CreateSolidCylinderCone(oBottomPt, oTopPt, 0.5, 0.5, 0.5)
Dim oCylinder2 As SurfaceBody
Set oCylinder2 = oTransientBRep.CreateSolidCylinderCone(oBottomPt2, oTopPt2, 0.5, 0.5, 0.5)
' Create a base feature with the result body.
Dim oBaseFeature As NonParametricBaseFeature
Set oBaseFeature = oCompDef.Features.NonParametricBaseFeatures.Add(oBody)
Dim oBaseFeature2 As NonParametricBaseFeature
Set oBaseFeature2 = oCompDef.Features.NonParametricBaseFeatures.Add(oCylinder)
End Sub
Solved! Go to Solution.