Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rotate Drawing Using VBA

Status
Not open for further replies.

LumpoDelMagnifico

Electrical
Sep 22, 2004
35
0
0
US
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.
 
Replies continue below

Recommended for you

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
 
Status
Not open for further replies.
Back
Top