Jump to content

Recommended Posts

Posted

added the double slashes, still says invalid file name. my head hurts and this is no longer cost effective. lol:ouch:

 

must. stop. now.

  • Replies 46
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    16

  • Alaskachick

    11

  • RPGIS

    9

  • wizman

    5

Top Posters In This Topic

Posted
added the double slashes, still says invalid file name. my head hurts and this is no longer cost effective. lol:ouch:

 

must. stop. now.

 

Fair enough - at least we tried :)

Posted

Here is the report: I took the script & lisp to work and dropped a task that originally took 50 secs per file down to 15 secs per file. Unfortunetly, the head engineer didn't like the remaining named page setup. So I wrote another script to fix files I had already changed and then figured out a way to run the script/lisp and delete the name page setup all in 18 secs per file.

 

So, Thank You All for your help!!

 

It scored me big points and after that my boss told me my "temporary" position would continue for as long as they have work for me, instead of the original 4-6 weeks.

Posted
Here is the report: I took the script & lisp to work and dropped a task that originally took 50 secs per file down to 15 secs per file. Unfortunetly, the head engineer didn't like the remaining named page setup. So I wrote another script to fix files I had already changed and then figured out a way to run the script/lisp and delete the name page setup all in 18 secs per file.

 

So, Thank You All for your help!!

 

It scored me big points and after that my boss told me my "temporary" position would continue for as long as they have work for me, instead of the original 4-6 weeks.

 

 

That's good to hear, goodluck!

  • 4 weeks later...
Posted

I found this lsp in the web, it works, however i would like to make the selected page setup to be current. can someone help me add some strings to make it happen. thank you very much in advance.

 

(defun C:IPS (/ exprt)

(setq exprt (getvar "EXPERT"))

(setvar "EXPERT" 2)

(command "._-PSETUPIN" "Q:\\Layouts\\AX059_AB.dwg" "AX059_A2_AB_DAR") ;change the name and path to your dwg/dwg file

(setvar "expert" exprt)

)

Posted
I found this lsp in the web, it works, however i would like to make the selected page setup to be current. can someone help me add some strings to make it happen. thank you very much in advance.

 

(defun C:IPS (/ exprt)

(setq exprt (getvar "EXPERT"))

(setvar "EXPERT" 2)

(command "._-PSETUPIN" "Q:\\Layouts\\AX059_AB.dwg" "AX059_A2_AB_DAR") ;change the name and path to your dwg/dwg file

(setvar "expert" exprt)

)

 

 

My code here should help you :)

  • 1 month later...
Posted
Wiz,

 

might this work?

 

(defun SetPSAllLayouts (setup / doc)

 (if (not (vl-catch-all-error-p
            (setq setup
              (vl-catch-all-apply (function vla-item)
                (list (vla-get-PlotConfigurations
                        (setq doc
                          (vla-get-ActiveDocument
                            (vlax-get-acad-object)))) setup)))))
   (vlax-map-collection
     (vla-get-layouts doc)
       (function
         (lambda (x)
           (if (eq :vlax-false (vla-get-Modeltype x))
             (vla-CopyFrom x setup)))))))

 

 

 

 

How would i go about implementing this code? what do I need to specifiy what page setup I would like to set the layouts to?

 

Thanks a ton, this has been a brutal couple of days trying to find a solution to this!

Posted
what do I need to specifiy what page setup I would like to set the layouts to?

 

Yes, the argument required is a valid Setup Name :)

 

Thanks a ton, this has been a brutal couple of days trying to find a solution to this!

 

You're welcome :)

Posted

 

 

I am still very confused!:?

 

If I have a c:\CAD\PAGE BORDER.dwg and the layout is called "RP PAGE BORDER" and the page setup name is "RP BORDER"

 

Which one of these do I use? and Where do I insert them in the lsp?

 

Thanks a million!

Posted

Sorry, I should have explained a bit more.

 

The function I have provided is a sub-function, which may be called with arguments (in this case the Page Setup Name):

 

(defun SetPSAllLayouts (setup / doc)

 (if (not (vl-catch-all-error-p
            (setq setup
              (vl-catch-all-apply (function vla-item)
                (list (vla-get-PlotConfigurations
                        (setq doc
                          (vla-get-ActiveDocument
                            (vlax-get-acad-object)))) setup)))))
   (vlax-map-collection
     (vla-get-layouts doc)
       (function
         (lambda (x)
           (if (eq :vlax-false (vla-get-Modeltype x))
             (vla-CopyFrom x setup)))))))

 

You can call it like:

 

(SetPSAllLayouts "Setup")

 

Or, in a LISP that may be invoked via the command line:

 

(defun c:test nil

 (SetPSAllLayouts "Setup")
 (princ))

 

[ Notice the defun c: in this case ]

 

In your case, you can call it with:

 

(SetPSAllLayouts "RP BORDER")

 

Lee

Posted

 

 

 

 

 

How does it know where to look for the .lsp file?

 

I keep getting an error saying LOAD FAILED. I cant even get to a point where i can figure out if the contents of my .lsp file will work!

 

thanks again

Posted

 

 

 

Okay....I figured the lsp loading. Thanks alot.

 

Here is the lsp I have loaded currently but I keep getting the following error. Note: I change the name of the lsp routine to DOBORDER

 

** Error: no function definition: VLAX-GET-ACAD-OBJECT **

 

 

 

(defun DOBORDER (/ *error* AT:PageSetups SetPSAllLayouts vl ov)

(defun *error* (msg)

(and ov (mapcar 'setvar vl ov))

(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")

(princ (strcat "\n** Error: " msg " **")))

(princ))

(setq *acad* (cond (*acad*) ((vlax-get-acad-object)))

*doc* (cond (*doc) ((vla-get-ActiveDocument *acad*))))

 

;;; Insert all Page Setups into drawing (will overwrite if exists)

;;; #DrawingFile - name of DWG file from which to import

;;; Alan J. Thompson, 07.29.09

(defun AT:PageSetups (#layout1)

(if (findfile #layout1)

(progn

(command "_.psetupin" (findfile #layout1) "*")

(while (wcmatch (getvar "cmdnames") "*PSETUPIN*")

(command "_yes")) T)))

(defun SetPSAllLayouts (setup / doc)

 

(if (not (vl-catch-all-error-p

(setq setup

(vl-catch-all-apply (function vla-item)

(list (vla-get-PlotConfigurations

(setq doc

(vla-get-ActiveDocument

(vlax-get-acad-object)))) setup)))))

(vlax-map-collection

(vla-get-layouts doc)

(function

(lambda (x)

(if (eq :vlax-false (vla-get-Modeltype x))

(vla-CopyFrom x setup)))))))

(setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl))

(mapcar 'setvar vl '(0 0))

;; ------------ Start Here -----------------------------

(vl-cmdf "_.pasteclip" "0,0")

(AT:PageSetups "C:\CAD\PAGE BORDER.dwg") ;; Change this if necessary

(repeat 3 (vla-purgeall *doc*))

(setPSAllLayouts "RP BORDER")

(vla-ZoomExtents *acad*)

(if (eq "" (vla-get-FullName *doc*))

(vla-saveas *doc*

(strcat

(vla-get-Path *doc*) "\\"

(vla-get-name *doc*)))

(vla-save *doc*))

;; ------------ End Here -----------------------------

(mapcar 'setvar vl ov)

(princ))

 

 

 

Thanks again!

Posted

sorry

 

(defun DOBORDER (/ *error* AT:PageSetups SetPSAllLayouts vl ov)
 (defun *error* (msg)
   (and ov (mapcar 'setvar vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))
 (setq *acad* (cond (*acad*) ((vlax-get-acad-object)))
       *doc*  (cond (*doc)   ((vla-get-ActiveDocument *acad*))))
  
 ;;; Insert all Page Setups into drawing (will overwrite if exists)
 ;;; #DrawingFile - name of DWG file from which to import
 ;;; Alan J. Thompson, 07.29.09
 (defun AT:PageSetups (#layout1)
   (if (findfile #layout1)
     (progn
       (command "_.psetupin" (findfile #layout1) "*")
       (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
         (command "_yes")) T)))
(defun SetPSAllLayouts (setup / doc)

 (if (not (vl-catch-all-error-p
            (setq setup
              (vl-catch-all-apply (function vla-item)
                (list (vla-get-PlotConfigurations
                        (setq doc
                          (vla-get-ActiveDocument
                            (vlax-get-acad-object)))) setup)))))
   (vlax-map-collection
     (vla-get-layouts doc)
       (function
         (lambda (x)
           (if (eq :vlax-false (vla-get-Modeltype x))
             (vla-CopyFrom x setup)))))))
 (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl))
 (mapcar 'setvar vl '(0 0))
 ;; ------------ Start Here -----------------------------
 (vl-cmdf "_.pasteclip" "0,0")
 (AT:PageSetups "C:\CAD\PAGE BORDER.dwg") ;; Change this if necessary
 (repeat 3 (vla-purgeall *doc*))
 (setPSAllLayouts "RP BORDER")
 (vla-ZoomExtents *acad*)
 (if (eq "" (vla-get-FullName *doc*))
   (vla-saveas *doc*
     (strcat
       (vla-get-Path *doc*) "\\"
         (vla-get-name *doc*)))
   (vla-save *doc*))
 ;; ------------ End Here -----------------------------
 (mapcar 'setvar vl ov)
 (princ))

Posted

Just missing a (vl-load-COM) to load the Visual LISP functionality:

 

(defun c:DOBORDER (/ *error* AT:PageSetups SetPSAllLayouts vl ov)
 (vl-load-com)
 
 (defun *error* (msg)
   (and ov (mapcar 'setvar vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))
 
 (setq *acad* (cond (*acad*) ((vlax-get-acad-object)))
       *doc*  (cond (*doc)   ((vla-get-ActiveDocument *acad*))))
  
 ;;; Insert all Page Setups into drawing (will overwrite if exists)
 ;;; #DrawingFile - name of DWG file from which to import
 ;;; Alan J. Thompson, 07.29.09
 (defun AT:PageSetups (#layout1)
   (if (findfile #layout1)
     (progn
       (command "_.psetupin" (findfile #layout1) "*")
       (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
         (command "_yes")) T)))
 
 (defun SetPSAllLayouts (setup / doc)
   
   (if (not (vl-catch-all-error-p
              (setq setup
                     (vl-catch-all-apply (function vla-item)
                       (list (vla-get-PlotConfigurations
                               (setq doc
                                      (vla-get-ActiveDocument
                                        (vlax-get-acad-object)))) setup)))))
     (vlax-map-collection
       (vla-get-layouts doc)
       (function
         (lambda (x)
           (if (eq :vlax-false (vla-get-Modeltype x))
             (vla-CopyFrom x setup)))))))
 
 (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl))
 (mapcar 'setvar vl '(0 0))
 
 ;; ------------ Start Here -----------------------------
 
 (vl-cmdf "_.pasteclip" "0,0")
 (AT:PageSetups "C:\CAD\PAGE BORDER.dwg") ;; Change this if necessary
 
 (repeat 3 (vla-purgeall *doc*))
 
 (setPSAllLayouts "RP BORDER")
 
 (vla-ZoomExtents *acad*)
 
 (if (eq "" (vla-get-FullName *doc*))
   (vla-saveas *doc*
     (strcat
       (vla-get-Path *doc*) "\\"
         (vla-get-name *doc*)))
   
   (vla-save *doc*))
 
 ;; ------------ End Here -----------------------------
 
 (mapcar 'setvar vl ov)
 (princ))

Posted
Just missing a (vl-load-COM) to load the Visual LISP functionality:

quote]

 

 

Command: (load "DOBORDER.lsp")

C:DOBORDER

Command: (DOBORDER)

; error: no function definition: DOBORDER

 

Any suggestions?

Posted

Yeah, I changed it so you could invoke it at the command line - check the definition:

 

(defun [color=Red][b]c:[/b][/color] ...

Posted
Just missing a (vl-load-COM) to load the Visual LISP functionality:

quote]

 

 

Command: (load "DOBORDER.lsp")

C:DOBORDER

Command: (DOBORDER)

; error: no function definition: DOBORDER

 

Any suggestions?

 

 

(c:DOBORDER)

Posted

Still the same thing...

 

 

error: no function definition: DOBORDER

 

weird.

 

 

Here is the code:

 

OPEN "C:\CAD\G&H.dwg"
(load "DOBORDER.lsp")
(DOBORDER)

 

 

Here is the LSP:

 

(defun c:DOBORDER (/ *error* AT:PageSetups SetPSAllLayouts vl ov)
 (vl-load-com)
 
 (defun *error* (msg)
   (and ov (mapcar 'setvar vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))
 
 (setq *acad* (cond (*acad*) ((vlax-get-acad-object)))
       *doc*  (cond (*doc)   ((vla-get-ActiveDocument *acad*))))
  
 ;;; Insert all Page Setups into drawing (will overwrite if exists)
 ;;; #DrawingFile - name of DWG file from which to import
 ;;; Alan J. Thompson, 07.29.09
 (defun AT:PageSetups (#layout1)
   (if (findfile #layout1)
     (progn
       (command "_.psetupin" (findfile #layout1) "*")
       (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
         (command "_yes")) T)))
 
 (defun SetPSAllLayouts (setup / doc)
   
   (if (not (vl-catch-all-error-p
              (setq setup
                     (vl-catch-all-apply (function vla-item)
                       (list (vla-get-PlotConfigurations
                               (setq doc
                                      (vla-get-ActiveDocument
                                        (vlax-get-acad-object)))) setup)))))
     (vlax-map-collection
       (vla-get-layouts doc)
       (function
         (lambda (x)
           (if (eq :vlax-false (vla-get-Modeltype x))
             (vla-CopyFrom x setup)))))))
 
 (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl))
 (mapcar 'setvar vl '(0 0))
 
 ;; ------------ Start Here -----------------------------
 
 (vl-cmdf "_.pasteclip" "0,0")
 (AT:PageSetups "C:\CAD\PAGE BORDER.dwg") ;; Change this if necessary
 
 (repeat 3 (vla-purgeall *doc*))
 
 (setPSAllLayouts "RP BORDER")
 
 (vla-ZoomExtents *acad*)
 
 (if (eq "" (vla-get-FullName *doc*))
   (vla-saveas *doc*
     (strcat
       (vla-get-Path *doc*) "\\"
         (vla-get-name *doc*)))
   
   (vla-save *doc*))
 
 ;; ------------ End Here -----------------------------
 
 (mapcar 'setvar vl ov)
 (princ))

 

Any insight, maybe i screwed something up in the lsp?

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...