Jump to content

Find the scale of a Viewport - VBA


neophyte

Recommended Posts

Hi

 

How can I found the scale of a viewport on my drawing.

 

I want to write this informations in my cartouche

 

I have only one tab (layout1) I could have more than one viewport, they should be all the same scale

 

ex:

If the result of

Scale relative to Paper space= 0.0208xp

Then I'm going to write 1/4"=1'-0"

 

Thanks for your help

Link to comment
Share on other sites

Hi

The next time I'm going to do a better search

The answer was just under my eyes:oops:

http://www.cadtutor.net/forum/showthread.php?t=29175

 

This is was I extract from this link

Sub PVPortScale()
Dim strVpScaleStd As String
Dim strVpScaleCust As String
Dim Entity As AcadEntity
Dim PVport As AcadPViewport
Dim objLayout As AcadLayout
Dim i As Integer
  For Each objLayout In ThisDrawing.Layouts

     If objLayout.Name <> "Model" Then
        ThisDrawing.ActiveLayout = objLayout
       ThisDrawing.MSpace = False
        For i = 1 To objLayout.Block.Count - 1 'avoid primary Paperspace PViewport
           Set Entity = objLayout.Block.Item(i)
           If TypeOf Entity Is AcadPViewport Then
              Set PVport = Entity
              strVpScaleStd = PVport.StandardScale
              strVpScaleCust = PVport.CustomScale
              If strVpScaleCust > 0 Then
              Exit For
              End If
           End If
        Next
       End If
  Next
End Sub

 

Now I have to find out how compare my result with a list. The list contains the correspondence of results

ex. if strVpScaleStd = 30 the scale I have to write is 3/32"=1'0"

 

Have good day!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...