Jump to content

Recommended Posts

Posted

In a dwg file that has more than one tab I would like to check

if the plotter device is set to 'NONE' on any of the tabs.

 

First I tried using :

 
(setq GetActivePlotDevice(vla-get-ConfigName
   (vla-get-ActiveLayout
   (vla-get-activedocument
     (vlax-get-acad-object)))))

to find the plotter device in the current tab. This doesn't seem to work. Is there a way to find the plotter device name?

 

I other questions but that is all for now - thanks

 

cheers

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    11

  • Lee Mac

    7

  • Small Fish

    6

Top Posters In This Topic

Posted Images

Posted

Perhaps something like this?

 

(defun GetPlotDevices (/ dvc)
 (vl-load-com)
 ;; Lee Mac  ~  26.02.10

 (vlax-map-collection
   (vla-get-layouts
     (vla-get-ActiveDocument
       (vlax-get-acad-object)))
   (function
     (lambda (layout)
       (vla-RefreshPlotDeviceInfo layout)
       (setq dvc
         (cons
           (cons
             (vla-get-name layout)
               (vla-get-ConfigName layout)) dvc)))))
 
 (reverse dvc))

Posted

(vla-get-configname
 (vla-get-activelayout
   (vla-get-activedocument
     (vlax-get-acad-object))))

Works just fine for me. Returns "None" if nothing or the plotting device name.

 

Edit: Oops, didn't realize you replied. I hit reply, got up for a second, sat back down and finished responding.

Posted
Edit: Oops, didn't realize you replied. I hit reply, got up for a second, sat back down and finished responding.

 

Hey, no worries dude :)

 

As you say, the code that SmallFish posted seemed to be correct, but sometimes I find you have to call:

 

(vla-RefreshPlotDeviceInfo <layout>)

first.

 

Lee

Posted
Hey, no worries dude :)

 

As you say, the code that SmallFish posted seemed to be correct, but sometimes I find you have to call:

 

(vla-RefreshPlotDeviceInfo <layout>)

first.

 

Lee

That's true. I've encountered that in the past.

Posted

I was just curious...

 

(defun PlotDevices (/ #List)
 (vlax-for x (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
   (vla-refreshplotdeviceinfo x)
   (setq #List (cons (cons (vla-get-name x) (vla-get-configname x)) #List))
 ) ;_ vlax-for
 (reverse #List)
) ;_ defun

 

Command: (benchmark '( (getplotdevices) (plotdevices) ))
Elapsed milliseconds / relative speed for 64 iteration(s):

   (PLOTDEVICES)........1203 / 1.17 <fastest>
   (GETPLOTDEVICES).....1407 / 1.00 <slowest>

Command: (benchmark '( (getplotdevices) (plotdevices) ))
Elapsed milliseconds / relative speed for 64 iteration(s):

   (GETPLOTDEVICES).....1218 / 1.00 <fastest>
   (PLOTDEVICES)........1219 / 1.00 <slowest>

Command: (benchmark '( (getplotdevices) (plotdevices) ))
Elapsed milliseconds / relative speed for 64 iteration(s):

   (PLOTDEVICES)........1219 / 1.01 <fastest>
   (GETPLOTDEVICES).....1234 / 1.00 <slowest>

Command: (benchmark '( (getplotdevices) (plotdevices) ))
Elapsed milliseconds / relative speed for 64 iteration(s):

   (GETPLOTDEVICES).....1219 / 1.00 <fastest>
   (PLOTDEVICES)........1219 / 1.00 <slowest>

Command: (benchmark '( (getplotdevices) (plotdevices) ))
Elapsed milliseconds / relative speed for 64 iteration(s):

   (PLOTDEVICES)........1218 / 1.00 <fastest>
   (GETPLOTDEVICES).....1219 / 1.00 <slowest>

Posted

Thanks Alan and Lee mac

 

.....so it was the old "vla-RefreshPlotDeviceInfo"

function that I needed .

 

cheers

.:D

Posted
Thanks Alan and Lee mac

 

.....so it was the old "vla-RefreshPlotDeviceInfo"

function that I needed .

 

cheers

.:D

Enjoy and have a good weekend.

Posted

One more question...

I would like to alert/princ the user that there are one or more tabs that have 'none' as the plot device - how do I check for any 'none' pairs in the dvc dotted pair list?

thanks

Posted
One more question...

I would like to alert/princ the user that there are one or more tabs that have 'none' as the plot device - how do I check for any 'none' pairs in the dvc dotted pair list?

thanks

Maybe something like this...

(and (setq #Alert "")
    (foreach x (GetPlotDevices)
      (and (eq "None" (cdr x))
           (setq #Alert (strcat #Alert (car x) "\n"))
      ) ;_ and
    ) ;_ foreach
    (alert (strcat "Layouts without defined plotter devices:\n\n" #Alert))
) ;_ and

Posted

Hey Alan

that looks good (I can't try it yet - but I'm sure it works)

many thanks SM

Posted
Hey Alan

that looks good (I can't try it yet - but I'm sure it works)

many thanks SM

I think it'll give you what you need. :)

alert.PNG

Posted

Thanks Alan, I realised that vlax-map-collection is slower, but I fancied a change :) They should make vlax-map-collection act like mapcar to make it really useful.

Posted
Thanks Alan, I realised that vlax-map-collection is slower, but I fancied a change :) They should make vlax-map-collection act like mapcar to make it really useful.

I'd never used vlax-map-collection. I was just curious about the speed.

Posted

Alan thanks yes it works well and I like that alert box that can add depending on the list. However I seem to be having a problem with the alert box not working intermittely - and I'm not sure why? I originally also was going to make a list of tabs that had the printer set to 'NONE' however that may be too difficult. What I was trying to do is exit the code if any of the tabs selected are set to 'None' then asking the user to set to a printer device.

 

 

now I've got sore eyes and a headache...

I'm trying to:

 

1) I want to make the alert box work again

2) exit if 'none' is selected for a plotter device

3) If tabs selected do not have any 'none' then continue on.

(maybe even let the user change the plotter device while program is running - but that sounds difficult)

 

 
(defun c:plotdev2 (/ layout dvc #Alert layouts_to_plot)
(vl-load-com)
(vlax-map-collection
   (vla-get-layouts
     (vla-get-ActiveDocument
       (vlax-get-acad-object)))
   (function
     (lambda (layout)
       (vla-RefreshPlotDeviceInfo layout)
       (setq dvc
         (cons
           (cons
             (vla-get-name layout)
               (vla-get-ConfigName layout)) dvc)))))
 
 (reverse dvc)

(and (setq #Alert "")
    (foreach x dvc
      (and (eq "None" (cdr x))
           (setq #Alert (strcat #Alert (car x) "\n"))
      ) ;_ and
    ) ;_ foreach
    (alert (strcat "Layouts without defined plotter devices:\n\n" #Alert))
    (exit)
) ;_ and
(setq layouts_to_plot (dos_multilist "  A3 prints to  printer"
  "Select drawings to be printed" (ListLayouts)))
;more to be added later....
(princ)
);defun

Posted

Something like this perhaps:

 


(defun c:plotdev2 (/ GetPlotDevices lst2str Devices)
(vl-load-com)
 
 (defun GetPlotDevices (/ dvc)
   ;; Lee Mac  ~  26.02.10

   (vlax-map-collection
     (vla-get-layouts
       (vla-get-ActiveDocument
         (vlax-get-acad-object)))
     (function
       (lambda (layout)
         (vla-RefreshPlotDeviceInfo layout)
         (setq dvc
           (cons
             (cons
               (vla-get-name layout)
                 (vla-get-ConfigName layout)) dvc)))))
   
   (reverse dvc))

 (defun lst2str (lst del)
   (if (cdr lst)
     (strcat (car lst) del (lst2str (cdr lst) del))
     (car lst)))
 

 (if (setq Devices
       (vl-remove-if-not
         (function
           (lambda (x) (eq "None" (cdr x)))) (GetPlotDevices)))

   (alert (strcat "Layouts without defined plotter devices:\n\n"
                  (lst2str (mapcar (function car) Devices) "\n"))))

 (princ))

   

Posted

??

 

(defun test (/ #Msg)
 (setq #Msg "")
 (vlax-for x (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
   (vla-refreshplotdeviceinfo x)
   (and (eq (vla-get-configname x) "None")
        (setq #Msg (strcat #Msg (vla-get-name x) "\n"))
   ) ;_ and
 ) ;_ vlax-for
 (if (eq "" #Msg)
   (alert "All layouts have a defined plotter device.")
   (alert (strcat "Layouts without defined plotter devices:\n\n" #Msg))
 ) ;_ if
) ;_ defun

Posted

wow! that works well - thanks Alan and Lee8)

there's so much to learn.....

Posted

You're welcome Mr Fish - I probably went for the more OOP approach, but Alans will most likely be faster. :)

Posted
wow! that works well - thanks Alan and Lee8)

there's so much to learn.....

You're welcome. There's always something new to learn. :)

 

You're welcome Mr Fish - I probably went for the more OOP approach, but Alans will most likely be faster. :)

Well, I just thought I'd show him a less laborious option. Nothing wrong with yours, it's just slowed down by processing the same list 3 times, plus the recursion sub.

 

What's the OOP approach?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...