Jump to content

Areas to attribute by combining three lisp routines


Recommended Posts

Posted

Hello,

 

Is it possible to combine three routines into one to create area description (block attribute with field)?

step 1 - find polygon centroids

step 2 - replace points with block

step 3 - assign block attribute (area field) to polygon

I assume its a common task and maybe somone has already created similar routine?

I've attached three lisp routines and a test DWG file.

 

Best Regards

 

snap.PNG.62e93d92b9ceefbd0003161e75c6e6c3.PNG

 

1-PolygonsCentroid.lsp 2-Pt2Block.lsp 3-Areas2AttributeV1-2.lsp areas2attribute.dwg

Posted

Why not just copy and paste all 3 into one lisp ? 

 

1 Hint centroid can be 1 line of code using a inbuilt function. 

(setq obj (vlax-ename->vla-object (entlast)))
(setq cpt (osnap (vlax-curve-getStartPoint obj) "gcen"))

 

 2 lot of code for insert block ? Just check does exist if not make it as you only need 1 att. I would remove  (getstring "\nName of block to insert: ") use a hard coded block name so exists in your DWT.

 

3 Lee's code is great but as you know the block that you inserted step 2 just edit the attribute with the field answer no need for a total 3rd program. The answer for the att string is in Lee's code.

 

So the steps

Select all plines making selection set

Loop through selection

Insert block at centroid

Amend block attribute string value to field

Repeat for all plines.

 

Maybe 100 lines of code probably less.

 

I have not posted any code as did you google "label area multiple pline autocad lisp"

 

  • Like 1
  • Agree 2

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