Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a Temporary dcl and Page setup

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
1673 Views, 10 Replies

Create a Temporary dcl and Page setup

Hello,

I am working on a Autolisp routine that can setup layout page settings and create viewport and place the drawing in given scale.

attached lisp is a Single sample from a long sequence of pagesizes. (viewport_setup.lsp)

 

What I want:

1. If Pdf-Xchange 4.0 is not available a dialog box will open. (design of dialog box attached)

 

2. Even if Pdf-Xchange 4.0 is available still user can open that dialog box by enter "S" (Settings) with in running command and set the parameters in the dialog box and then continue with the lisp flow (entering scale, then orientation).

 

3. Rename Layout if provided in the dialog box other wise rename as per page size(Default).

 

4. Delete other Layouts will be default, user can change it.

10 REPLIES 10
Message 2 of 11
ronjonp
in reply to: Anonymous

Have a look at using named pagesetups and a combination of plot, sheet set manager and publish.

image.pngimage.png

Message 3 of 11
ronjonp
in reply to: Anonymous

FWIW here are a few comments to the code you posted.

(setq layc (getvar 'clayer))
(command "-layer" "make" "Defpoints" "color" "white" "" "")
(setvar 'clayer layc)




(defun c:3042 (/ ad cmd lay ornt sc tb)	; RJP localized all variables
  (command "undo" "begin")
  ;; RJP Changed initget from 1 to 7 ( number greater than 0  required )
  (initget 7)
  (setq sc (getreal "Enter Drawing Scale:"))
  (setq sc (* 10000 sc))		;for fractionsl scales
  (initget "Portrait Landscape")
  (setq	ornt (cond ((getkword "\nEnter Drawing Orientation[Portrait/Landscape]<Landscape>:"))
		   ("Landscape")
	     )
  )
  (setq cmd (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  (command "-layer" "ON" "Defpoints" "T" "Defpoints" "")
  ;; Faster :)
  (vlax-for tab	(vla-get-layouts (setq ad (vla-get-activedocument (vlax-get-acad-object))))
    (and (> (vla-get-taborder tab) 0) (vla-delete tab))
  )
  ;; (foreach ly (layoutlist) (command "-Layout" "Delete" ""))
  (setvar 'ctab "Model")
;;;  (if (= ornt "Portrait")
;;;    (command "-plot"	 "Yes"	     "Layout1"	 "PDF-XCHANGE 4.0"	 "30x42"     "Inches"
;;;	     "P"	 "NO"	     "Extents"	 "1:1"	     "C"	 "Yes"
;;;	     "monochrome.ctb"	     "Yes"	 "NO"	     "NO"	 "No"	     "N"
;;;	     "Y"	 "N"
;;;	    )
;;;  )
  ;; RJP - only need to change 'L' or 'P'
  (command "-plot"
	   "Yes"
	   "Layout1"
	   "PDF-XCHANGE 4.0"
	   "30x42"
	   "Inches"
	   (if (= ornt "Landscape")
	     "L"
	     "P"
	   )
	   "NO"
	   "Extents"
	   "1:1"
	   "C"
	   "Yes"
	   "monochrome.ctb"
	   "Yes"
	   "NO"
	   "NO"
	   "No"
	   "N"
	   "Y"
	   "N"
  )
  (setq lay (getvar 'clayer))
  (setvar 'clayer "Defpoints")
  ;; Set first ( and only ) tab current
  (setvar 'ctab (car (layoutlist)))
  (command "._erase" (ssget "_X" '((0 . "VIEWPORT"))) "")
  ;; Removed command
  (vlax-for tab (vla-get-layouts ad) (and (> (vla-get-taborder tab) 0) (vla-put-name tab "30x42")))
  ;; (command "-layout" "rename" "layout1" "30x42")
  (command "Mview" "Fit")
  (command "Mspace")
  (command "zoom" "Extents")
  (command "zoom" (strcat "10000/" (rtos sc 2 0) "XP") "")
  (setvar 'psltscale 0)
  (command "Regen")
  (command "pspace")
  (command "Zoom" "Extents")
  (setvar 'clayer lay)
  (command "mview" "lock" "on" (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (69 . 1))) "")
  (command "ctab" "Model")
  (command "zoom" "Extents")
  (command "_qsave")
  (setvar 'ctab (car (layoutlist)))
  (setvar "cmdecho" cmd)
  (command "undo" "e")
  (princ "\nViewport Created")
  (princ)
)					;End
Message 4 of 11
Anonymous
in reply to: ronjonp

@ronjonp  thank you for you comment and corrections... I have updated that lisp as per your suggestion. 

But the pdf with size is not what I am looking for. Some how I need to develop that dialog box with that lisp. Can help me in that issue?

Message 5 of 11
ronjonp
in reply to: Anonymous


@Anonymous wrote:

@ronjonp  thank you for you comment and corrections... I have updated that lisp as per your suggestion. 

But the pdf with size is not what I am looking for. Some how I need to develop that dialog box with that lisp. Can help me in that issue?


Sorry .. creating dialog boxes is not my strong suit.

Message 6 of 11
pbejse
in reply to: Anonymous


@Anonymous wrote:

But the pdf with size is not what I am looking for. Some how I need to develop that dialog box with that lisp. Can help me in that issue?


 

What are the pdf sizes then? HaVe a look at sea.havens post about dcl library  ----> Multiple toggles.lsp 

Tweak it a little so instead of toggle, use it as radio_button

 

sh.PNG

 

HTH

 

 

Message 7 of 11
Anonymous
in reply to: pbejse

Page sizes: 

30x42

24x36

18x24

8.5x11

8.5x14

11x17

17x22

22x34

34x44

 

we generally use pdf xchange 4.0 as default. but if someone doesn't have that then the dialog box should open and ask to choose other pdf driver from available list and page size too.

otherwise user can choose the "Setting" keyword to open the dialog box (see the attached image for the dcl reference).

(exmpl: like in "HATCH" command "seTting" keyword to open the dialog box with in the running command)

Message 8 of 11
Sea-Haven
in reply to: pbejse

Go to cadtutor Downloads there are 4 "MULTI" lisp library dcls "Multi Radio buttons" is one of them, thanks for recommendation.

 

(setq ans  (ah:butts but "V"   '("Choose Page size " "30x42" "24x36" "18x24" "8.5x11" "8.5x14" "11x17" "17x22" "22x34" "34x44")) )

 

screenshot197.png

 

I have updated the lisp as attached will update Cadtutor also changed a couple of items to make better.

Message 9 of 11
Anonymous
in reply to: Sea-Haven

Thank you.

Message 10 of 11
Anonymous
in reply to: Anonymous

I just want the dcl with that lisp file.

Message 11 of 11
Sea-Haven
in reply to: Anonymous

Its a library function just makes a temporary dcl runs it then deletes it can have any amount of buttons subject to screen size I posted example code. There are more examples in the lisp code.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report