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.
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
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