TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: divtiply on November 21, 2014, 10:47:44 AM

Title: Convert same geometry to block
Post by: divtiply on November 21, 2014, 10:47:44 AM
There are multiple same geometry entries in the drawing, i.e. two lines cross & circle. Any ideas how to automatically convert them to block inserts?
Title: Re: Convert same geometry to block
Post by: ronjonp on November 21, 2014, 11:18:04 AM
Look for common properties of the items ( radius, length, layer etc.. ). Filter them, insert block @ center point of circle, then delete selection.
Title: Re: Convert same geometry to block
Post by: divtiply on November 21, 2014, 11:35:02 AM
But there can be entities with same properties, but not aligned so to be in the block.
Title: Re: Convert same geometry to block
Post by: CAB on November 21, 2014, 11:57:21 AM
Yes, would require a complex solution but is doable and not fool proof.
Title: Re: Convert same geometry to block
Post by: ronjonp on November 21, 2014, 12:08:31 PM
Post a drawing if you can.
Title: Re: Convert same geometry to block
Post by: divtiply on November 21, 2014, 12:13:28 PM
Let's simplify task to 2D lines only. Any non-geometrical properties are ignored.
So we have lines start & end coords, length & azimuth. How to compare relative positions?
Title: Re: Convert same geometry to block
Post by: danallen on November 21, 2014, 12:20:28 PM
If you could assume the relative entity creation order of the objects is the same, that would help tremendously. Because then you can interate through the database comparing first object to next relative object compared to your original. Use trans to make coordination comparison relative to 0.
Title: Re: Convert same geometry to block
Post by: divtiply on November 21, 2014, 12:22:37 PM
Here is an example - fragment of pile foundation drawing. Drafter copied pile gometry multiple times. I want to have piles as block inserts.

I know how to
pseudocode:
1. ssget geometry to search for (two lines cross & circle)
2. getpoint insertion-point (in this case line intersection / circle center)

What next?
Title: Re: Convert same geometry to block
Post by: Lee Mac on November 21, 2014, 12:27:50 PM
Is the 'pile geometry' on its own layer?
Title: Re: Convert same geometry to block
Post by: divtiply on November 21, 2014, 12:31:24 PM
Is the 'pile geometry' on its own layer?
In this case yes, but I saw a lot of drawings where all entities are on layer `0`.
Title: Re: Convert same geometry to block
Post by: ronjonp on November 21, 2014, 12:53:32 PM
Get a selection of circles then a selection of lines. Iterate through the circles center points looking for lines midpoints that are equal ( maybe fuzz is a percentage of the circle radius ) from the lines selset. If the result is 2 then do your stuff.
Title: Re: Convert same geometry to block
Post by: dgorsman on November 21, 2014, 01:37:24 PM
Generally, there is a need to quantify what "the same" means in concrete terms.  Humans can look at two item and declare them the same without much conscious thought; in order for this to be duplicated in a computer the steps we take internally have to be mapped out in discrete steps.  Remove everything from the drawing except for two such matching instances.  Pretend you are explaining this to somebody very young or simple - how would you explain why they are the same?
Title: Re: Convert same geometry to block
Post by: CAB on November 21, 2014, 01:47:20 PM
Here is an example - fragment of pile foundation drawing. Drafter copied pile gometry multiple times. I want to have piles as block inserts.

I know how to
pseudocode:
1. ssget geometry to search for (two lines cross & circle)
2. getpoint insertion-point (in this case line intersection / circle center)

What next?
Are you trying to get the pline donuts with the two crossing lines?
That could be easy.
ssget closed pline with a known width
Use the center to get the lines of known length.

Title: Re: Convert same geometry to block
Post by: divtiply on November 21, 2014, 02:58:05 PM
I'm tryining to find generalized soulution, not only for lines/circles, but also for lwplines/3dplines/arcs/eclipses/etc.
Title: Re: Convert same geometry to block
Post by: ronjonp on November 21, 2014, 02:59:37 PM
I'm tryining to find generalized soulution, not only for lines/circles, but also for lwplines/3dplines/arcs/eclipses/etc.
The answer will always be dependent on the relationship between the objects and how accurately they were drafted.
Title: Re: Convert same geometry to block
Post by: CAB on November 21, 2014, 03:40:40 PM
Exactly, if you post a sample DWG file someone can see what you are up against.

Are the object a result of a copy & paste? If so they will be less coding needed to detect them.

It may require separate sub-functions for different object types.