Isolate a group of objects through their index number?

Isolate a group of objects through their index number?

Anonymous
Not applicable
909 Views
5 Replies
Message 1 of 6

Isolate a group of objects through their index number?

Anonymous
Not applicable

Hi everyone,

 

Could some one tell me how to ISOLATE a group of objects through a list of their index (idxgroup variable in the following code)? 

By the way, welcome all advices to improve this code.

 

Thank you.

 

My code:

 

(defun c:test(/ idxgroup)
  (setq obj1 (ssget))
  (command "_.area" "_o" (ssname obj1 0))
  
  ; area of 1st object
  (setq area (getvar "area"))
  
  ; pick objects to compare their area values to the 1st one
  (setq obj2 (ssget))
  (setq i (sslength obj2))
  
  ; loop
  (repeat i
    (setq idx (1- i))
    (command "_.area" "_o" (ssname obj2 idx))
    
    ; area of the current object
    (setq area2 (getvar "area"))
    (if (= area2 area)
      (progn
	(setq prop (entget (ssname obj2 idx)))
	
	; change color object 
	(setq ed (subst (cons 62 1) (assoc 62 prop) prop))
	(entmod ed)
	
	 ; object's index group that have equal area
	(setq idxgroup (append idxgroup (list idx)))
	
	) ; progn
      ) ; if
    (setq i (1- i))
    ) ; repeat
  (command "isolateobjects" <<need helps>>
  ) ; defun

 

0 Likes
Accepted solutions (1)
910 Views
5 Replies
Replies (5)
Message 2 of 6

hmsilva
Mentor
Mentor

Hi maikhanhmst,

you are creating a list with the index from the second selection set objects with equal area from the first object selected.

 

Do you need the index in a list to do something else with it?

Or your goal is to isolate all selected objects with the same area, or just the selected in the second ssget function?

Which type of objects you want to select?

 

Henrique

 

 

EESignature

0 Likes
Message 3 of 6

Anonymous
Not applicable
Hi Henrique,
Thank for your quick response.
My goal is to isolate the objects with the same area. The index do nothing except that. So with the index group I can isolate separately with loop.
0 Likes
Message 4 of 6

hmsilva
Mentor
Mentor
Accepted solution

@Anonymous wrote:
My goal is to isolate the objects with the same area. The index do nothing except that. So with the index group I can isolate separately with loop.

If your goal is only to see each object a time, perhaps something like this

 

(if idxgroup
    (foreach x idxgroup
      (command "isolateobjects" (ssname x obj2) "")
      (command "delay" 2000)
      (command "unisolate")
      )
    )

 

Hope this helps,
Henrique

EESignature

Message 5 of 6

Anonymous
Not applicable
Many thanks, Henrique.
It works :).
0 Likes
Message 6 of 6

hmsilva
Mentor
Mentor

@Anonymous wrote:
Many thanks, Henrique.
It works :).

You're welcome, maikhanhmst
Glad I could help

Henrique

EESignature

0 Likes