Ideas on how to efficiently trace imported geometry?

Ideas on how to efficiently trace imported geometry?

tpottebaum
Contributor Contributor
1,370 Views
21 Replies
Message 1 of 22

Ideas on how to efficiently trace imported geometry?

tpottebaum
Contributor
Contributor

Hello,

 

Been experimenting with AutoLISP to try and improve the process of tracing imported geometry using AutoCAD LT. For context, we manufacture precast wall panels that typically have 4" sheets of foam insulation in them. We lay these 4' x 8' sheets into the footprint of the panel, but they have a lot of cutouts due to embedded plates that are placed inside them. So, we run each of these sheets through a cnc machine to cut out what we need. Below is what I normally import into AutoCAD. 

 

tpottebaum_0-1735591954323.png

 

The following snip below would be the final product after I manually trace each cutout (in green). The blue rectangles are there for reference to show how each 4'x8' sheet would get laid out in this scenario.

 

tpottebaum_1-1735592303757.png

 

Does anyone have ideas on how I could improve this process? I've been tying to think of an AutoLISP code, but not sure how I could create anything that would be faster than simply tracing. Given it is an imported PDF, I imagine there isn't much to do here... but I thought I'd ask to see if anyone has any creative ideas 😁.  Thanks!

 

0 Likes
Accepted solutions (2)
1,371 Views
21 Replies
Replies (21)
Message 2 of 22

Kent1Cooper
Consultant
Consultant

The blue could be done easily enough with a User Hatch pattern, with its origin set at the left end, assuming the overall isn't more than 8' high [or maybe even if it is].  Is the outer perimeter a single object like a closed Polyline?

 

On the green parts, is there anything in the way they import that can distinguish them from other objects of the same type in the drawing?  And what are they -- Polylines, or made up of individual Lines, or...?  If they're Polylines, and [for example] are the only closed Polylines, or the only ones of more than a certain area, or if there are widths involved that are unique to the different kinds of things, then AutoLisp can find them easily.

 

But if it can, do you then want to convert them to what you show as green, or draw over them as apparently do you manually with the originals remaining, or...?

 

A sample drawing....

Kent Cooper, AIA
0 Likes
Message 3 of 22

ec-cad
Collaborator
Collaborator

Any chance you could get the (original) file that the supplier uses for outputting the .pdf ?

Could they supply say a .dxf instead ?

Is scaling an issue ?

 

ECCAD

0 Likes
Message 4 of 22

tpottebaum
Contributor
Contributor

I only need a better way to do the green as of now. They do come in as polylines but the entire geometry comes in on the same layer. I can't find anything different about those lines in particular. The lines I need come in as open polylines as well.

 

Looks like I can just select each polyline and change it to a new layer and that would work fine. I can't think of any way for Autolisp to identify the lines I need. 

0 Likes
Message 5 of 22

tpottebaum
Contributor
Contributor

We do get .dxf sometimes, but not all suppliers give us those and it typically takes them longer to send them, so I usually start the process using the pdf version.

 

Scaling isn't an issue here. When they do send the .dxf files we can simply turn off the layers we don't need and it leaves us with the cutouts. 

0 Likes
Message 6 of 22

ec-cad
Collaborator
Collaborator

Ok, I get it.

Can you upload a small sample .dwg with the .dxf image included ?

Maybe a Lisp with PEDIT or such will allow you to pick a few lines, and make a Polyline

and put it on a given layer ..

 

ECCAD

0 Likes
Message 7 of 22

tpottebaum
Contributor
Contributor

Here is a .dwg with the imported and scaled pdf. 

0 Likes
Message 8 of 22

ec-cad
Collaborator
Collaborator

Thanks for the drawing.

I see there might be a chance of grabbing those polylines, by their 'Lineweight', and isolating them.

Some have 0.09mm, and others have 0.20mm and another 0.30mm.

If that is an indication of 'what' they are, maybe grab all, make (3) layers with different colors,

and put a copy of the different Lineweights on those layers ?

Shall I try that ?

ECCAD

0 Likes
Message 9 of 22

tpottebaum
Contributor
Contributor

It looks like there are some other lines with that same lineweight. So, while it would quickly narrow down what I need, I think I would still have to do some work to clean it all up. 

 

I think I may be grasping at straws with this one... 

0 Likes
Message 10 of 22

ВeekeeCZ
Consultant
Consultant

I would focus on area. See what I get if I qselect all plines with area 250+ 

That could be done by simple routine... much faster than qs.

 

eekeeCZ_1-1735846779992.png

 

 

 

0 Likes
Message 11 of 22

ec-cad
Collaborator
Collaborator

Initial version. Drag/Drop into your drawing.

Let's go from there.

 

ECCAD

0 Likes
Message 12 of 22

Kent1Cooper
Consultant
Consultant

I was hoping the things you want green would be closed shapes, but they're [mostly] not.  Even the biggest outer-bounds Polyline, though it wraps around to where it starts, is not actually closed in AutoCAD's meaning.  In addition, there are complications like this:

Kent1Cooper_0-1735846489155.png

The upper red outline [as far as it goes] is a single Polyline, but the corresponding lower one is in two pieces, yellow and green.  So looking for certain characteristics might find some things you want and miss others.

 

And yes, I find that the stirrups [if that's the right word] are of the same lineweight as the things you want green, so lineweight is not going to be the distinguishing characteristic.

 

The non-Solid Hatching is done in independent single-segment Polylines -- another good reason to get it in DXF or better yet DWG format if available.  There would presumably be Layer distinctions, which should help.  What is the type of document from which they are generating the PDF's you get?

 

One thing that might be achievable, if it would help, would be to isolate at least all Polylines that contain only orthogonal segments.  That would at least bypass the stirrups and some of the associated parts, and the "stars" [whatever they are], and the screw- or bolt-heads, and hatching pieces.  But it would still catch some things you don't want.  Would such Polylines, but only those with segments no shorter than a certain length, be a reliable distinction?

Kent Cooper, AIA
0 Likes
Message 13 of 22

tpottebaum
Contributor
Contributor

Some suppliers provide DWGs. These have the cutouts in their own layer, so that makes it pretty easy for me. I'm just trying to find a better way of handling this when I don't have the DWGs.

 

The length of segments could help out... Possibly pairing this with the .lsp from @ec-cad could get very close to only having the desired lines left.

 

Was also curious if the number of segments in the polyline could help distinguish as well. A maximum number of segments may not be necessary as that might only be applicable to the stirrups and similar geometries, which would be eliminated by the orthogonal segment criteria. But, the cutouts I need should almost always be at least 3 segments. There are cases when there could be 2, but that's pretty rare, so I feel comfortable taking care of that situation manually if it arises. 

 

 

0 Likes
Message 14 of 22

Kent1Cooper
Consultant
Consultant

@tpottebaum wrote:

.... Was also curious if the number of segments in the polyline could help distinguish as well. .... 


Yes, (ssget) can filter for the number of vertices in a LWPolyline [the DXF 90 entry], even both ways  -- you could have it "see" only those with both more than [let's say] two and fewer than [let's say] 20 vertices.  Look into >relational tests< and >logical groupings<.

Kent Cooper, AIA
0 Likes
Message 15 of 22

ronjonp
Mentor
Mentor
Accepted solution

@tpottebaum Give this a try. The preset values work with your sample drawing

 

(defun c:foo (/ ar b j ll m mn mx pts r s ur )
  ;; RJP » 2025-01-02
  (if (and (or (setq ar (getreal "\nEnter minimum area for cutout:<75>")) (setq ar 75))
	   (or (setq mn (getreal "\nEnter minimum bounding box side length:<1>")) (setq mn 1))
	   (or (setq mx (getreal "\nEnter maximum bounding box side length:<60>")) (setq mx 60))
	   (setq s (ssget '((0 . "LWPOLYLINE"))))
      )
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (cond ((and (> (vlax-curve-getarea e) ar)
		  (setq pts (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget e))))
		  (> (length pts) 3)
		  (setq a (mapcar '(lambda (r j) (rem (angle r j) pi)) pts (cdr pts)))
		  (vl-every '(lambda (x) (or (equal x 0 1E-2) (equal x (/ pi 2) 1E-2))) a)
	     )
	     (vla-getboundingbox (vlax-ename->vla-object e) 'll 'ur)
	     (setq b (mapcar 'abs (mapcar '- (vlax-safearray->list ll) (vlax-safearray->list ur))))
	     ;; Remove walls ( a side less than 1 unit )
	     ;; and remove boundaries ( a side greater than 60 units )
	     (if (and (> (car b) mn) (> (cadr b) mn) (< (car b) mx) (< (cadr b) mx))
	       (entmod (append (entget e) '((8 . "CUTOUT") (62 . 1))))
	     )
	    )
      )
    )
  )
  (princ)
)

 

 

2025-01-02_15-14-18.gif

Message 16 of 22

tpottebaum
Contributor
Contributor

I tested it on one of my PDFs and it worked great! It grabbed all of the polylines I needed and just a few extra. Very easy to just go delete the extras and move on. Thanks!

0 Likes
Message 17 of 22

ronjonp
Mentor
Mentor

Glad to help! 🙂

0 Likes
Message 18 of 22

ec-cad
Collaborator
Collaborator
Accepted solution

Foo is great ronuonp, sweet.

I added a couple of functions to the end.

Function C:CUTS freezes all layers except cut outs. Any key restores. Just a way to quickly see what's

on that layer. You could do Laywalk, but CUTS is a little shorter route.

Function C:ADDCUT  allows selection set to get moved to cut outs layer. Just grab what you want.

Thought they would come  in handy for OP.

 

ECCAD

0 Likes
Message 19 of 22

tpottebaum
Contributor
Contributor

Thanks ECCAD. You're ADDCUT function is what I thought of doing originally. Definitely helpful in cases where a polyline or two got missed so I can quickly add them. Never thought to add your CUTS function too. That's a nice addition. 

 

Thanks!

0 Likes
Message 20 of 22

ec-cad
Collaborator
Collaborator

Thanks,

Anytime 🙂

ECCAD

0 Likes