Jump to content

Extracting polyline information from multiple blocks.


Recommended Posts

Posted

I have a series of blocks which are being used multiple times in a model. All of the blocks have a polyline within them on the same layer. Is there anyway I can extract the co-ordinates of those polylines?

Posted

If the data is in the drawing, you can always get it out. The question is how. Pick a programming language you're comfortable with, and you should be able to extract at least the insertion point of the blocks.

 

To help you any better, we'd probably need more information. Do these blocks appear with multiple scales and rotations? Do you need the starting vertex or all of them? Where will the data go, and how should it be formatted?

Posted

The Express Tool ncopy copies objects nested inside blocks and external references.  Might be a starting point.

Posted

I've attached an example file that contains the blocks. Within the blocks there are polylines on the layer B_Footprint. What I'd like to do is extract the co-ordinates of the polylines either into a table or a excel sheet or word file. I don't mind which. However they are dynamic blocks and I only want the ones that are visible.

Drawing3.dwg

Posted (edited)

A quick and dirty, copy the block a known amount say +x direction. get bounding box of copy, explode block, use ssget with pline and correct layer then get co-ords subtract -x from all co-ords erase copy.

 

Do what ever next with co-ord.

 

For others the code will fail if you can not "SEE" the copied block. This is one of those Gotcha lisp problems.

 

(defun c:test ( / pt1 pt2 ss x k j  pt plent)
(setq ent  (entsel "select block"))
(setq xoff 250.0)
(command "copy" ent "" "0,0" (list xoff 0.0))
(setq obj (vlax-ename->vla-object (entlast)))
(vla-GetBoundingBox obj 'minpoint 'maxpoint)
(setq pointmin (vlax-safearray->list minpoint))
(setq pointmax (vlax-safearray->list maxpoint))
(command "explode" (entlast) )
(command "zoom" "C" pointmin 80.0)
(setq ss (ssget "w" pointmin pointmax (list (cons 0 "lwpolyline")(cons 8 "B-Footprint"))))
(setq plent (ssname ss 0))
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (j) (= (car j) 10)) (entget plent))))
(setq lst2 '())
(repeat (setq k (length co-ord))
(setq pt (nth (setq k (- k 1)) co-ord))
(setq x (- (car pt) xoff))
(setq lst2 (cons (list x (cadr pt)) lst2))
)
(command "erase" "w" pointmin pointmax "")
(command "zoom" "P")
(alert "points are in lst2")
(princ lst2)
)

 

Edited by BIGAL
Posted (edited)
On 10/30/2019 at 12:15 PM, Bob658 said:

I have a series of blocks which are being used multiple times in a model. All of the blocks have a polyline within them on the same layer. Is there anyway I can extract the co-ordinates of those polylines?

 

A similar question was recently asked (and answered) in this thread.

Edited by Lee Mac
Posted

Hi Lee that is the right way to do it, as I said the quick and dirty way.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...