aridzv Posted May 12 Posted May 12 (edited) Hi. 1. The Current layout name to change is known and stored in "lytname" var. 2. the new layout name is also known and stored in "drwnm" var. I know how to change layout name with command this way: (command "LAYOUT" "_r" lytname drwnm) I tried to do it with vla-put-name this way but failed: (vlax-for x (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object))) (if (= x lytname) (vla-put-Name x drwnm) );if );vlax-for how can I chane the layout name using vla-put-name or entmod? thanks, aridzv. Edited May 12 by aridzv Quote
GLAVCVS Posted May 12 Posted May 12 Try changing (if (= x lytname) to (if (= (vla-get-name x) lytname) 1 Quote
Saxlle Posted May 12 Posted May 12 (edited) If you want to use entmod, you need the following: ;; Example (setq ent (car (entsel)) ;; select entity polyline, circle, arc, etc. data (entget ent) ;; get data definition of the selected entity old_layer (cdr (assoc 8 data)) ;; get the name of the layer ) ;; inside the " " you can put the desired name (entmod (subst (cons 8 "new_layer") (cons 8 old_layer) data)) ;; NEW ;; OLD ;; data definition ....... rest of the code...... Edited May 12 by Saxlle Sorry, this is for layer name, not for layout name :D 1 Quote
aridzv Posted May 12 Author Posted May 12 30 minutes ago, GLAVCVS said: Try changing (if (= x lytname) to (if (= (vla-get-name x) lytname) Thanks!! Worked perfect!! Quote
aridzv Posted May 12 Author Posted May 12 And the obvious question: Which of the two (vla-put-name or entmod) is faster?... Quote
Saxlle Posted May 12 Posted May 12 I think that you can't use entmod to change the names of the layouts, because the entmod is meant to use in modifying the definition data of an object (entity). 1 Quote
BIGAL Posted May 12 Posted May 12 Unless you can work at micro second level then you will probably not see any difference between Command, Entmod & VL for this task.. But if you were changing 1000 layouts then one method may be faster than another. Command is the slowest method. 1 Quote
Steven P Posted May 13 Posted May 13 Likewise to add to BigAl, out of all the methods, it is rare that I make a code more efficient to save enough time to go grab a drink. Quote
Saxlle Posted May 13 Posted May 13 Is there somewhere topic about what function is the faster than other function (for e.g. repeat vs while, command vs command-s, etc.)? Quote
Steven P Posted May 13 Posted May 13 Think it was last discussed a couple of years ago, often like here they are hidden in other threads. The consensus being that speed differences only really come into it when you are doing many calculations - into hundreds and thousands - for the user to notice anything. I don't have any links handy to share though. Often though for ease of programming I'll use what I know works, might be a little slower but if it saves me 10 minutes in programming and testing time I can usually run that LISP hundreds of times before any speed difference gains outweigh what I spent to make an easier LISP first off. Quote
Saxlle Posted May 13 Posted May 13 Also, I saw it in some others threads, but don't know where to find it. 6 minutes ago, Steven P said: Often though for ease of programming I'll use what I know works, might be a little slower but if it saves me 10 minutes in programming and testing time I can usually run that LISP hundreds of times before any speed difference gains outweigh what I spent to make an easier LISP first off. Yes, absolutely agree with this. Maybe it would be great if moderators can make a thread where can all usefull things about programming in lisp can found in one place (for e.g. like from my previous post) and make it looks like from picture (like the "Code posting guidelines"). Quote
aridzv Posted May 13 Author Posted May 13 (edited) I've been looking for information about this in the past, and from what I understand, it can be said very generally that: 1. ENTMAKE is the fastest. 2. VLA is slightly behind and almost without difference (if any). 3. COMMAND is the slowest and in my experience it is indeed noticeable,so I try to avoid it as much as possible. aridzv Edited May 13 by aridzv 1 Quote
Saxlle Posted May 13 Posted May 13 Great, thanks. Also, the entmod is one of the function which is too fast for changing the definition data of the entity. Whenever, entmake is great solution for making an entity. The while loop is fast for iterating trough the selection set or similiar situtation. 1 Quote
BIGAL Posted May 13 Posted May 13 Just a real comment, re speed. Manual task do 2000+ changes = 3hrs. 1st go at a program using command = 32 minutes. About 5 go, using VL = 2 minutes. Client was very So if speed is a problem need to look at what your coding just changing to VL or entmake may give improvements, but using defuns and cond v's multi If's can increase speed also. 1 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.