DrawingView.MoveTo Method

DrawingView.MoveTo Method

jdkriek
Advisor Advisor
731 Views
3 Replies
Message 1 of 4

DrawingView.MoveTo Method

jdkriek
Advisor
Advisor

What is the proper way to use this method? Not having any luck.

 

Also tried using oDoc.Sheets.Item(2) for Target Sheet.

 

Public Sub MoveViews()
    Dim oApp As Application
    Set oApp = ThisApplication
    Dim oDoc As DrawingDocument
    Set oDoc = oApp.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet
    
    ' Check to make sure a view was selected.
    If Not TypeOf oDoc.SelectSet.Item(1) Is DrawingView Then
        MsgBox "A drawing view must be selected."
        Exit Sub
    End If
    
    Dim oDrawingView As DrawingView
    Set oDrawingView = oDoc.SelectSet.Item(1)
    
    ' Test to see if we have the view
    oDrawingView.ShowLabel = True
    
    ' Move view to target sheet
    oDrawingView.MoveTo ("Sheet:2")
End Sub
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Accepted solutions (1)
732 Views
3 Replies
Replies (3)
Message 2 of 4

YuhanZhang
Autodesk
Autodesk

Can you double check that the active sheet is Sheet:2 or not? You could not move a drawing view to the same sheet it is located in.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 4

jdkriek
Advisor
Advisor

Rocky,

 

Yes Sheet:1 is active and I cannot move it to Sheet:2

 

Also the view is stand-alone, not a section or view with parent.

 

Tested in 2011, 2012, and 2013

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 4 of 4

YuhanZhang
Autodesk
Autodesk
Accepted solution

Seems there is a code error, please use below updated code:

 

Public Sub MoveViews()
    Dim oApp As Application
    Set oApp = ThisApplication
    Dim oDoc As DrawingDocument
    Set oDoc = oApp.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet
    
    ' Check to make sure a view was selected.
    If Not TypeOf oDoc.SelectSet.Item(1) Is DrawingView Then
        MsgBox "A drawing view must be selected."
        Exit Sub
    End If
    
    Dim oDrawingView As DrawingView
    Set oDrawingView = oDoc.SelectSet.Item(1)
    
    ' Test to see if we have the view
    oDrawingView.ShowLabel = True
    
    ' Move view to target sheet
    oDrawingView.MoveTo oDoc.Sheets("Sheet:2")
End Sub

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.