Jump to content

Recommended Posts

Posted

Hi..Everyone.

I need help again. I have a lisp code for create layouts automatically.

I have a rectangle attribute block. First I insert the block in model space then run the lisp.

This lisp creates a layouts according to block insertion point.

Layouts creates properly but it creates reverse order

For ex.. I have insert 3 blocks and layouts should be creates like A01,A02,A03, but its create like reverse order (A03,A02,A01)

I want to layout create like A01,A02,A03…etc.

Someone help me.

(defun c:Aplan()
(vl-load-com)
(vlax-for layout (vla-get-layouts
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(if (/= (vla-get-name layout) "Model")
(vla-delete layout)
)
)
(command "filedia" "1")
(setq ss (ssget "X" '((2 . "A3") (66 . 1))))
(setq no_of_blocks(sslength ss))
(setq test 0)
(while (< test no_of_blocks)
(setq ent(ssname SS test))
(setq enx (entget (setq blk (entnext ent))))
(Setq entp (entget ent))
(setq inspoint (item 10 entp))
(setq vname (item 1 enx))
(print (type vname))
(command "tilemode" "1")
(command "-view" "w" vname inspoint "@396.0000,204.6493")
(command "_layout" "template" "C:/User/Desktop/Template.dwg" "A3")
(command "_layout" "set" "A3")
(command "_layout" "rename" "A3" (strcat "A" vname ""))
(command "mspace" "-view" "r" vname )(command "pspace")
(command "-view" "d" vname)
(setq test (1+ test))
)
(terpri)
(command "layout" "d" "layout1")
(command "layout" "d" "layout2")
(command "regenall")
)

(Defun ITEM (N E) (CDR (Assoc N E)))

A3.dwg[/ATTACH]

Template.dwg

Posted (edited)

Look at this method it works in reverse for the selection set

 

(repeat (setq x (sslength ss))
(setq ent (ssname SS (setq (setq x (- x 1))))) this will get to 0 item

Edited by SLW210

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