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

Find plotting parameters with vlax - how?

12 REPLIES 12
Reply
Message 1 of 13
george.drayton
990 Views, 12 Replies

Find plotting parameters with vlax - how?

Could someone please help with the names of the function to establish the plotting parameters using the (vlax-get-property <name> <parameter> ) method.  For example the plotting device name is obtainable by (vlax-get-property <objectname> 'Configname).  

 

What "words"/parameters do I use to find the plot orientation and paper size?

Thanks

George

12 REPLIES 12
Message 2 of 13
pbejse
in reply to: george.drayton


@Anonymous wrote:

Could someone please help with the names of the function to establish the plotting parameters using the (vlax-get-property <name> <parameter> ) method.  For example the plotting device name is obtainable by (vlax-get-property <objectname> 'Configname).  

 

What "words"/parameters do I use to find the plot orientation and paper size?

Thanks

George


Paper size

(vla-GetPaperSize (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))) 'h 'w)

 

h = height

w- width

 

 

 

 

Message 3 of 13
george.drayton
in reply to: pbejse

Thanks - I'll try it. what about orientation that shows in the plot dialog box. Is there no option to use vlax-put-property to assign to landscape and A3 ?
Message 4 of 13
Lee_Mac
in reply to: george.drayton


@Anonymous wrote:
What about orientation that shows in the plot dialog box. Is there no option to use vlax-put-property to assign to landscape and A3 ?

You would need to alter the plot settings using the ActiveX properties of the relevant Layout object or Plot Configuration object.

 

To understand what properties & methods are at your disposal for a given VLA-Object, you can either use the vlax-dump-object function (as demonstrated by this utility), or refer to the ActiveX documentation.

 

The following ActiveX properties of a VLA Layout Object are relevant to plotting:

 

CanonicalMediaName
CenterPlot
ConfigName
PaperUnits
PlotHidden
PlotOrigin
PlotRotation
PlotType
PlotViewportBorders
PlotViewportsFirst
PlotWithLineweights
PlotWithPlotStyles
ScaleLineweights
ShowPlotStyles
StyleSheet
ViewToPlot

 

Message 5 of 13
george.drayton
in reply to: Lee_Mac

Thanks - "CanonicalMediaName" was what I needed. I'll try to make it work with (vlax-put-property Activelayt 'CanonicalMediaName "A3")
Message 6 of 13
dgorsman
in reply to: george.drayton

Canonical media names aren't always so straightforward.  I'd recommend manually setting the page size first, then getting the property value and copying it to your code.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 7 of 13

Thank you for your help, but I cannot get the vla-getPaperSize to do anything.  I have run the following code

 

(vl-load-com)
(setq AcadObject (vlax-get-acad-object))
(setq AcadDocument (vlax-get-property AcadObject 'ActiveDocument))
(setq ActiveLayt (vlax-get-property AcadDocument 'ActiveLayout))
(setq ActivePlt (vlax-get-property ActiveLayt 'Configname)) 

 

This code produces output and shows me the active plotter so it seems to work in principle.

 

When I try (vla-GetPaperSize ActiveLayt 'h  'w) it just returns nil - is my syntax correct?  I cannot find information in the Help system regarding this function.

Is there a paramenter name whhich show landscape or portrait or do I have to use the height and width and do  (if h > w then mode=protrait) logic?

 

What I am REALLY trying to do is set the plotting orientation to Landscape (these words used in the plot dialog box) because I have a large number of layouts in many drawings where probably a new printer driver defaults to portrait mode.  I am trying to automate the change.  I am totally new to VBA but I have been able to master (with help) changing the printer name. Thanks once again.

Where do I find Help on the (vla-GetPaper..... series of functions?

Message 8 of 13
aqdam1978
in reply to: george.drayton

Hi,

 

This code gets paper size for all layouts:

 

(defun c:Demo ( / ps p)
  (vl-load-com)
  (foreach x (layoutlist)
    (cond 
	   ((not lay) (setq lay (vla-get-activelayout(vla-get-activedocument (vlax-get-acad-object)))))
    )
    (setq ps (vla-getpapersize lay 'w 'h))
    (setq p (cons (strcat x ": " (rtos w 2 1) "x" (rtos h 2 1)) p))
  );foreach
  (foreach lays	(reverse p)
    (print lays)(princ)
  );foreach
)

 

Abbas

Message 9 of 13
george.drayton
in reply to: aqdam1978

Thanks for your wonderful help. I now realise that the (getpapersize) function assigns the values for height and width as strings to the variables named in the program (W & H) in this case. This was not clear as I could not find the documentation for this function. Is there a (vla-setpapersize function to change the sizes?
Message 10 of 13
aqdam1978
in reply to: george.drayton


-------Methods------------------- CopyFrom Delete GetCanonicalMediaNames GetCustomScale GetExtensionDictionary GetLocaleMediaName GetPaperMargins GetPaperSize GetPlotDeviceNames GetPlotStyleTableNames GetWindowToPlot GetXData RefreshPlotDeviceInfo SetCustomScale SetWindowToPlot SetXData ------Properties-------------------- Application CanonicalMediaName CenterPlot ConfigName Document Handle HasExtensionDictionary ModelType Name ObjectID ObjectID32 ObjectName OwnerID OwnerID32 PaperUnits PlotHidden PlotOrigin PlotRotation PlotType PlotViewportBorders PlotViewportsFirst PlotWithLineweights PlotWithPlotStyles ScaleLineweights ShowPlotStyles StandardScale StyleSheet UseStandardScale ViewToPlot ------Events-------------------- Modified

 To set the paper size, use the "CanonicalMediaName" property.

 

Thanks,

Abbas

 

 

 

Message 11 of 13
george.drayton
in reply to: aqdam1978

How do I set the Landscape/Portrait property? or do I have to specifically set the width and height according? Thanks
Message 12 of 13
Lee_Mac
in reply to: george.drayton


george.drayton wrote:

When I try (vla-GetPaperSize ActiveLayt 'h  'w) it just returns nil - is my syntax correct?


Yes, although the first output parameter is the width and the second is the height, so you might want to reverse the symbols. The method will indeed return nil, with the results assigned to the symbols supplied as the output parameters.

 

Here is a quick console demonstration:

 

_$ (vla-getpapersize (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))) 'w 'h)
nil
_$ w
210.058
_$ h
296.884

george.drayton wrote:
I cannot find information in the Help system regarding this function.

There is no formal ActiveX reference for Visual LISP, but the ActiveX & VBA Reference can be found in the acadauto.chm compiled help file, and there is an online version available here (though, note that this is a Russian site and isn't published by Autodesk). The specific documentation for the getpapersize method can be found here.


george.drayton wrote:

Is there a paramenter name which show landscape or portrait or do I have to use the height and width and do  (if h > w then mode=protrait) logic?


Not as far as I know - you will need to test which of the width & height values is greatest and proceed accordingly.


george.drayton wrote:

What I am REALLY trying to do is set the plotting orientation to Landscape


For this you will need to alter the ActiveX plotrotation property of the plot configuration or layout.

Message 13 of 13
pbejse
in reply to: Lee_Mac


@Lee_Mac wrote:

george.drayton wrote:

When I try (vla-GetPaperSize ActiveLayt 'h  'w) it just returns nil - is my syntax correct?


Yes, although the first output parameter is the width and the second is the height, so you might want to reverse the symbols....

 


Ahhh, that would be my bad LM, [message 2] Smiley Very Happy

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

Post to forums  

Autodesk Design & Make Report

”Boost