Inventor Customization

Inventor Customization

Reply
Active Contributor
fleece.design
Posts: 36
Registered: ‎07-21-2005
Message 1 of 3 (141 Views)
Accepted Solution

How to do boundarypatch on 3Dsketch circles in VBA?

141 Views, 2 Replies
09-21-2012 10:23 AM

Hi,

 

I want to select all circles in the design to patch them. How do I do this in VBA? Drawing the circles is no problem.

 

Kind regards,

Bart

 

ScreenShot004.png

Could you please test this sample code. It works for me.

Private Sub BoundaryPatch_SketchCircle3D()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
Set oDef = oDoc.ComponentDefinition
'reference to 3d sketch
Dim oSketch3d As Sketch3D
Set oSketch3d = oDef.Sketches3D.Item(1)
'create Boundary Patch Definition
Dim oBoundaryPatchDef As BoundaryPatchDefinition
Set oBoundaryPatchDef = oDef.Features _
.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
'Add all 3D circles to Boundary Patch Definition
'using Path object
Dim oCircle3d As SketchCircle3D
Dim oPath As Path
For Each oCircle3d In oSketch3d.SketchCircles3D
Set oPath = oDef.Features.CreatePath(oCircle3d)
Call oBoundaryPatchDef.BoundaryPatchLoops.Add(oPath)
Next
' Create the boundary patch feature based on the definition.
Dim oBoundaryPatch As BoundaryPatchFeature
Set oBoundaryPatch = oDef.Features _
.BoundaryPatchFeatures.Add(oBoundaryPatchDef)
End Sub

 Cheers,

ADN Support Specialist
Vladimir.Ananyev
Posts: 491
Registered: ‎08-14-2012
Message 2 of 3 (128 Views)

Re: How to do boundarypatch on 3Dsketch circles in VBA?

09-25-2012 05:00 AM in reply to: fleece.design

Could you please test this sample code. It works for me.

Private Sub BoundaryPatch_SketchCircle3D()

  Dim oDoc As PartDocument
  Set oDoc = ThisApplication.ActiveDocument
  Dim oDef As PartComponentDefinition
  Set oDef = oDoc.ComponentDefinition
  
  'reference to 3d sketch
  Dim oSketch3d As Sketch3D
  Set oSketch3d = oDef.Sketches3D.Item(1)

  'create Boundary Patch Definition
  Dim oBoundaryPatchDef As BoundaryPatchDefinition
  Set oBoundaryPatchDef = oDef.Features _
        .BoundaryPatchFeatures.CreateBoundaryPatchDefinition
  
  'Add all 3D circles to Boundary Patch Definition
  'using Path object
  Dim oCircle3d As SketchCircle3D
  Dim oPath As Path
  For Each oCircle3d In oSketch3d.SketchCircles3D
    Set oPath = oDef.Features.CreatePath(oCircle3d)
    Call oBoundaryPatchDef.BoundaryPatchLoops.Add(oPath)
  Next

  ' Create the boundary patch feature based on the definition.
  Dim oBoundaryPatch As BoundaryPatchFeature
  Set oBoundaryPatch = oDef.Features _
        .BoundaryPatchFeatures.Add(oBoundaryPatchDef)
  
End Sub

 Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Active Contributor
fleece.design
Posts: 36
Registered: ‎07-21-2005
Message 3 of 3 (121 Views)

Re: How to do boundarypatch on 3Dsketch circles in VBA?

09-25-2012 06:03 AM in reply to: Vladimir.Ananyev

Thanks a lot! That works perfectly the way I wanted!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.