×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Rotate Drawing Using VBA

Rotate Drawing Using VBA

Rotate Drawing Using VBA

(OP)
I am trying to determine if a drawing is longer Vertically than it is Horizontally. If it is I want to rotate the drawing by 90 degrees.

Does anyone have any idea how to check the max dimensions using VBA and then how to rotate the drawing?

I used to do this in Lisp using the following

(setq mx (getvar "extmax"))
(setq mn (getvar "extmin"))
(setq width (- (nth 0 mx) (nth 0 mn)))
(setq height (- (nth 1 mx) (nth 1 mn)))
(if (> height width)
    (command "rotate" "all" "" "0,0" "90")
)
(command "Zoom" "E")

I would like to do the exact same thing. Barring that I would like to just run this chunk of LISP code from VBA if that is possible.

RE: Rotate Drawing Using VBA

This little thing should work. Be careful ..no error checking and the selection set name is not cleared before created...

Sub RotateTallDwg()
'------------------------------------------------------------------------------
'RotateTallDwg:
'
'
'------------------------------------------------------------------------------
Dim vMX As Variant
Dim vMN As Variant
Dim acSS As AcadSelectionSet
Dim acItem As AcadObject
Dim dPt(0 To 2) As Double
'''''''''''''''''''''''''''''''''''''''
vMX = ThisDrawing.GetVariable("EXTMAX")
vMN = ThisDrawing.GetVariable("EXTMIN")
If (vMX(0) - vMN(0)) < (vMX(1) - vMN(1)) Then
    Set acSS = ThisDrawing.SelectionSets.Add("DWG")
    acSS.Select 1, vMN, vMX
    dPt(0) = 0: dPt(1) = 0: dPt(2) = 0
    For Each acItem In acSS
        acItem.Rotate dPt, ((Atn(1) * 4) / 2)
    Next acItem
End If
End Sub

"Everybody is ignorant, only on different subjects." — Will Rogers

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources