Jump to content

Lisp for pulling intersection data from two lines inside a block


Darksaber501st

Recommended Posts

Hi! (First post, probably not the last).

 

 

I'm currently working on a piece of code for use in AutoCAD 2013 that will save me a bunch of time, but I've hit a snag and I'm not yet proficient enough with LISP to figure this out (I'm very new to both my job and Autodesk products as a whole).

 

 

Basically, what I have is a block containing two intersecting lines (making an "X") and some text, which we use to call out spot grades at locations on our sites. I need to pull the position information for the intersection point between the two lines so that I can feed it in to the rest of my code. Ideally, it would be fantastic if that information could be obtained by just clicking on the block. We currently have to manually identify the point, and it's a pain in sometimes very busy drawings with lots of very close intersections.

 

 

Thanks appreciated, internet cookies in the oven for anyone who can help.

Link to comment
Share on other sites

You're just wanting a lisp to run an I.D. command, or do you want the results of the I.D. command to be made into a text-string that is placed after selecting the point?

Need more info as to what you're requiring :)

Link to comment
Share on other sites

Easy you drew the block so you know the geometry

Just take the insertion point and work out the ID spot distance and angle using Polar all done!

Now for tricky bit but easy again rotate block again geometry answer, your point is alway a fixed radial distance away.

2nd hard part you rescale again simple to work out ID point.

 

ScreenShotblockid.jpg

 

; very simple example nothing smart no checks
(defun AH:blockpt ( / obj blkins)
(setq obj (entsel))
(setq blkins (assoc 10 (entget (car obj))))
; do your bit here (setq newpt (polar blkins ang dist))
)
(AH:blockpt)

Link to comment
Share on other sites

You're just wanting a lisp to run an I.D. command, or do you want the results of the I.D. command to be made into a text-string that is placed after selecting the point?

Need more info as to what you're requiring :)

 

What I need is to be able to click anywhere on the block and have it grab and store the position of the intersection between the two lines inside the block. Once that is stored in some happy variable, I have about a thousand other things to do to those coordinates but that code is already written. The problem is, depending on the geometry and location of the other item in the block (a text string), the insertion point is not always in the same position relative to the intersection of those two lines. I was hoping that blocks somehow stored a record of all the individual objects inside of them, and that there was method to pull such information (such as the start and end points of each line, so I could calculate their intersection) out of the block.

 

Does that make more sense?

Link to comment
Share on other sites

If the intersection point of the two lines is marking the position of a spot grade, then it would be logical for the Insertion point of the block to be at that intersection point.

 

But then some folk see things differently :shock:

Link to comment
Share on other sites

Sooooooooo, I lied about being done with this, and my problem has changed .

 

Attached is a copy of where the LISP is currently at, along with a sample drawing.

 

The short version: This LISP would ideally, when used, let me click on each of two blocks, grab an attribute from those blocks (a text-string, converted to a float), and based on those floats (spot elevations), calculate the elevation change and location of the contours between the two blocks - specifically the distance between the center of the "X" in each block, and then plot the locations of those contours.

 

Where it's currently having problems: The LISP needs to grab as the two comparison points the centerpoints of each X in the block. Instead, it looks like it's grabbing the insertion point of the text in the block. As a result, when it tries to plot the locations of the contours, it's off.

 

Sample file: contains the 8 main variations of this block that we use. It also contains two examples of the final result, the top one showing what this would ideally look like if it worked (done using a much older, far less efficient version of this LISP), and the bottom showing how it currently looks.

 

Help appreciated. It would save me a very, very large amount of time.

 

Incidentally, if someone could also tell me how to use the float that I pull from the text and modify the "Z" position of the block to match the value of that float, I would be even more thrilled.

ELL - Copy.lsp

Sample.dwg

Link to comment
Share on other sites

Did you read what I posted the X is 2 lines it can not move to a new spot within the block it is always relative to the insertion position same with your text ! Disregarding dynamic blocks for moment. If different blocks then just add a list of the rules for the other blocks.

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