Inventor: Scale of a Drawing

by Vladimir Ananyev

Issue

How to view and change the scale of an IDW?

Solution

DrawingView object has Scale property. You may change its value to control view scale.

 

In C#

class cls_DrawingViewScale

{

  public static void DrawingViewScale()

  {

    try

    {

      Inventor.Application oApp =

        (Inventor.Application)System.

            Runtime.InteropServices.Marshal.

              GetActiveObject("Inventor.Application");

 

      DrawingDocument oDoc =

        oApp.ActiveDocument as DrawingDocument;

      DrawingView view = oDoc.ActiveSheet.DrawingViews[1];

 

      double dScale = view.Scale;

      System.Windows.Forms.MessageBox

          .Show("Current scale: " + dScale.ToString()); 

           

      view.Scale = 0.5; // change the scale

      System.Windows.Forms.MessageBox

          .Show("New scale: " + dScale.ToString());

    }

    catch

    {

       // some error

    }

  }

}

VB .NET

Sub DrawingViewScale()

  Try

    Dim oApp As Inventor.Application _

      = CType(System.Runtime.InteropServices.Marshal _

          .GetActiveObject("Inventor.Application"),  _

              Inventor.Application)

    Dim oDoc As DrawingDocument _

      = TryCast(oApp.ActiveDocument, DrawingDocument)

    Dim oView As DrawingView _

      = oDoc.ActiveSheet.DrawingViews.Item(1)

    MsgBox("Current scale: " & oView.Scale.ToString)

 

    oView.Scale = 0.5 ‘ change the scale

    MsgBox("New scale: " & oView.Scale.ToString)

  Catch ex As Exception

    MsgBox("ERROR")

  End Try

End Sub

In VBA

Sub DrawingViewScale()

    Dim oDoc As DrawingDocument

    Set oDoc = ThisApplication.ActiveDocument

   

    Dim oView As DrawingView

    Set oView = oDoc.ActiveSheet.DrawingViews.Item(1)

    MsgBox oView.Scale()

 

    oView.[Scale] = 0.5 ‘ change the scale

    MsgBox oView.Scale()

End Sub

<

p style=”line-height: normal;margin: 0cm 0cm 0pt” class=”MsoNormal”> 


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading