Jump to content

Help needed to modify lisp for inserting area text inside polylines


Recommended Posts

Posted

Hello, I am using the lisp below (written by chatgpt based on my requests) to add a text showing polyline area inside selected polylines. It works well. The polylines are selected one by one or by window. Now, for another application, I want to modify this code so I can select the areas to add the text (area) by clicking inside them instead of selecting them as objects. I suppose it should do a boundary, add the text with it's area and then delete (or not) the resulted polyline. Please note that I am using progecad (intellicad platform) so some functions may not work though the majority of them do. Somehow chatgpt was not able to help with this modification :))

Thanks in advance!

PLA.lsp

Posted
1 hour ago, Radu Iordache said:

Hello, I am using the lisp below (written by chatgpt based on my requests) to add a text showing polyline area inside selected polylines. It works well. The polylines are selected one by one or by window. Now, for another application, I want to modify this code so I can select the areas to add the text (area) by clicking inside them instead of selecting them as objects. I suppose it should do a boundary, add the text with it's area and then delete (or not) the resulted polyline. Please note that I am using progecad (intellicad platform) so some functions may not work though the majority of them do. Somehow chatgpt was not able to help with this modification :))

Thanks in advance!

PLA.lsp 1.33 kB · 1 download

@Radu Iordache Please upload your sample.dwg

Posted (edited)

Your answer is BPOLY throw that at Chatgp. Would like to see what is returned.

 

Was the code provided edited or is it as created interested to see how good chatgp is.

Edited by BIGAL
Posted
12 hours ago, BIGAL said:

Your answer is BPOLY throw that at Chatgp. Would like to see what is returned.

 

Was the code provided edited or is it as created interested to see how good chatgp is.

It is as created. However, I asked for each step. for example: create a lisp that writes areas of selected polylines as text. then I asked to cut the decimals to 0, then to put the text in the center of the polyline, then to ask for the user input for text height, etc. Each step at a time.

I tried to tell him about bpoly, he does not manage to change the lisp, no versions are working I am no lisp programmer to be able to check. That's why I turned to you guys, maybe someone could help.

Posted (edited)

Doesn't bpoly throw up a dialogue box?

 

i'd be tempted to do it hatch and no dialogue box, this should give the boundary. Noting there is no checking that a valid boundary is selected, no warnings either. Note also below will select any entity as the hatch boundary, lines, polyline, circles..... not just polylines

 

If it was me I would use the selected point, pt, as the text entry point, just fewer clicks, or as above using the geometric centre of the area.

 

(defun c:test ( / pt tempent Boundaryent) ;; Draw a boundary
  (setq pt (getpoint "Select Internal Point"))
  (command "-hatch" pt "")
  (setq tempent (entlast))
  (command "-hatchedit" (entlast) "b" "p" "")
  (setq Boundaryent (entlast))
  (entdel tempent)
  Boundaryent ; returns the entity name for the boundary, area can be calculated from this and boundaryu deleted later
)

 

Edited by Steven P

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