AnsweredAssumed Answered

Name new projected drawing view anything

Question asked by Travis Forkner on Feb 2, 2021

Hi all,

I am trying to make a macro that will project a new view -- then rotate the view -- then add a note "back view" 

the problem is that the view that comes in can be somewhat random depending if someone before me added a lot of views then deleted them.

 

 

 

Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
boolstatus = Part.ActivateView("Drawing View3")
boolstatus = Part.Extension.SelectByID2("Drawing View3", "DRAWINGVIEW", 8.53561068370976E-02, 0.165508714701573, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Drawing View3", "DRAWINGVIEW", 8.53561068370976E-02, 0.165508714701573, 0, False, 0, Nothing, 0)
Dim myView As Object
Set myView = Part.CreateUnfoldedViewAt3(6.71812675910645E-02, 0.240406816797144, 0, False)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Drawing View3", "DRAWINGVIEW", 8.53561068370976E-02, 0.165508714701573, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.ActivateView("Drawing View8")
boolstatus = Part.Extension.SelectByID2("Drawing View8", "DRAWINGVIEW", 9.75488211317255E-02, 0.195467955539802, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Drawing View8", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.DrawingViewRotate(3.1415926535898)

Dim myNote As Object
Dim myAnnotation As Object
Dim myTextFormat As Object
Set myNote = Part.InsertNote("BACK VIEW")
If Not myNote Is Nothing Then
myNote.LockPosition = False
myNote.Angle = 0
boolstatus = myNote.SetBalloon(0, 0)
Set myAnnotation = myNote.GetAnnotation()
If Not myAnnotation Is Nothing Then
longstatus = myAnnotation.SetLeader3(swLeaderStyle_e.swNO_LEADER, 0, True, False, False, False)
boolstatus = myAnnotation.SetPosition(5.95772251855989E-02, 0.187107237166343, 0)
boolstatus = myAnnotation.SetTextFormat(0, True, myTextFormat)
End If
End If
Part.ClearSelection2 True
Part.WindowRedraw
End Sub

Outcomes