Jump to content

All objects inside this selection want to send layer 0


Dayananda

Recommended Posts

Like this?

(defun c:example ()
   (setq x (ssget '((0 . "LINE,LWPOLYLINE,INSERT,ARC"))))
   (repeat (setq y (sslength x))
     (setq ss (ssname x (setq y (1- y))))
    (command "_.CHANGE" ss "" "_Properties" "_LAyer" "0" ""))
)

 

  • Thanks 1
Link to comment
Share on other sites

@Scoutr4 You don't need to irradiate thought the selection set you just reference it to change them all at the same time.

 

(defun c:example (/ ss)
  (if (setq set1 (ssget "_C" p1 p2))
    (command "_.CHPROP" set1 "" "_LAyer" "0" ""))
    (prompt "\nNothing Selected")
  )
)

 

  • Like 1
  • Agree 1
Link to comment
Share on other sites

more than one way to do anything, above is neater, this is another (useful if you want to change any other properties of the selection)

 

(setq set1 (ssget "_C" p1 p2))
(setq acount 0)
(while (< acount (sslength set1))
  (setq MyEntList (entget (ssname set1 acount)))
  (entmod (subst (cons 8 "0") (assoc 8 MyEntList) MyEntList))
  (entupd (ssname set1 acount))
  (setq acount (+ acount 1))
(princ MyEnt)
)

 

  • Like 1
  • Agree 1
Link to comment
Share on other sites

Yes their is no "wrong" way to do things if it works. But it usually boils down to people arguing over if its the most efficient.

  • Like 1
Link to comment
Share on other sites

It is fractions of a second each way which in a working day you can loose chatting to someone at the coffee machine - if it works, then it works and I reckon that shows you have gone the 'right' way whatever that was.

  • Agree 1
Link to comment
Share on other sites

100% dealing with small selection sets is always negligible. when selection sets get bigger the differences balloons out of control. and people are usually impatient when it comes to commands thinking everything is instant.

I made a command that took a 30+ min process down to sub 30 sec and the person using it thought it didn't work because it was taking too long and would canceled the command and then do it the manual 30+ min way.

and why not if their isn't a progress output how long are you suppose to wait?

 

This is an example of why doing the same task with different code. And was really impressed with my code until i saw the rest of the results.

https://www.cadtutor.net/forum/topic/74035-copy-multiple-text-contents-to-nearest-text-multiples/

 

On 11/21/2021 at 10:02 AM, Isaac26a said:

Well I tested the programs in a much larger scale (about 1550) text for each selection set and the results were

 

ronjonp               0:04.07

Tharwat              0:16.27

Mhupp                1:16.88

Mine  took          2:50:15

  • Like 1
Link to comment
Share on other sites

Quote
25 minutes ago, mhupp said:

why not if their isn't a progress output how long are you suppose to wait?

I think I have seen people using progress bars, although I'd like to know how to use them myself.

I've seen your progress in lisp and you do much better things than when you started posting. You have helped me many times. Thanks

  • Like 1
Link to comment
Share on other sites

Thank you for the kind words.

 

Yeah seen a few also but they output to the command prompt so you get a bunch of spam. i just put in an alert "This process could take up to 1 minute to complete" and then plays a sound with another alert when done.

 

Edited by mhupp
Link to comment
Share on other sites

Progress bars are built in as a Acet command. One example.

 

Moving away from using (command and using (entmake speeds up processing immensly but like mhupp changing 1000+ objects 4 times takes like 2 minutes compared to say 4 hours. Still working on progress bar a cheats way something is happening is (princ x) then add 1 to x so see 12345................

 

;; EXAMPLE LISP SHORT VERSION
(defun c:test(/ progress)
(defun progressbar (a b c d)
(cond ((= 0 a)
(acet-ui-progress-init d 100)
(setq c 0)
)
((= 1 a)
(setq c (+ (/ 100.0 b) c))
(acet-ui-progress-safe c)
)
((= 2 a)
(acet-ui-progress-done)
)
)
c
)
(setq repeatvariable 10000)
(setq progress (Progressbar 0 repeatvariable progress "Processing:")) ;Create the progress bar, total length is repeatvariable or 10000
(repeat repeatvariable
(setq progress (Progressbar 1 repeatvariable progress "")) ;arg (a) is set to 1 and (d) can be blank here
;code to repeat in here
)
(Progressbar 2 0 0 "") ;arg(a) is set to 2 to close the progress bar, arg (b), (c) & (d) can be blanks
)

 

  • Like 3
Link to comment
Share on other sites

Another example, having some fun getting to work correct as inside a complex modify objects 1000+

 

(acet-ui-progress-init "Redoing blocks :" (length lst2))
(setq i 0)

(foreach val lst2

..................................

(setq i (1+ i))
(acet-ui-progress-safe i)
) ; foreach

(acet-ui-progress-done)

 

Link to comment
Share on other sites

On 7/29/2022 at 7:57 PM, BIGAL said:

Progress bars are built in as a Acet command. One example

I'll look into it as soon I have some free time, thank you for your help Bigal, you're always great at helping others. 

Link to comment
Share on other sites

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