AnsweredAssumed Answered

Macro to do a section view down to an Axis

Question asked by Matt Sullivan on Feb 21, 2019
Latest reply on Feb 26, 2019 by Fifi Riri

Hi Guys. Love the forum you're a lot of help. I started doing a few macros and I'm stuck on one that will help me save some time.


I created a macro that takes a part drawing, and opens up a 2D drawing template with predetermined views.

This all works great. I used this forum and the record macro feature combined.


Now I am stuck on this part.

I need a partial cross section of a specific view. I get there by displaying axis, draw box, select "broken out section" feature and click the axis.

The section view cuts down to the axis of a revolved part nicely.


I can't get the record feature to work because when the section happens, it isn't referencing the axis as a "stop cut" point, it is using the distance value of the specific part I'm recording.

I believe this part to be my issue in the code below.  "Part.CreateBreakOutSection 3.61338130073942E-03"


Hopefully that makes sense, I'm sure it does you're smart people.

Your help would be fantastic.



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


boolstatus = Part.SetUserPreferenceToggle(swUserPreferenceToggle_e.swDisplayAxes, True)

boolstatus = Part.SetUserPreferenceToggle(swUserPreferenceToggle_e.swDisplayTemporaryAxes, True)

boolstatus = Part.ActivateView("Drawing View8")

boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchAddConstToRectEntity, swUserPreferenceOption_e.swDetailingNoOptionSpecified, False)

boolstatus = Part.Extension.SetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchAddConstLineDiagonalType, swUserPreferenceOption_e.swDetailingNoOptionSpecified, True)

Dim vSkLines As Variant

vSkLines = Part.SketchManager.CreateCornerRectangle(0.021695343274111, 0, 0, -2.54349947452516E-02, 1.06324886917547E-02, 0)

boolstatus = Part.Extension.SelectByRay(0.142251506759536, 4.66699951634164E-02, 0, 0, 0, -1, 6.40012578196038E-04, 5, True, 0, 0)

Part.CreateBreakOutSection 3.61338130073942E-03

Part.ClearSelection2 True

boolstatus = Part.SetUserPreferenceToggle(swUserPreferenceToggle_e.swDisplayAxes, False)

boolstatus = Part.SetUserPreferenceToggle(swUserPreferenceToggle_e.swDisplayTemporaryAxes, False)


End Sub