Jump to content

Recommended Posts

Posted (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 by aridzv
Posted

Try changing
(if (= x lytname)
to (if (= (vla-get-name x) lytname)

  • Thanks 1
Posted (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 by Saxlle
Sorry, this is for layer name, not for layout name :D
  • Like 1
Posted
30 minutes ago, GLAVCVS said:

Try changing
(if (= x lytname)
to (if (= (vla-get-name x) lytname)

 

Thanks!!

Worked perfect!!

Posted

And the obvious question:

Which of the two (vla-put-name or entmod) is faster?...

Posted

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

  • Like 1
Posted

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.

  • Like 1
Posted

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.

Posted

Is there somewhere topic about what function is the faster than other function (for e.g. repeat vs while, command vs command-s, etc.)?

Posted

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.

Posted

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

 

image.thumb.png.82efd32a9b62d0c5faafa8324af56291.png

Posted (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 by aridzv
  • Like 1
Posted

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.

  • Like 1
Posted

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 :beer:

 

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.

  • Like 1

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