Select lines/objects that are duplicated

Select lines/objects that are duplicated

pallen9JA6T
Enthusiast Enthusiast
9,449 Views
27 Replies
Message 1 of 28

Select lines/objects that are duplicated

pallen9JA6T
Enthusiast
Enthusiast

Hi. I'm looking for a lisp routine that will create a selection of all duplicated objects. Similar to overkill, but instead of deleting, I want it to select them. The reason I want this is that I copied a lot of linework out of an existing drawing and pasted it into a new drawing. I put everything on the same layer so that I could just make it all grayscale except for a few specific things. In hindsight, that was a bad choice. I want to recopy some of the objects on their correct layer, but now I have the duplicate that is on a layer with 800,000 other objects.

0 Likes
Accepted solutions (2)
9,450 Views
27 Replies
Replies (27)
Message 21 of 28

john.uhden
Mentor
Mentor

@cool.stuff ,

This is the first thing to look at:

HIGHLIGHT (System Variable)

Controls object highlighting; does not affect objects selected with grips.

Type:Integer
Saved in:Not-saved
Initial value:1
ValueDescription

0

Turns off object selection highlighting

1

Turns on object selection highlighting

But it's probably ON which is the default.

Anyway, you appear to want a selection set highlighted after some lisp code has processed them.

I would say you have two different options... highlighting vs. cold gripping.

For highlighting a selection set I offer:

 

(defun highlight (ss onoff / i obj)
  ;; where ss is a selection set
  ;; onoff is an integer, 0 for OFF and 1 for ON
  (vl-load-com)
  (repeat (setq i (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
    (vla-highlight obj onoff)
  )
  (princ)
)

 

For cold gripping, use:

 

(sssetfirst nil ss)
;; Unless no other action has changed their grip state,
;; (sssetfirst) will turn off the cold grips.

 

John F. Uhden

Message 22 of 28

JamesMaeding
Advisor
Advisor

I did not see anyone mention filtering for bounding box overlap before testing for true overlap.

This "compare all to all" thinking only goes so far, and the n-squared loops thing bites you.

I happen to be very interested in this because a delunay triangulator I use does not like overlapping colinear objects.

I have to filter those out, or at least detect them for troubleshooting.

I commonly have 10k entities to search through, so that would be 100 million loops.

 

You could also look at line angles to filter for things at same angle.

This involves making a lit of the entities and sorting by some property so you skip items that could not be overlapping. I even did a k-d tree for bounding boxes of any entity but that that only helps if you want to know items whose box contains a point. I did that for finding surface triangle under a point but things change when you ask what boxes overlap with another box.

People might suggest a sweep-line approach which is great for all lines, but arcs mess that up (I believe).

I did not get my overlap engine working yet to my satisfaction so interested if others have developed approaches that scale well when number of objects is large.

 

 


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Message 23 of 28

john.uhden
Mentor
Mentor

@JamesMaeding ,

That sounds like repetitious agony to me.

I wonder if @leeminardi 's affinity for vector math would help.

John F. Uhden

0 Likes
Message 24 of 28

JamesMaeding
Advisor
Advisor

@john.uhden 

Interesting, I'll look over his posts.

The whole computational geometry thing is what I should have done as a career, its like designing guided missiles when the opponent has dumb bombs. Its based on simple things too, no calculus or anything beyond jr high math.

I also herd cats for fun on weekends, it can feel about the same sometimes.


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

0 Likes
Message 25 of 28

cool.stuff
Collaborator
Collaborator

Hi @john.uhden  and thank you for your answer!

 

I copied your routine to a file and loaded it but nothing happened.

 

My current problem is this: the routines presented in this link

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-lines-objects-that-are-duplic...

 

I cannot get the duplicated elements, which if I understood correctly are stored in ss1.

 

By the way, the routines that you have provided in this topic I cannot run them because I get and error "; error syntax".

 

Could you help me on any of those, since I am stuck and I could make your previous help work?

 

Many thanks

0 Likes
Message 26 of 28

john.uhden
Mentor
Mentor

@cool.stuff ,

I checked both of my functions and they work perfectly as intended.

The problem seems to be with @Moshe-A 's function where the selection set named ss1 is empty.  Otherwise it would do exactly as you want.

I don't like to mess with others' work, but he should get a copy of this response and hopefully look over his work.

John F. Uhden

Message 27 of 28

cool.stuff
Collaborator
Collaborator

Thanks for your help @john.uhden 🙂

 

Let's hope that @Moshe-A reads this message and can help.

 

Best regards

0 Likes
Message 28 of 28

JamesMaeding
Advisor
Advisor

@cool.stuff 

I can tell you are approaching the lisp language without certain tools.

Lisp is both archaic and super powerful at the same time, and you need some basic debugging skills.

You think you have a specific lisp issue, but you actually have a basics of lisp issue like we all did at some point.

Homework I hope you do as it will make things way less frustrating:

The first thing to know is the VLIDE built into autocad. Its the lisp editor/debugger (Visual Lisp IDE..).

Try running VLIDE and if it asks about the .net one, pick the bottom option and I think you have to reopen acad.

Once the VLIDE is open, open your lisp, and notice its color coded.

Now, double click before a parenthesis, it selects the code to the "end" parenthesis, no matter how far down.

Just that skill is critical as paren matching is critical in lisp.

Next, try selecting a statement like (setq myvar 12.0), right click, and pick Inspect. It spits the result into a little dialog, or shows an error, all right in place. You can even just select a var like myvar and inspect to see its current value.

You can also set a watch on a variable with the right click menu.

Next, try loading your code with Tools->Load Text in Editor.

Close the window that pops up, but read it to see if it gives an error.

That is a test of paren matching, and it loads your code so you can try things in cad.

Next, you can set a break point with F9, before an opening paren.

Then do Tools->load text in editor.

When you try your command in acad, it will start and then jump to the VLIDE and stop at the break point.

Use F8 to step through code and the debug toolbar to step over or out to stop.

You can inspect things while code is stopped.

 

With those skills you can answer most of the things you asked.

I will add that lisp is a language where you make lots of lists.

As you loop through a selection set, you may build a list of entity names you care about.

So making and accessing them with list, cons, append, nth, foreach, and so on are items you will need to know.

Its so easy once you see you can write a statement and inspect the result to test if you did it right.

 

 


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties