I'm trying to write a macro that will allow me to select an extrude and a body to extrude it to within an assembly. My application for this is defining lengths of pipes between joints. Here are some screenshots to explain further:
Here is my default pipe.
Its boss extrude is set to blind and 10" long.
I change it to up to body and select the opposite joint to define the pipe length. I select "This configuration" so that I may have different lengths in my assembly.
This works, but there's several clicks that can be saved if it were made into a macro.
This is what I have so far. I make two selections. First, I select the pipe. Then, I select the joint and run my macro.
This is what happens after running my macro.
If I roll the boss extrude forward and edit it, it's changed correctly, but it has failed to update into my assembly. Plus, I'd like the macro to only modify "This configuration".
Here is my macro thus far:
Dim swApp As SldWorks.SldWorks
Dim Model As ModelDoc2
Dim PipeSelection As Object
Dim PipeFeature As Feature
Dim PipeDefinition As ExtrudeFeatureData2
Dim JointSelection As Object
Dim JointBody As Object
Dim isGood As Boolean
Dim SelMgr As SelectionMgr
Set swApp = CreateObject("sldWorks.application")
Set Model = swApp.ActiveDoc
Set SelMgr = Model.SelectionManager
Set PipeSelection = SelMgr.GetSelectedObject6(1, -1)
Set PipeFeature = PipeSelection.GetFeature
Set JointSelection = SelMgr.GetSelectedObject6(2, -1)
Set JointBody = JointSelection.GetBody
Set PipeDefinition = PipeFeature.GetDefinition
isGood = PipeDefinition.AccessSelections(Model, Nothing)
PipeDefinition.SetEndCondition True, 7
PipeDefinition.SetEndConditionReference True, JointBody
isGood = PipeFeature.ModifyDefinition(PipeDefinition, Model, Nothing)
I couldn't find any solutions within the documentation, but hopefully someone knows how to remedy this issue.