Jump to content

Recommended Posts

Posted

Hi All

 

I have a lisp to import a page setup, as shown below

 

(command "-psetupin" "Z:/Drawings/Pagesetups.dwg" "ICAD-DWF")

 

 

Problem is, if this page setup already exists i need to use this one as i will be prompted if i want to replace the existing one.

 

(command "-psetupin" "Z:/Drawings/Pagesetups.dwg" "ICAD-DWF" "y")

 

 

I tried using the 2nd one where the page setup wasnt currently in the drawing but it crashes the lisp as it uses the "y" as a command so i get the command not known error.

 

I have thought about using the if but not sure how to get the arrgument for the page setup.

 

I know most of you will know a better way of doing this so any tips will be appreciated.

 

Cheers

Posted

Not sure if this would work?

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] PsetIm  [b][color=RED]([/color][/b]setp [b][color=BLUE]/[/color][/b] plts lst[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] plts
        [b][color=RED]([/color][/b][b][color=BLUE]vla-get-PlotConfigurations[/color][/b]
          [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b]
            [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] plt  plts
   [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Name[/color][/b] plt[b][color=RED])[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-position[/color][/b] setp lst[b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vl-cmdf[/color][/b] [b][color=#ff00ff]"_.-psetupin"[/color][/b] [b][color=#ff00ff]"Z:/Drawings/Pagesetups.dwg"[/color][/b] setp[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

Posted

I delete all pagesetups then import:

 

(defun c:del_pagesetups    (/)
 (vlax-map-collection
   (vla-get-Plotconfigurations
     (vla-get-ActiveDocument
   (vlax-get-Acad-Object)
     )
   )
   'vla-delete
 )
 (princ)
)

Posted

Ron, would this work?

 

(defun PsetIm  (setp / plts lst)
 (setq plts
        (vla-get-PlotConfigurations
          (vla-get-ActiveDocument
            (vlax-get-acad-object))))
 (vlax-map-collection plts 'vla-delete)
 (vla-add plts setp :vlax-false))

Posted

It will create the pagesetup...but you'd still have to set the rest of the pertinent plot settings. I've used the command version since Acad2005 and have not had any problems. (right now I have 72 different pagesetups:? )

Posted
It will create the pagesetup...but you'd still have to set the rest of the pertinent plot settings. I've used the command version since Acad2005 and have not had any problems. (right now I have 72 different pagesetups:? )

 

 

I see -

 

I wanted to veer away from the "command-call-cop-out" if you like :P

 

but it looks like it might be appropriate for this situation :)

  • 1 year later...
Posted

hey there all, this is a very late responce to this thread but i am looking for something :)

 

i have a lot of drawing of a older project that has about 2000 drawings each with between 3 to 50 layout's, with A4 and A3 size random spread.

is it possible to set a pagesetup bij the name of the titleblock with the help of a lisp?

 

Mvg John

Posted

thx ronjonp, i have looking at the link you send..

it looks like with t(hat lisp i have to look at every layout to see if it's A4 or A3

i'm looking for a lisp that looks at the titelblok and then set the right pagesetup.

Posted
thx ronjonp, i have looking at the link you send..

it looks like with t(hat lisp i have to look at every layout to see if it's A4 or A3

i'm looking for a lisp that looks at the titelblok and then set the right pagesetup.

 

The link was only for ideas. It has all the basic code needed (import pagesetup, apply pagesetup to layout, etc...) Do you write any code or are you looking for the whole enchilada?:)

Posted

i'm just new to lisp ...

at the moment i am looking to a lott of code... and doing the windows thing ..

copy paste ;)

 

it's not nobel but i'm learning

Posted

No worries ... I'm a bit busy at work right now but if time permits I'll see if I can throw something together. Perhaps in the mean time you can post a sample drawing ... maybe Lee will jump on board and write you something lickety-split:lol:

Posted

this is something i have found

 

but i don't see where the link is set to the dwt

 

 

;; *** MB-2004 *** 
;; *** Turns off Messages ***
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)

;; *** Deletes Page Setups
(defun Delset ()
 (vl-load-com)
 (vlax-for y (vla-get-plotconfigurations
 (vla-get-activedocument (vlax-get-acad-object))
   )
(if (/= "Model" (vla-get-name y))
  (vla-delete y)
)
 )
)
(Delset)

;; *** Deletes Page Layouts
(defun DelTabs ()
 (vl-load-com)
 (vlax-for x (vla-get-layouts
 (vla-get-activedocument (vlax-get-acad-object))
   )
(if (/= "Model" (vla-get-name x))
  (vla-delete x)
)
 )
)
(deltabs)

;; *** Calls in current layout tabs based on size ***
;; *** Adds Default Setups and sets defaults ***
(setq a (ssget "X"
	'((-4 . "<OR")
  (-4 . "<AND")
  (0 . "Insert")
  (2 . "B-SIZE")
  (-4 . "AND>")
  (-4 . "<AND")
  (0 . "Insert")
  (2 . "C-SIZE")
  (-4 . "AND>")
  (-4 . "<AND")
  (0 . "Insert")
  (2 . "C-SIZE-H")
  (-4 . "AND>")
  (-4 . "<AND")
  (0 . "Insert")
  (2 . "CP-SIZE")
  (-4 . "AND>")
  (-4 . "<AND")
  (0 . "Insert")
  (2 . "D-SIZE")
  (-4 . "AND>")
  (-4 . "OR>")
 )
)
)
(setq n (sslength a))
(setq index 0)
(repeat n
 (setq b (entget (ssname a index)))
 (setq blkname (cdr (assoc 2 b)))
 (if (= (strcase blkname T) "b-size")
(command "LAYOUT"	   "T"		"BBraun B-Size-2005.dwt"
  "*"	   "-PSETUPIN"	  "BBRAUN B-SIZE-2005.DWT"
  "*"	   ^c		^c
  ^c		^c
 )
 )
 (if (= (strcase blkname T) "c-size")
(command "LAYOUT"	   "T"		"BBraun C-Size-2005.dwt"
  "*"	   "-PSETUPIN"	  "BBRAUN C-SIZE-2005.DWT"
  "*"	   ^c		^c
  ^c		^c
 )
 )
 (if (= (strcase blkname T) "c-size-h")
(command "LAYOUT"		"T"
  "BBraun C-Size-H-2005.dwt"   "*"
  "-PSETUPIN"	   "BBRAUN C-SIZE-H-2005.DWT"
  "*"		^c   ^c
  ^c		 ^c
 )
 )
 (if (= (strcase blkname T) "d-size")
(command "LAYOUT"	   "T"		"BBraun D-Size-2005.dwt"
  "*"	   "-PSETUPIN"	  "BBRAUN D-SIZE-2005.DWT"
  "*"	   ^c		^c
  ^c		^c
 )
 )
 (if (= (strcase blkname T) "cp-size")
(command "LAYOUT"	 "T"	 "BBraun CP-Size.dwt"
  "*"	 "-PSETUPIN"	"BBRAUN CP-SIZE.DWT"
  "*"	 ^c	 ^c
  ^c	  ^c
 )
 )
 (setq index (1+ index))
)
;; *** Deletes the default "Layout1" Tab
(vla-Delete
 (vla-Item (vla-Get-Layouts
   (vla-Get-ActiveDocument (vlax-Get-Acad-Object))
 )
 "Layout1"
 )
)
;; *** Renames Layout Tabs ***
(setq AcdDoc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for Obj (vla-get-layouts AcdDoc)
 (if (wcmatch (setq TmpNme (vla-get-name Obj)) "Layout*")
(vla-put-name Obj (substr TmpNme 7))
 )
)
;; *** Turns on messages ***
(setvar "cmdecho" oldcmdecho)
(princ)

Posted

This is where your template is specified:

 

(command "LAYOUT" "T" "BBraun B-Size-2005.dwt"

"*" "-PSETUPIN" "BBRAUN B-SIZE-2005.DWT"

"*" ^c ^c

^c ^c

)

 

What are the names of your titleblocks and the pagesetups you want to use? This route you're looking at is pretty easy to write. I was thinking more batch processing since you have 2000 drawings.

Posted

the lisp find's te .dwt without file path?

means it' has to be in de the main directory..

 

batch is for when i get this to work.

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