Select and highlight lines

Select and highlight lines

carlos_m_gil_p
Advocate Advocate
219 Views
6 Replies
Message 1 of 7

Select and highlight lines

carlos_m_gil_p
Advocate
Advocate

Hi guys, how have you been?

I ask for your help for a filter solution with ssget.

I want to select a number of lines on the screen using ssget.
But I need to filter it by some xdata values.
And I don't know how to work with xdata, and that's where I don't understand how to create the filter.

 

For example:
The lines I need to select contain this data:
(-3 (Autor (1000 . Name = Link1) (1000 . Maintain = Length) (1000 . Original Length = 2) (1000 . Stiffness = 10F)))

 

I need it to take two into account when selecting.


This one doesn't change.
(1000 . Maintain = Length)


And this one can change the numeric value, but the letter F doesn't.
(1000 . Stiffness = 10F)

 

I attach a dwg where I am doing the tests.

If you can help me, I'd appreciate it.

 


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
220 Views
6 Replies
Replies (6)
Message 2 of 7

Moshe-A
Mentor
Mentor

@carlos_m_gil_p  hi,

 

Are you aware that your xdata is wrong built?

 

here an example of one selected line:

(-3 ("Autor" (1000 . "Name = Link1) (1000 . Maintain = Length) (1000 . Original Length = 2) (1000 . Stiffness = 10F"))))

 

the xdata stored here stores only one dxf1000 string

(1000 . "Name = Link1....................................Stiffness = 10F")

 

and i assume you are expecting 4 strings?!

 

Moshe

 

Message 3 of 7

komondormrex
Mentor
Mentor

hey,

check this one

(defun c:filter_line (/ lines_filtered_sset)
  (setq lines_filtered_sset (ssadd))
  (foreach line (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "X" '((0 . "line") (-3 ("Autor")))))))
    (if (and (wcmatch (setq a_la_xdata (vl-princ-to-string (assoc -3 (entget line '("Autor"))))) "*1000 . Maintain = Length*")
	     (wcmatch a_la_xdata "*1000 . Stiffness = *F*")
        )
        (setq lines_filtered_sset (ssadd line lines_filtered_sset))
    )
  )
  (sssetfirst nil lines_filtered_sset)
  (princ) 
)

 

Message 4 of 7

carlos_m_gil_p
Advocate
Advocate

Hi @Moshe-A thanks for your reply.
I think there's something strange, but I'm not the one doing it. As I mentioned, I don't know how to work with Xdata.
I'll have to start looking into it.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 5 of 7

carlos_m_gil_p
Advocate
Advocate

Hi @komondormrex thanks for the help too.
The function works perfectly.
I'm not accepting it as a solution because I don't know if the thread will be closed.
But I will.
I wanted to ask you another favor.
Could you modify it to create another function that selects the other opposing lines?
In this case (1000 . Stiffness = 10), it doesn't use letters, just a numeric value; it can be real or integer.
Thanks in advance.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 6 of 7

Moshe-A
Mentor
Mentor

@carlos_m_gil_p hi,

 

Can you share what is your goal here? after you select the lines, what do you do with them?

do you modify them in any way? 

does the way this xdata is written interfere you in anyway?

 

anyway (ssget) filter does not support xdata dxf codes.

 

post some code if you can?!

 

Moshe

 

  

0 Likes
Message 7 of 7

komondormrex
Mentor
Mentor

sure. but keep in mind that will work on that wrong xdata only. if somehow the xdata will be attached correctly, the routines should be rewritten. 

(defun c:filter_not_F_line (/ lines_filtered_sset)
  (setq lines_filtered_sset (ssadd))
  (foreach line (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "X" '((0 . "line") (-3 ("Autor")))))))
    (if (and (wcmatch (setq a_la_xdata (vl-princ-to-string (assoc -3 (entget line '("Autor"))))) "*1000 . Maintain = Length*")
          (not (wcmatch a_la_xdata "*1000 . Stiffness = *F*"))
        )
        (setq lines_filtered_sset (ssadd line lines_filtered_sset))
    )
  )
  (sssetfirst nil lines_filtered_sset)
  (princ) 
)

 

0 Likes