Extrusion in an Assembly

Extrusion in an Assembly

mk92
Collaborator Collaborator
241 Views
0 Replies
Message 1 of 1

Extrusion in an Assembly

mk92
Collaborator
Collaborator

Hello,

 

i want to check the active sketch for closed profiles and if there is one or more do an extrusion.

I found some code here: Link and tried to make it work in an assembly.

 

But the result is (in a sketch with 3 closed profiles) the message that there is no closed profile. Any ideas?

 

This is what i got:

If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
'Do nothing
Else
MessageBox.Show("Activate a Sketch First then Run this Rule", "ilogic")
Return
End If

Dim oAssDoc As AssemblyDocument
oAssDoc = ThisApplication.ActiveDocument

Dim oSketch As PlanarSketch
oSketch = ThisApplication.ActiveEditObject 

' Create a profile.
Dim oProfile As Profile
On Error Goto NoProfile
oProfile = oSketch.Profiles.AddForSolid


Dim oExtrudeDef As ExtrudeDefinition
        
Dim ExtrudeDistance As Long
ExtrudeDistance = 20 mm
oDirection = kPositiveExtentDirection
oJoinOrCut = kJoinOperation

oExtrudeDef = oAssDoc.Features.ExtrudeFeatures.AddByDistanceExtent( _
oProfile, ExtrudeDistance, oDirection, oJoinOrCut)

ThisApplication.CommandManager.ControlDefinitions.Item("FinishSketch").Execute

iLogicVb.UpdateWhenDone = True

Exit Sub

NoProfile:
MessageBox.Show("No closed profile found", "iLogic")
Return

NoExtrude:
MessageBox.Show("No extrusion created, check your inputs.", "iLogic")
Return
0 Likes
242 Views
0 Replies
Replies (0)