LISP to - Connect line to base point of a block

LISP to - Connect line to base point of a block

nkamphui
Enthusiast Enthusiast
5,848 Views
30 Replies
Message 1 of 31

LISP to - Connect line to base point of a block

nkamphui
Enthusiast
Enthusiast

Hi all,

 

Is there a LISP that connects lines to the base point of a block? See attached pictures.

 

 

0 Likes
Accepted solutions (2)
5,849 Views
30 Replies
Replies (30)
Message 2 of 31

ВeekeeCZ
Consultant
Consultant

Done. 

From the picture called "whatiwant" assuming that you already have it.

 

Please mark my answer as a solution if my answer helped you realize that you already have what you want.

 

 

 

Edit: You need to do a better job with an explanation because your initial attempt says literally nothing.

0 Likes
Message 3 of 31

nkamphui
Enthusiast
Enthusiast

That is what can be done by hand yes.... I would like to have a lisp because i have hundreds of these. 

0 Likes
Message 4 of 31

ВeekeeCZ
Consultant
Consultant

Slightly better now - but how about adding some context?

0 Likes
Message 5 of 31

nkamphui
Enthusiast
Enthusiast

So i have some hundreds of these blocks, which represent swirls, those lines represent pipes. But these lines need to be connected to the exact center of the blocks. They are mostly a few centimeters away. This is a somewhat time consuming job and boring job to do. So a LISP would help me a lot

0 Likes
Message 6 of 31

hak_vz
Advisor
Advisor

@nkamphui wrote:

Hi all,

 

Is there a LISP that connects lines to the base point of a block? See attached pictures.

 

 


Try this

(defun bbp ()(trans (cdr(assoc 10 (entget(car(entsel)))))0 1))

(setq p (bbp))

(bbp)

 

Usage. When asked to enter next point enter (bbp) into console line i.e.

Command: pline
ENTER to use last point/Follow/<Start of polyline>: 
Current Lineweight: 0
Arc/Distance/Follow/Halfwidth/Width/<Next point>: (bbp)
 

 

You   can use option (setq p (bbp)) to store block base point into variable p and use it in cpmmand

Command: (setq p (bbp))
 
Select entity: (573399. 5.08632E+006 0.000000)

 

an then use !p when needed

Command: circle
2Point/3Point/Ttr(tan tan radius)/Arc/Multiple/<Center of circle>: !p
2Point/3Point/Ttr(tan tan radius)/Arc/Multiple/<Center of circle>: (573399. 5.08632E+006 0.000000)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 31

roland.r71
Collaborator
Collaborator

...and how exactly did you have that in mind?

Selecting the line & block to connect to? Might as well do it by hand.

Selecting all the lines and blocks that need connecting? That's a lot of work. Might as well do it by hand.

Select nothing, let the lisp sort it all out for you? That's a whole lot of work, Might as well...

 

0 Likes
Message 8 of 31

ВeekeeCZ
Consultant
Consultant

Great, now we heading somewhere. You need to fix your drawing.

Post some dwg with few examples to get an idea of units, scales... 

 

0 Likes
Message 9 of 31

nkamphui
Enthusiast
Enthusiast

Here is the .dwg with a few of the lines and blocks

0 Likes
Message 10 of 31

ВeekeeCZ
Consultant
Consultant

You're a student?

Have you thought of an algorithm on how such automation should work?

0 Likes
Message 11 of 31

pbejse
Mentor
Mentor

For those "pipe", does it suppose to maintain the same angle as it was before ?

0 Likes
Message 12 of 31

nkamphui
Enthusiast
Enthusiast

Yes that is correct and no i am a noob in algorithms

0 Likes
Message 13 of 31

nkamphui
Enthusiast
Enthusiast

Noo that is not a problem at all. It can be directed differently to be able to align with the base point. 

0 Likes
Message 14 of 31

hak_vz
Advisor
Advisor

Have you tested provided code?

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 15 of 31

pbejse
Mentor
Mentor

Do you see a rainbow after it rains from where you at?

0 Likes
Message 16 of 31

roland.r71
Collaborator
Collaborator

Instead of an algorithm, try to think of a workflow for the lisp... 

 

Easiest would be if you select both the line & block. Get the end or start point from the polyline, whichever is closest to the block, and then "copy" the basepoint coords to the polyline end or start point. Relatively easy to do with lisp, but as i said before, this will bring you nothing as you might as well click the end/startpoint grip and drop it on the basepoint grip, manually.

 

To do all, or a selection (of many) would save you some time and a lot of clicking, but if for just one drawing, it would take more time to write such a lisp, as it would to do it all by hand. (as you would need to get each polylines end or start point and then find the nearest block. Not impossible, but usefull ?

0 Likes
Message 17 of 31

nkamphui
Enthusiast
Enthusiast

Hi, thanks for the reply. I am trying but can't get it to work. I think i am a noob. 

 

Am i supposed to paste the first bit only?

0 Likes
Message 18 of 31

roland.r71
Collaborator
Collaborator

This method will work while drawing, but this is a matter of 'repairing' what's already drawn.

0 Likes
Message 19 of 31

nkamphui
Enthusiast
Enthusiast

The workflow as i would see it is to select all lines and blocks and then executing the lisp which connects the lines based on the end point (which is indeed determined by which is closest to a block). This routine will need to be executed for multiple drawings in the future i guess. But writing a new LISP for it would probably not be worth the time. I was just wondering if anybody already had one or this could be written easily.

0 Likes
Message 20 of 31

nkamphui
Enthusiast
Enthusiast

?

0 Likes