Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Drawing Orientation

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
cncah
1603 Views, 9 Replies

Get Drawing Orientation

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.

9 REPLIES 9
Message 2 of 10
~Opie
in reply to: cncah

I do you manually determine the orientation? Is it based on the layout? Or Page Setup? Or the extents? Or previously picked points?
Message 3 of 10
Kent1Cooper
in reply to: cncah

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.

Kent Cooper, AIA
Message 4 of 10
cncah
in reply to: Kent1Cooper

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.

Message 5 of 10
Shneuph
in reply to: cncah

'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

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 6 of 10
cncah
in reply to: Shneuph

Plot rotation is zero for both types.

Message 7 of 10
Shneuph
in reply to: cncah

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

 

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 8 of 10
cncah
in reply to: Shneuph

No it's returning portrait in both types of drawings.

Message 9 of 10
cncah
in reply to: Kent1Cooper

I think this method will work fine. Thanks Kent!

Message 10 of 10
vbreuckTuc
in reply to: cncah

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 
   )

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost