AnsweredAssumed Answered

How to Dissolve Feature in a Macro

Question asked by Patrick Malone on Jul 17, 2019

SW Professional 2018.

I want to create a macro that will Dissolve Feature then save it then close it.

The Record Macro did not capture those few steps.

 

Not sure how to proceed.

 

Please advise

 

=

 

This is what was recorded:

 

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
boolstatus = Part.Extension.SelectByID2("xaaaaa.SLDPRT", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("xaaaaa.stp", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.ForceRebuild3(True)
Part.ClearSelection2 True

' Save As
longstatus = Part.SaveAs3("C:\Users\x1234\Desktop\SW Models\xaaaaa.SLDPRT", 0, 2)

' Close Document
Set swPart = Nothing
Set Part = Nothing
swApp.CloseDoc "xaaaaa.SLDPRT"
End Sub

 

 

I just wanted to save the file (.stp) with it's current file name to the current directory after dissolving the feature.

Outcomes