Alaskachick Posted January 3, 2010 Author Posted January 3, 2010 added the double slashes, still says invalid file name. my head hurts and this is no longer cost effective. lol:ouch: must. stop. now. Quote
Lee Mac Posted January 3, 2010 Posted January 3, 2010 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 Quote
Alaskachick Posted January 5, 2010 Author Posted January 5, 2010 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. Quote
wizman Posted January 5, 2010 Posted January 5, 2010 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! Quote
Lee Mac Posted January 5, 2010 Posted January 5, 2010 Excellent to hear - glad we could help you along! Quote
hamskies Posted February 1, 2010 Posted February 1, 2010 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) ) Quote
Lee Mac Posted February 1, 2010 Posted February 1, 2010 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 Quote
RPGIS Posted March 4, 2010 Posted March 4, 2010 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! Quote
Lee Mac Posted March 4, 2010 Posted March 4, 2010 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 Quote
RPGIS Posted March 4, 2010 Posted March 4, 2010 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! Quote
Lee Mac Posted March 4, 2010 Posted March 4, 2010 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 Quote
RPGIS Posted March 4, 2010 Posted March 4, 2010 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 Quote
Lee Mac Posted March 4, 2010 Posted March 4, 2010 Perhaps read this first: http://www.cadtutor.net/forum/showthread.php?t=1390 Quote
RPGIS Posted March 4, 2010 Posted March 4, 2010 Perhaps read this first: http://www.cadtutor.net/forum/showthread.php?t=1390 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! Quote
RPGIS Posted March 4, 2010 Posted March 4, 2010 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)) Quote
Lee Mac Posted March 4, 2010 Posted March 4, 2010 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)) Quote
RPGIS Posted March 4, 2010 Posted March 4, 2010 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? Quote
Lee Mac Posted March 4, 2010 Posted March 4, 2010 Yeah, I changed it so you could invoke it at the command line - check the definition: (defun [color=Red][b]c:[/b][/color] ... Quote
alanjt Posted March 4, 2010 Posted March 4, 2010 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) Quote
RPGIS Posted March 4, 2010 Posted March 4, 2010 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? Quote
Recommended Posts
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.