Hello, I'm writing a custom plot lisp for printing various drawings on our network. Due to certain circumstances, I have to assign various window points to plot the drawing correctly. I've got everything working well, but I'd like to keep this as one program instead of having 2 different lisps for portrait and landscape drawings. I am wondering what vla or vlax command returns the drawing orientation? This way I can have just one program. If the drawing is portrait, I set specific window coordinates at certain points. If the drawing is landscape, then I set the window points differently. Any help would be greatly appreciated.
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
If you don't have things drawn outside the area you want to plot [whether in Model or Paper space], you can use the EXTMIN and EXTMAX System Variables. They contain the XYZ coordinates of the EXTents of the current space, the MIN being the lower left corner and the MAX the upper right corner. So, for example:
(setq
LL (getvar 'extmin)
UR (getvar 'extmax)
); setq
(if (> (- (car UR) (car LL)) (- (cadr UR) (cadr LL)))
(... then -- it's wider than it is tall; use landscape-orientation settings ...)
(... else -- it's taller than it is wide; use portrait-orientation settings ...)
); if
However, there's a caveat: If you had extraneous stuff outside the plotting area, and you erase it in order to plot by this method, you need to do a Zoom All or Zoom Extents first. These two System Variables "swell" outward whenever things are added that enlarge the extents, but they don't "shrink" back inward when things are removed that reduce the extents until the next Zoom All/Extents.
If you have a title-block/border element as a Block or Xref, which you can identify by name or something, you could get its bounding box and run the same kind of test. Or maybe you could decide based on its name.
I don't know if this is correct but it's what I've been playing around with:
(setq ActLay (vla-get-Activelayout (vla-get-ActiveDocument (vlax-get-acad-object)))) (setq PlotOrient (vlax-get-property ActLay 'PlotType))
If PlotOrient = 1 then it's landscape, if = 2 then portrait.
It seems to get the correct orientation so far, I've tried it out on about 20 different drawings. Ranging from drawings that are 6 years old to ones that were created a couple of days ago, and it seems to produce the correct results. I don't know if this is the correct way to go about this though.
'plottype?
I thought plotrotation?
(if (= (vla-get-plotrotation
(vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))
)
0) (princ "Portrait") (princ "Landscape") );if
EDIT:
Neither variable looks like it directly reports the orientation of layout page setup.. Let me look some more.
PlotRotation
acPlotRotation enum; read-write
ac0degrees
ac90degrees
ac180degrees
ac270degrees
PlotType
acPlotType enum; read-write
acDisplay
acExtents
acLimits
acView
acWindow
acLayout
hmmm... the rotation changes from 0 to 1 when I change an 8.5x11 sheet from portrait to Landscape (or vice-versa). This does not work for me..does it work for you?
(setq l1 (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))) (vla-getpapersize l1 'width 'height) (if (< width height) (princ "Portrait") (princ "Landscape") );if
Another possibility:
(setq orientation (vla-get-plotrotation (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))) )
(cond
((= orientation ac0degrees) (princ "\nPortrait") )
((= orientation ac90degrees) (princ "\nLandscape") )
((= orientation ac180degrees) (princ "\nPortrait / Plot upside down") )
((= orientation ac270degrees) (princ "\nLandscape/ Plot upside down") )
(T (princ "\nUnknown Orientation")) ; another possibility is not allowed
)