Tharwat 发表于 2022-7-5 23:25:29

Replace this .
 

(setq sstri(ssadd (entget sn) sstri))With this.
 

(ssadd sn sstri)
 
And this is enough .
 
and this .

(if (eval ss)
 
With this .

(if ss

joemc 发表于 2022-7-5 23:27:28

With your two changes I get:
 
 
and no lines change color.
 
Below still works:

Command: (colorgray (ssget))
 
I added eval because it seemed to fix an issue that doesn't exist anymore.

joemc 发表于 2022-7-5 23:32:15

Could it be a scope issue?
 
will sstri still exist when used in this context?
 
I would think it is returning the list as a "value"
 
I come more from a C environment.LISP has been something else so far.

joemc 发表于 2022-7-5 23:33:38

Got it to work, but i don't really understand why.I added (eval sstri) at end of function instead of just (sstri).
 

(defun GetMTriangle (/ ss i sn l )( setq sstri (ssadd)) (if (setq ss (ssget "_X" '((0 . "LINE"))))        (repeat (setq i (sslength ss))                (setq sn (ssname ss (setq i (1- i))))                (setq l (distance        (cdr (assoc 10 (entget sn)))                                        (cdr (assoc 11 (entget sn)))                                )                )                (if (or (equal l 0.1876 1e- (equal l 0.1875 1e-4))                        (ssadd sn sstri)                                      )        ))(eval sstri))

Tharwat 发表于 2022-7-5 23:38:19

Explain what you are trying to do to avoid tons of questions and wasting of time .

joemc 发表于 2022-7-5 23:42:10

ColorGray( ss)
Modify color attribute of all entities in a selection set to pen 8
 

(defun GetMTriangle (/ ss i sn l )
Return all lines in drawing of length 0.1876 or 0.1875 asa selection set
 
 
 
My code works.Just didn't understand why you need to use (eval ss) to return selection set instead of just (ss).
 
If I am wasting your time, don't bother.Just trying to learn, maybe I am on the wrong forum.

Tharwat 发表于 2022-7-5 23:44:39

 
What was wrong with my previous post HERE ?
 
Not needed .

joemc 发表于 2022-7-5 23:48:11

I should of started a new thread, because my question is unrelated to the initial thread.I will.My goal is to learn how to return a selection set for more than thisonly purpose. I have got it to work.I think the eval is required because there is an extra set of () around the set.
 
Nothing, code works great and taught me a lot.
 
I disagree I think it is more clear to be able to write code like below even though it is less efficient.Obviously just an opinion.
 

(Color Gray GetMTriangle)(Color Gray GetBendLines)(Color Blue GetWeldMarkers)(Color Blue GetEtchText)
 
Gray = no cutBlue = etchin my CAM software.
 
Thank you for your help.I have read through your other posts and you have a lot of knowledge.

Tharwat 发表于 2022-7-5 23:52:02

 
You're welcome , and hope you understand that when I said to avoid wasting of time in post # 15 , that was to save time for you and to get the best reply when you explain your aim clearly to allow more users to participate with their knowledge as well and nothing's more .
页: 1 [2]
查看完整版本: Selecting a unique object (tri