Jump to content

Insert Block at intersection of polyline which are in two different layers


anupmadhu

Recommended Posts

It can be used for counting no of fittings in irrigation network to calculate no of reducers needed.

ie 1" will be separate layer & 1.5" will be in different layer, by counting the inserted blocks gives us the no 1.5*1" reducer

Link to comment
Share on other sites

Sir,

 

What i wan't is layer selection instead of an object selection, because in an irrigation drawing there will be hundreds of intersection

So just by selecting a layer 1" pipes and layer 1.5" will give me the no reducers needed.

Link to comment
Share on other sites

You need a double loop ie take all 1" lines and make a selection set then take all 1.5" lines and make a selection set, you then loop through the 1" 1 at a time comparing the 2nd selection set for possible intersections and if so do something. Its achievable but I dont have code. Look at what Lee posted maybe as a start hint, INTERSECTWITH obj1 obj2 true or false.

Link to comment
Share on other sites

This is close but I need help its extending plines so extra points instead of only 1 intersect.

 

(defun sprinklers ( / ss1 ss2 x y len1 len2)
(vl-load-com)
(setq obj (entsel "\nPick 1st layer"))
(setq lay1 (vla-get-layer (vlax-ename->vla-object (car obj))))
(setq obj (entsel "\npick 2nd layer"))
(setq lay2 (vla-get-layer (vlax-ename->vla-object (car obj))))
(setq ss1 (ssget "X" (list (cons 8 lay1))))
(setq ss2 (ssget "X" (list (cons 8 lay2))))
(setq len1 (sslength ss1))
(setq len2 (sslength ss2))
(setq x 0
    total 0)
(repeat len1
(setq y 0)
(setq obj1 (vlax-ename->vla-object(ssname ss1 x)))
(repeat len2
(setq obj2 (vlax-ename->vla-object (ssname ss2 y)))
(setq pt (vla-intersectwith obj2 obj1 0))
(if (/= pt nil)(setq total (+ total 1))(Princ "Miss"))
(setq y (+ y 1))
) ; len2
(setq x (+ x 1))
) ; len1
(princ Total)
) ; defun
(sprinklers)

Link to comment
Share on other sites

  • 2 weeks later...

Another work around for this sort of thing is to copy just the layers you need into a separate drawing (along with the block), then run the program. You can then transfer the results back to the original drawing. This way, no more programming is needed.

Link to comment
Share on other sites

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...