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

Make a Lisp Rotine to make copy of model tab.

5 REPLIES 5
Reply
Message 1 of 6
fraineman
6047 Views, 5 Replies

Make a Lisp Rotine to make copy of model tab.

If I have multiple drawings on my model tab and I want to make new tabs for page one, page two and so on. I'm very new at making Lisp. Retinues, this was set up for me at my old job and now I want to set it up at my new job so I need to learn how to do Lisp. Retinues. I would really appreciate all the help I can get

5 REPLIES 5
Message 2 of 6
pbejse
in reply to: fraineman


@fraineman wrote:

If I have multiple drawings on my model tab and I want to make new tabs for page one, page two and so on. I'm very new at making Lisp. Retinues, this was set up for me at my old job and now I want to set it up at my new job so I need to learn how to do Lisp. Retinues. I would really appreciate all the help I can get


Welcome to the forum fraineman. Are you wanting to move a portion of the model space entities to a separate layout tabs? sort of layout to model [ExportLayout] but reverse? 

 

Post an example if you will 🙂

 

Cheers

 

Message 3 of 6
fraineman
in reply to: fraineman

(defun c:copytabs (/ numtabs currenttab)
(setq currenttab (getvar "ctab"))

(cond ((= currenttab "Model")
(command "copyclip" "all" "" "layout" "new" "Page1" "layout" "set" "Page1" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
((= currenttab "Page1")
(command "copyclip" "all" "" "layout" "new" "Page2" "layout" "set" "Page2" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
((= currenttab "Page2")
(command "copyclip" "all" "" "layout" "new" "Page3" "layout" "set" "Page3" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
((= currenttab "Page3")
(command "copyclip" "all" "" "layout" "new" "Page4" "layout" "set" "Page4" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
((= currenttab "Page4")
(command "copyclip" "all" "" "layout" "new" "Page5" "layout" "set" "Page5" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
((= currenttab "Page5")
(command "copyclip" "all" "" "layout" "new" "Page6" "layout" "set" "Page6" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
((= currenttab "Page6")
(command "copyclip" "all" "" "layout" "new" "Page7" "layout" "set" "Page7" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
((= currenttab "Page7")
(command "copyclip" "all" "" "layout" "new" "Page8" "layout" "set" "Page8" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
((= currenttab "Page8")
(command "copyclip" "all" "" "layout" "new" "Page9" "layout" "set" "Page9" "pasteclip" "0,0" "zoom" "all" "ZOOM" ".9X" "QSAVE")
)
)
(command "layout" "delete" "layout1")
(command "layout" "delete" "layout2")

 

 

This is what I am trying to do. If I have a Three page drawing on my Model tab I want to Delete the Layout tabs and then copy the Model tabs as many times as there are pages to your drawing, and set the limits of thoughs pages. 

 

(defun c:reset ()
(command "-dimstyle" "" "millimeters")
(if (= (getvar "dimasz") 0) (setvar "dimasz" 0.078))
(command "cmddia" "0")
(command "dimapost" "mm")
(command "filedia" "0")
(command "osnap" "int,end,mid,qua,app")
(command "ortho" "on")
(command "dimtix" "on")
(command "dimtih" "on")
(command "dimtoh" "on")
(command "dimsd1" "off")
(command "dimsd2" "off")
(command "dimse1" "off")
(command "dimse2" "off")
(command "dimassoc" "1")
(command "dimpost" "\"\\P")
(command "dimtmove" "2") ;;ALLOWS MOVING OF DIM TEXT FROM DIMENSION
(command "dimgap" ".02")
(command "filletrad" "0.0")
(command "dimtad" "0")
(command "griddisplay" "2") ;added 11-01-06 for AutoCad2007
;-------------------
;sets limits
(setq lm (getvar "limmax"))
(setq lmin (getvar "limmin"))
(setq lm_c (car lm))
(setq lmin_c (car lmin))
(setq total_lim (- lm_c lmin_c))
(setq newlim (/ total_lim 8.5))
;--------------------
(setq textheight001 (* 0.125 newlim))
(setvar "textsize" textheight001)
(setvar "dimscale" newlim)
(setvar "mleaderscale" newlim)
(setq gridsize001 (* 0.5 newlim))
(command "grid" gridsize001)
(command "-layer" "set" "obj" "")
(command "pellipse" "1")
(command "ucsicon" "off")
(command "zoom" "all")
;may not need this line, i added this to make sure millimeters dimstyle is saved
(command "-dimstyle" "s" "MILLIMETERS" "y")
(command "cmddia" "1")
(command "filedia" "1")
(command "dim" "dimlfac" "1")
(command "exit")
(Command "zoom" "all")
'makes it so dim lines can be selected when dimensioning. i added this for myself
'nobody else seems to have this issues but me. can be taken out if not needed
(command "ampsnapfiltero")
(COMMAND "QSAVE")
(princ)
)

 

As you can see I have the Lisp Routine but it is not working for me I'm using AutoCad 2010.

 

Todd

Message 4 of 6
pbejse
in reply to: fraineman


fraineman wrote"

 

This is what I am trying to do. If I have a Three page drawing on my Model tab I want to Delete the Layout tabs and then copy the Model tabs as many times as there are pages to your drawing, and set the limits of thoughs pages. 

 

Todd


It only took you 3 weeks to post a reply Smiley Happy

 

I think its easy. you only need to explain more on what your wanting to do.

Now, how would you determine the number of "pages"? are these bounded by a Titleblock? Are you wanting to create a viewport on layout tab for each "pages"? 

 

Or " copy the Model tabs" means ALL entities on model and "paste" the "copyclip" to a layout tab , for whatever number of pages then the user will start deleting "stuff" on every layout tab per page?

 

Meaning if 3 pages. copy and paste all entities from model to 3 separate layout tabs?

Message 5 of 6
fraineman
in reply to: fraineman

Sorry about taking so long, Got busy with other stuff. I don't want any Layout tabs, the first thing the Lisp should do is delete both layout tabs, then it should copy the Model tab as many times as you want by just picking the button that you create the number of copys that you want. that is what the copytab Lisp Routine should do. Than the other Button and Lisp Routine is to pick the drawing that you want and deletes the other drawings making your page one only one of the drawings, then do the same for page two and so on.

 

Thanks for all help

Todd

Message 6 of 6
pbejse
in reply to: fraineman


@fraineman wrote:

Sorry about taking so long, Got busy with other stuff. I don't want any Layout tabs, the first thing the Lisp should do is delete both layout tabs,...


I'm gussing you mean the layout tab named "Layout1" "Layout2" .Layout tab is PAPER space tab FYI.

 

Anyhoo. try this quickie

 

(defun c:c2l (/ _CheckName i aDoc LayoutColl MoveToLayout ss ObjToMove)
(vl-load-com)  
(defun _CheckName (n pre / nm)
  (if (member (setq nm (strcat pre (itoa (setq n (1- n))))) (layoutlist))
    (_CheckName n pre)
    nm
  )
)  
  (setq	i	   0
	adoc	   (vla-get-activedocument (vlax-get-acad-object))
	LayoutColl (vla-get-layouts adoc)
  )
  (While (setq
	   MoveToLayout	nil
	   ss		(ssget "_:L")
	 )
		   
    (vlax-for x	(setq ObjToMove (vla-get-activeselectionset aDoc))
      (setq MoveToLayout (cons x MoveToLayout))
    )
    (vla-delete ObjToMove)
		       (vla-add LayoutColl
	     (setq NLNAme (_CheckName i "Page"))
    )
    (vla-CopyObjects
      ADoc
      (vlax-make-variant
	(vlax-safearray-fill
	  (vlax-make-safearray
	    vlax-vbObject
	    (cons 0 (1- (length MoveToLayout)))
	  )
	  MoveToLayout
	)
      )
      (vla-get-block (vla-item LayoutColl NLNAme))
    )
    (foreach O MoveToLayout (vla-delete O))
    (alert (Strcat "\nSelected objects will be move to " NLNAme " tab"))
    
  )
  (foreach nm '("Layout1" "Layout2")
    	(if (member nm (layoutlist))
          	(vla-delete (Vla-item LayoutColl nm))))
(princ)
)

 

HTH

 

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

Post to forums  

”Boost