02-17-2020
06:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-17-2020
06:25 AM
OK. I opened your part, got an error, because it couldn't find the linked original version of the derived part, but I just skipped that. I used the Module1 of for that document to insert and modify your code untill I got it to work. Try this VBA code.
Sub CreateExtrudeFeat()
Dim oPDoc As PartDocument
Set oPDoc = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition
Set oPDef = oPDoc.ComponentDefinition
Dim oSketch As PlanarSketch
Set oSketch = oPDef.Sketches.Item(2)
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid
Dim oExtFeats As ExtrudeFeatures
Set oExtFeats = oPDef.Features.ExtrudeFeatures
Dim oExtDef As ExtrudeDefinition
Set oExtDef = oExtFeats.CreateExtrudeDefinition(oProfile, kCutOperation)
Call oExtDef.SetDistanceExtent("1000 mm", kNegativeExtentDirection)
Dim oExtFeat As ExtrudeFeature
Set oExtFeat = oExtFeats.Add(oExtDef)
If oPDef.HasMultipleSolidBodies = True Then
Call AddAffectedBodies(oPDef, oExtFeat)
End If
End Sub
Private Sub AddAffectedBodies(oPDef As PartComponentDefinition, oExtFeat As ExtrudeFeature)
Dim oBodies As ObjectCollection
For Each oBody In oPDef.SurfaceBodies
oBodies.Add (oBody)
Next
Call oExtFeat.SetAffectedBodies(oBodies)
End SubLet me know if this works for you.
Wesley Crihfield
(Not an Autodesk Employee)