Using ActiveX/LISP to get/set plot configuration

Using ActiveX/LISP to get/set plot configuration

Anonymous
Not applicable
2,609 Views
22 Replies
Message 1 of 23

Using ActiveX/LISP to get/set plot configuration

Anonymous
Not applicable
Hello ActiveX gurus,

Kind of a tall order this time.

Using ActiveX/LISP, how would I go about getting/setting plot properties? I
figure it's probably something like:
(vla-get-property some_object "PlotHidden") and
(vla-put-property some_object "PlotHidden" vlax:true) or something.

I guess the real questions are what object(s) do I use to get/set the
following plot properties, and how do I get these objects?

1. layout name
2. output device name
3. paper size
4. paper units
5. drawing orientation
6. Plot upside down
7. plot area
8. plot scale
9. plot offset
10. Plot with plot styles
11. plot style table name
12. Plot with lineweights
13. Remove hidden lines
14. Write the plot to a file
15. Save changes to model tab

--
Thank you much once again,
Eric S. eschneider@jensenprecast.com
0 Likes
2,610 Views
22 Replies
Replies (22)
Message 2 of 23

Anonymous
Not applicable
BTW: A2ki/W2k.

I'm writing a plot routine to run from a reactor.
--
Eric S. eschneider@jensenprecast.com
0 Likes
Message 3 of 23

Anonymous
Not applicable
No ActiveX guru, but the "some-object" you seek
is approximately "PlotConfiguration" object.
ActiveX help out of the VLIDE ought to get you
started.

On Tue, 29 Aug 2000 20:08:00 +0000, "Eric Schneider"
wrote:

>Hello ActiveX gurus,
>
>Kind of a tall order this time.
>
>Using ActiveX/LISP, how would I go about getting/setting plot properties? I
>figure it's probably something like:
>(vla-get-property some_object "PlotHidden") and
>(vla-put-property some_object "PlotHidden" vlax:true) or something.
>
>I guess the real questions are what object(s) do I use to get/set the
>following plot properties, and how do I get these objects?
>
>1. layout name
>2. output device name
>3. paper size
>4. paper units
>5. drawing orientation
>6. Plot upside down
>7. plot area
>8. plot scale
>9. plot offset
>10. Plot with plot styles
>11. plot style table name
>12. Plot with lineweights
>13. Remove hidden lines
>14. Write the plot to a file
>15. Save changes to model tab
>
>--
>Thank you much once again,
>Eric S. eschneider@jensenprecast.com
>
0 Likes
Message 4 of 23

Anonymous
Not applicable
Eric,
here's some snippets that might get you on the track:

>>1
(setq layoutname (vla-get-name (vla-get-ActiveLayout (vla-get-activedocument (vlax-get-acad-object )))))

(setq AD (vla-get-activedocument (vlax-get-acad-object )))
(setq AL (vla-get-ActiveLayout AD))

>>2
(defun get-DefaultPrinter(/ dev pos)
(setq dev "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
dev (vl-registry-read dev "Device")
dev (substr dev 1 (vl-string-search "," dev)))
)

(defun GetPlotDevices (ad)
(vla-RefreshPlotDeviceInfo
(vla-get-activelayout
ad))
(vlax-safearray->list
(vlax-variant-value
(vla-getplotdevicenames
(vla-item (vla-get-layouts ad) "Model"))))
)

; Plot Device in active Layout
(defun GetActivePlotDevice (ad)
(vla-get-ConfigName
(vla-get-ActiveLayout
ad))
)

>>3
(defun GetCanonicalMediaNames (ad)
(vla-RefreshPlotDeviceInfo
(vla-get-activelayout
ad))
(vlax-safearray->list
(vlax-variant-value
(vla-GetCanonicalMediaNames
(vla-item (vla-get-layouts ad) "Model"))))
)

(defun GetLocaleMediaName (ad / mn mnl)
(setq la (vla-item (vla-get-layouts ad) "Model"))
(foreach mn (GetCanonicalMediaNames)
(setq mnl (cons (vla-GetLocaleMediaName la mn) mnl))
)
(reverse mnl)
)

(defun ListAllMediaNames(ad / al cn pd apmn)
(setq al (vla-get-activelayout ad))
(setq cn (vla-get-configname al))
(foreach pd (GetPlotDevices)
(if (/= pd "None")
(progn
(vla-put-configname al pd)
(setq apmn (cons pd apmn))
(setq apmn (cons (GetCanonicalMediaNames) apmn))
)
)
)
(if (/= cn "None") (vla-put-configname al cn))
(reverse apmn)
)

(defun ListAllLocalMediaNames(ad / al cn pd apmn)
(setq al (vla-get-activelayout ad))
(setq cn (vla-get-configname al))
(foreach pd (GetPlotDevices)
(if (/= pd "None")
(progn
(vla-put-configname al pd)
(setq apmn (cons pd apmn))
(setq apmn (cons (GetLocaleMediaName) apmn))
)
)
)
(if (/= cn "None") (vla-put-configname al cn))
(reverse apmn)
)

>>4
(vla-get-PaperUnits al)

(vla-put-PaperUnits al acInches)
(vla-put-PaperUnits al acMillimeters)

>>5
(vla-get-PlotRotation al)

;;; alt. (ac0degrees ac90degrees ac180degrees ac270degrees)
(vla-put-PlotRotation al ac0degrees)

>>8
(setq PlotScale (vla-SetCustomScale AL 1 2 )) ; set scale to 1:2
(setq PlotScale (vla-put-StandardScale AL acVpScaleToFit))
(setq PlotScale (vla-put-StandardScale AL acVpScaleToFit))
(setq PlotScale (vla-put-StandardScale AL 0.5))
(setq PlotType (vla-put-PlotType AL acExtents))

(setq PlotCenter (vla-put-CenterPlot AL :vlax-true))

>>10
(vla-get-PlotWithPlotStyles AL)
(vla-set-PlotWithPlotStyles AL :vlax-true)

>>13
(vla-get-PlotHidden AL)
(vla-set-PlotHidden AL :vlax-false)

>>14
(vla-PlotToDevice
(vla-get-plot ad))

(vla-PlotToFile
(vla-get-plot ad)
(vl-filename-base (getvar "dwgname"))
)

; works with (vla-PlotToDevice ... )
(defun putPlotCopies (nr ad)
(vl-load-com)
(vla-put-NumberOfCopies
(vla-get-Plot
ad
)
nr
)
)

(defun getPlotCopies (ad)
(vla-get-NumberOfCopies
(vla-get-Plot
ad
)
)
)

--
Best regards: Jimmy B
CAD coordinator at Emtunga International AB
http://hem.fyristorg.com/cadman/
www.emtunga.com
0 Likes
Message 5 of 23

Anonymous
Not applicable
For everything I try though, I can't get the PlotConfiguration object. I can
get the PlotConfigurations object, but that one doesn't have all the item I
need to access, though it does have some.

Still befuddled.
--
Eric S. eschneider@jensenprecast.com

Command: (vlax-dump-object doc)
; IAcadDocument: AutoCAD Document Interface
; Property values:
; Active (RO) = -1
; ActiveDimStyle = #
; ActiveLayer = #
; ActiveLayout = #
; ActiveLinetype = #
; ActivePViewport = AutoCAD: No active viewport in paperspace
; ActiveSelectionSet (RO) = #
; ActiveSpace = 1
; ActiveTextStyle = #
; ActiveUCS = #
; ActiveViewport = #
; Application (RO) = #
; Blocks (RO) = #
; Database (RO) = #
; Dictionaries (RO) = #
; DimStyles (RO) = #
; ElevationModelSpace = 0.0
; ElevationPaperSpace = 0.0
; FullName (RO) = "S:\\JOBS\\0004\\0004-023-C UVA
StormVault\\004-023-C-1.dwg"
; Groups (RO) = #
; Height = 599
; HWND (RO) = 983650
; Layers (RO) = #
; Layouts (RO) = #
; Limits = (0.0 0.0 204.0 264.0)
; Linetypes (RO) = #
; ModelSpace (RO) = #
; MSpace = AutoCAD: Invalid mode
; Name (RO) = "004-023-C-1.dwg"
; ObjectSnapMode = 0
; PaperSpace (RO) = #
; Path (RO) = "S:\\JOBS\\0004\\0004-023-C UVA StormVault"
; PickfirstSelectionSet (RO) = #
; Plot (RO) = #
; PlotConfigurations (RO) = #
; Preferences (RO) = #
; ReadOnly (RO) = 0
; RegisteredApplications (RO) = #
01871fc4>
; Saved (RO) = 0
; SelectionSets (RO) = #
; TextStyles (RO) = #
; UserCoordinateSystems (RO) = #
; Utility (RO) = #
; Viewports (RO) = #
; Views (RO) = #
; Width = 978
; WindowState = 3
; WindowTitle (RO) = "S:\\JOBS\\0004\\0004-023-C UVA
StormVault\\004-023-C-1.dwg"
T

Command: (setq plot (vla-get-Plot doc))
#

Command: (setq pltcfgs (vla-get-PlotConfigurations doc))
#

Command: (vla-get-PlotConfiguration doc)
; error: no function definition: VLA-GET-PLOTCONFIGURATION

Command: (vlax-dump-object plot)
; IAcadPlot: AutoCAD Plot Interface
; Property values:
; Application (RO) = #
; BatchPlotProgress = 0
; NumberOfCopies = 1
; QuietErrorMode = 0
T

Command: (vlax-dump-object pltcfgs)
; IAcadPlotConfigurations: AutoCAD IAcadPlotConfigurations Interface
; Property values:
; Application (RO) = #
; Count (RO) = 0
; Document (RO) = #
; Handle (RO) = "19"
; HasExtensionDictionary (RO) = 0
; ObjectID (RO) = 1074543816
; ObjectName (RO) = "AcDbDictionary"
; OwnerID (RO) = 1074543712
T
etc. etc.
0 Likes
Message 6 of 23

Anonymous
Not applicable
Jimmy, you are solid gold! Thanks! I was off on another chase. Lots of goods
here.
--
Eric S. eschneider@jensenprecast.com
0 Likes
Message 7 of 23

Anonymous
Not applicable
Stay gold Jimmy.

Dan
0 Likes
Message 8 of 23

Anonymous
Not applicable
Eric,
can you specify more what you're after.

Maybe you can look at my homepage and search for pagesetup.lsp

--
Best regards: Jimmy B
CAD coordinator at Emtunga International AB
http://hem.fyristorg.com/cadman/
www.emtunga.com
0 Likes
Message 9 of 23

Anonymous
Not applicable
Jimmy,

We have a catalog of over 700 drawings and we save them in R15, R13, .dwf,
and .pdf formats. Doing this manually would indeed be a nightmare. Right
now, I have redefined Save, Saveas and Qsave and defun-ed them to include a
function to check their location before and after the save has been
perfomed. After comparing the before and afters, it creates or deletes the
directories and files in different formats as necessary. In the quest for
the better way, I want to do this through a function called by a reactor. I
know I can do all this as I already have the R13 format set up this way.

Well, right now I use the command function to step through the command line
version of -plot (no reactor, messy, kludgy, YUK!). I want to set all the
"plot defaults" (for lack of better wording) then use vla-sendComand or
something (vlax-invoke-method) to send the plot command. I would like the
plot command to need as few options as possible (see command line dump
below) so it willbe easier to adapt to model/paper space (each have a
different number of prompts). I also need ActiveX so it will run from a
reactor call.

Thank you for looking into my little mud bog.
--
Eric S. eschneider@jensenprecast.com

Command: -plot
Detailed plot configuration? [Yes/No] : n
Enter a layout name or [?] :
Enter a page setup name <>:
Enter an output device name or [?] :
Write the plot to a file [Yes/No] :
Save changes to model tab [Yes/No]?
Proceed with plot [Yes/No] :
0 Likes
Message 10 of 23

Anonymous
Not applicable
Eric.

;How about

(setq plotconfigs
(vla-get-PlotConfigurations
(vla-get-ActiveDocument (vlax-get-Acad-Object))
)
)
(setq plotconfiglis nil)
(vlax-for item plotconfigs
(setq plotconfiglis (cons item plotconfiglis))
)
;then plotconfiglis should contain a list of your plot configurations
(setq names (mapcar 'vla-get-name plotconfiglis))
;names should contain list of their names

On Tue, 29 Aug 2000 21:50:48 +0000, "Eric Schneider"
wrote:

>For everything I try though, I can't get the PlotConfiguration object. I can
>get the PlotConfigurations object, but that one doesn't have all the item I
>need to access, though it does have some.
>
>Still befuddled.
>--
>Eric S. eschneider@jensenprecast.com
>
>Command: (vlax-dump-object doc)
>; IAcadDocument: AutoCAD Document Interface
>; Property values:
>; Active (RO) = -1
>; ActiveDimStyle = #
>; ActiveLayer = #
>; ActiveLayout = #
>; ActiveLinetype = #
>; ActivePViewport = AutoCAD: No active viewport in paperspace
>; ActiveSelectionSet (RO) = #
>; ActiveSpace = 1
>; ActiveTextStyle = #
>; ActiveUCS = #
>; ActiveViewport = #
>; Application (RO) = #
>; Blocks (RO) = #
>; Database (RO) = #
>; Dictionaries (RO) = #
>; DimStyles (RO) = #
>; ElevationModelSpace = 0.0
>; ElevationPaperSpace = 0.0
>; FullName (RO) = "S:\\JOBS\\0004\\0004-023-C UVA
>StormVault\\004-023-C-1.dwg"
>; Groups (RO) = #
>; Height = 599
>; HWND (RO) = 983650
>; Layers (RO) = #
>; Layouts (RO) = #
>; Limits = (0.0 0.0 204.0 264.0)
>; Linetypes (RO) = #
>; ModelSpace (RO) = #
>; MSpace = AutoCAD: Invalid mode
>; Name (RO) = "004-023-C-1.dwg"
>; ObjectSnapMode = 0
>; PaperSpace (RO) = #
>; Path (RO) = "S:\\JOBS\\0004\\0004-023-C UVA StormVault"
>; PickfirstSelectionSet (RO) = #
>; Plot (RO) = #
>; PlotConfigurations (RO) = #
>; Preferences (RO) = #
>; ReadOnly (RO) = 0
>; RegisteredApplications (RO) = #
>01871fc4>
>; Saved (RO) = 0
>; SelectionSets (RO) = #
>; TextStyles (RO) = #
>; UserCoordinateSystems (RO) = #
>; Utility (RO) = #
>; Viewports (RO) = #
>; Views (RO) = #
>; Width = 978
>; WindowState = 3
>; WindowTitle (RO) = "S:\\JOBS\\0004\\0004-023-C UVA
>StormVault\\004-023-C-1.dwg"
>T
>
>Command: (setq plot (vla-get-Plot doc))
>#
>
>Command: (setq pltcfgs (vla-get-PlotConfigurations doc))
>#
>
>Command: (vla-get-PlotConfiguration doc)
>; error: no function definition: VLA-GET-PLOTCONFIGURATION
>
>Command: (vlax-dump-object plot)
>; IAcadPlot: AutoCAD Plot Interface
>; Property values:
>; Application (RO) = #
>; BatchPlotProgress = 0
>; NumberOfCopies = 1
>; QuietErrorMode = 0
>T
>
>Command: (vlax-dump-object pltcfgs)
>; IAcadPlotConfigurations: AutoCAD IAcadPlotConfigurations Interface
>; Property values:
>; Application (RO) = #
>; Count (RO) = 0
>; Document (RO) = #
>; Handle (RO) = "19"
>; HasExtensionDictionary (RO) = 0
>; ObjectID (RO) = 1074543816
>; ObjectName (RO) = "AcDbDictionary"
>; OwnerID (RO) = 1074543712
>T
>etc. etc.
>
0 Likes
Message 11 of 23

Anonymous
Not applicable
Tom,

I guess I have no plot configurations in the drawing because the functions
you gave me return nil.

I am sure you saw my reply to your first responce. According to the "object
model" flow chart that comes with the VBA IDE help, the PlotCinfiguration
object should be in the PlotConfigurations collection, but using
vla-dump-object, it's not there. (?)

I'll toy around with Jimmy B.'s stuff. At a glance, most of the stuff I need
to do appeared to be there. I'll keep banging my head to find the other
stuff I need.

Thanks.
--
Eric S. eschneider@jensenprecast.com
0 Likes
Message 12 of 23

Anonymous
Not applicable
If you manually establish a "Page setup" or two in
a drawing, you will have plot configuration objects.

I'm new to ActiveX, but as far as I can tell,
the plotconfigurations collection must be
iterated thru (note the vlax-for) in order
to access individual plot configuration objects:

I think the DimStyles collection would have to
be handled in the same way.

On Wed, 30 Aug 2000 16:39:03 +0000, "Eric Schneider"
wrote:

>Tom,
>
>I guess I have no plot configurations in the drawing because the functions
>you gave me return nil.
>
>I am sure you saw my reply to your first responce. According to the "object
>model" flow chart that comes with the VBA IDE help, the PlotCinfiguration
>object should be in the PlotConfigurations collection, but using
>vla-dump-object, it's not there. (?)
>
>I'll toy around with Jimmy B.'s stuff. At a glance, most of the stuff I need
>to do appeared to be there. I'll keep banging my head to find the other
>stuff I need.
>
>Thanks.
>--
>Eric S. eschneider@jensenprecast.com
>
0 Likes
Message 13 of 23

Anonymous
Not applicable
Oh yeah, you can use the Add method of
PlotConfigurations collection
to create a PlotConfiguration from within VBA or Vlisp

Noticed that in ActiveX help, DimStyle is mentioned as a
Child of the DimStyles collection, and block is a child
of Blocks collection.

But, though as you have noted this is not the case,
in help, with Plotconfigs. Error in help? or some subtlety.
Anybody know?

(yeah, Jimmy B did us favors, his post went straight
to the hard drive!)

On Wed, 30 Aug 2000 16:39:03 +0000, "Eric Schneider"
wrote:

>Tom,
>
>I guess I have no plot configurations in the drawing because the functions
>you gave me return nil.
>
>I am sure you saw my reply to your first responce. According to the "object
>model" flow chart that comes with the VBA IDE help, the PlotCinfiguration
>object should be in the PlotConfigurations collection, but using
>vla-dump-object, it's not there. (?)
>
>I'll toy around with Jimmy B.'s stuff. At a glance, most of the stuff I need
>to do appeared to be there. I'll keep banging my head to find the other
>stuff I need.
>
>Thanks.
>--
>Eric S. eschneider@jensenprecast.com
>
0 Likes
Message 14 of 23

Anonymous
Not applicable
Yeah, I'm new to ActiveX too. I'm stumbling along in the dark. We'll get it
though, with the help of the guru's.
--
Eric S. eschneider@jensenprecast.com
0 Likes
Message 15 of 23

Anonymous
Not applicable
Yes, praise {insert deity, spirit}

On Wed, 30 Aug 2000 17:37:50 +0000, "Eric Schneider"
wrote:

>Yeah, I'm new to ActiveX too. I'm stumbling along in the dark. We'll get it
>though, with the help of the guru's.
>--
>Eric S. eschneider@jensenprecast.com
>
0 Likes
Message 16 of 23

Anonymous
Not applicable
Eric,
At 14 of my prev. answer you have the code to start the "plot" command with activeX both to plotter and to file.
Anything else?

--
Best regards: Jimmy B
CAD coordinator at Emtunga International AB
http://hem.fyristorg.com/cadman/
www.emtunga.com
0 Likes
Message 17 of 23

Anonymous
Not applicable
Yeah. There is one more thing. What does the "B" stand for in Jimmy B.?
Oh and many thanks.
: )
--
Eric S. eschneider@jensenprecast.com
0 Likes
Message 18 of 23

Anonymous
Not applicable
B is equal to S as in your case

--
Best regards: Jimmy B
CAD coordinator at Emtunga International AB
http://hem.fyristorg.com/cadman/
www.emtunga.com
0 Likes
Message 19 of 23

Anonymous
Not applicable
Yes, but the "S" is cleverly desyphered in my e-mail address.
--
Eric S. eschneider@jensenprecast.com
0 Likes
Message 20 of 23

Anonymous
Not applicable
Mine isn't.

--
Best regards: Jimmy B
CAD coordinator at Emtunga International AB
http://hem.fyristorg.com/cadman/
www.emtunga.com
0 Likes