Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multiple Polyline Area Labels

38 REPLIES 38
SOLVED
Reply
Message 1 of 39
Anonymous
11931 Views, 38 Replies

Multiple Polyline Area Labels

This is probably a really easy thing for lsp, but I don't know it! Smiley Embarassed

 

I have many floorplans and each room has a polyline around it.

 

What I'd like to do, is be able to select multiple (or single) polylines and have a dynamic field with the area attached to each polyline placed in the middle (or on a consistent edge, say top left). Preferably with custom units as we use mm for the drawings, but would want the area in m2. Also custom text heights.

 

Any ideas? I can find a lot of 'put the area in the middle' scripts, but they're either not dynamic or they require a click to place each one - and with over 700 floorplans and over a hundred or more rooms on some, it's not really possible to do each one individually!

 

Thanks for any help!

38 REPLIES 38
Message 21 of 39
Anonymous
in reply to: pbejse

This is very useful and exactly what I was looking for. I don't have much knowledge of lisp but I was wondering if the lisp can be changed to accommodate decimal instead of a comma in the format. I know I'm a little late to the party but any help would be much appreciated.

 

Thanks in advance. 

 

EDIT: Sorry. I figured it out via field expression in Field Edit Dialog box (modified lisp attached). Thanks for such awesome lisp routine.

Message 22 of 39
toomohdi
in reply to: Anonymous

Hi I have same issue and did not get what you did to fix it will you please explain .thanks.


@Anonymous wrote:

It's now saying:

 

'Select objects: 0 found, 0 total
Select objects: 0 found, 0 total
Select objects: 0 found, 0 total'

 

when I say multiple and click on lines?

 

Clare


 

Message 23 of 39
pbejse
in reply to: toomohdi


@toomohdi wrote:

Hi I have same issue and did not get what you did to fix it will you please explain .thanks.


@Anonymous wrote:

It's now saying:

 

'Select objects: 0 found, 0 total
Select objects: 0 found, 0 total
Select objects: 0 found, 0 total'

 

when I say multiple and click on lines?

 

Clare


 


Are you having the same issue as the previous postee [ post 21 ]? decimals and comma? or an entirely different issue? Are you using the code posted at post 21?

 

 

Message 24 of 39
toomohdi
in reply to: pbejse

thanks for replay,
yes I got same :

It's now saying:

 

'Select objects: 0 found, 0 total
Select objects: 0 found, 0 total
Select objects: 0 found, 0 total'






@pbejse wrote:

@toomohdi wrote:

Hi I have same issue and did not get what you did to fix it will you please explain .thanks.


@Anonymous wrote:

It's now saying:

 

'Select objects: 0 found, 0 total
Select objects: 0 found, 0 total
Select objects: 0 found, 0 total'

 

when I say multiple and click on lines?

 

Clare


 


Are you having the same issue as the previous postee [ post 21 ]? decimals and comma? or an entirely different issue? Are you using the code posted at post 21?

 

 


 

Message 25 of 39
pbejse
in reply to: toomohdi


@toomohdi wrote:
thanks for replay,
yes I got same :

It's now saying:

 

'Select objects: 0 found, 0 total
Select objects: 0 found, 0 total
Select objects: 0 found, 0 total' 


Hi toomohdi, 

 

You are getting that message because of the selection filter is exclusive for polylines under layer "A-AREA-BDRY".

 

Either you change layer "A-AREA-BDRY" on the code to some other layer name or put the polylines for selection on aforementioned layer name.  OR

just remove this line from the code. 

 

(8 . "A-AREA-BDRY")

HTH

 

 

Message 26 of 39
F.Camargo
in reply to: pbejse

@pbejse

Very nice code! 🙂

 

How can I set the code to put change the text height and rotate?

 

I'd like to use the text with 1.5 height and 90° rotate as default. 🙂

 

Thanks

Fabrício

Message 27 of 39
pbejse
in reply to: F.Camargo


@F.Camargo wrote:

 

 ...I'd like to use the text with 1.5 height and 90° rotate as default. 🙂

 


 

Replace this

 

...
(vla-put-AttachmentPoint (setq txt (vla-addMText acsp (setq p (vlax-3d-point (mapcar '/ sum (list verts verts)))) 0 StrField)) acAttachmentPointMiddleCenter)
...

To this

(setq txt (vla-addMText
		                  acsp
		                  (setq p (vlax-3d-point
		                                   (mapcar '/ sum
		                                         (list verts
		                                               verts))))
		                  0  StrField))
(mapcar '(lambda (f v) (vlax-put txt f v)) '("AttachmentPoint" "Height" "Rotation") (list 5 1.5 (/ pi 2.0)))

HTH

Message 28 of 39
F.Camargo
in reply to: pbejse


@pbejse wrote:

@F.Camargo wrote:

 

 ...I'd like to use the text with 1.5 height and 90° rotate as default. 🙂

 


 

Replace this

 

...
(vla-put-AttachmentPoint (setq txt (vla-addMText acsp (setq p (vlax-3d-point (mapcar '/ sum (list verts verts)))) 0 StrField)) acAttachmentPointMiddleCenter)
...

To this

(setq txt (vla-addMText
		                  acsp
		                  (setq p (vlax-3d-point
		                                   (mapcar '/ sum
		                                         (list verts
		                                               verts))))
		                  0  StrField))
(mapcar '(lambda (f v) (vlax-put txt f v)) '("AttachmentPoint" "Height" "Rotation") (list 5 1.5 (/ pi 2.0)))

HTH


Thank you very much @pbejse

 

Now I know how to change the properties of the text.Smiley Happy

 

 

Fabrício

Message 29 of 39
F.Camargo
in reply to: pbejse


@pbejse wrote:

@F.Camargo wrote:

 

 ...I'd like to use the text with 1.5 height and 90° rotate as default. 🙂

 


 

Replace this

 

...
(vla-put-AttachmentPoint (setq txt (vla-addMText acsp (setq p (vlax-3d-point (mapcar '/ sum (list verts verts)))) 0 StrField)) acAttachmentPointMiddleCenter)
...

To this

(setq txt (vla-addMText
		                  acsp
		                  (setq p (vlax-3d-point
		                                   (mapcar '/ sum
		                                         (list verts
		                                               verts))))
		                  0  StrField))
(mapcar '(lambda (f v) (vlax-put txt f v)) '("AttachmentPoint" "Height" "Rotation") (list 5 1.5 (/ pi 2.0)))

HTH


Now I know how to change the properties of the text.

 

Thank you very much.Smiley Happy

Message 30 of 39
toomohdi
in reply to: pbejse


@pbejse wrote:

@toomohdi wrote:
thanks for replay,
yes I got same :

It's now saying:

 

'Select objects: 0 found, 0 total
Select objects: 0 found, 0 total
Select objects: 0 found, 0 total' 


Hi toomohdi, 

 

You are getting that message because of the selection filter is exclusive for polylines under layer "A-AREA-BDRY".

 

Either you change layer "A-AREA-BDRY" on the code to some other layer name or put the polylines for selection on aforementioned layer name.  OR

just remove this line from the code. 

 

(8 . "A-AREA-BDRY")

HTH

 

 


Thanks, appreciate it.

Message 31 of 39
toomohdi
in reply to: pbejse

is it possible to upgrade the lisp to able label all poly lines and calculate area and X,Y,Z and send it to excel or in a table in cad file.

Message 32 of 39
rebeccac
in reply to: pbejse

@pbejse Hello there.  I was wondering if anyone is still following this post?  This lisp appears to be exactly what I'm looking for, however, it's not adding any labels.  I loaded the lisp without making any changes, put my "boxes" to test it out on the correct layer, and run the command.  When it asks if I want to process all polylines, I say yes.  Then the command exits and nothing has happened.  Could you provide any insight? Thanks.

Message 33 of 39
CodeDing
in reply to: rebeccac

@rebeccac , 

 

Can you Copy/Paste what your command line history says when you run the command?

 

Best,

~DD

~DD
Senior CAD Tech & AI Specialist
Need AutoLisp help? Try my custom GPT 'AutoLISP Ace':
https://chat.openai.com/g/g-Zt0xFNpOH-autolisp-ace
Message 34 of 39
rebeccac
in reply to: CodeDing

It actually doesn't say anything.

2019-07-01_1744.png

It just exits the command, and goes back to the command line prompt.\

Message 35 of 39
Kent1Cooper
in reply to: rebeccac


@rebeccac wrote:

It actually doesn't say anything.

2019-07-01_1744.png

It just exits the command, and goes back to the command line prompt.\


 

Are your "boxes" in fact closed Polylines?  That is, not built of [for example] Lines?  Are they not on the specific Layer that the routine is written for [see Message 25]?

Kent Cooper, AIA
Message 36 of 39
Anonymous
in reply to: Kent1Cooper

Is it possible to create a similar function but which considers the area of ​​all the hatch instead of all the polylines?

Message 37 of 39
pbejse
in reply to: rebeccac


@rebeccac wrote:

I loaded the lisp without making any changes, put my "boxes" to test it out on the correct layer, 


 

What they said. 🙂

 

Did you at least get this message  "0 Objects found" at the command prompt after nothing has happened?

 

The program is targetting a specific layer name and the object type Polyline/Lwpolyline and the objects are on Model space

 

 

(setq ss (ssget (progn
                                      (initget 1 "Y N")
                                      (setq ans (getkword "\nProcess All Polylines [Yes/No]: "))
                                      (if (eq "Y" ans) "_X" ":L"))
                                             '((0 . "*POLYLINE")
                        (8 . "A-AREA-BDRY")
                        (-4 . "&")
                        (70 . 1)(410 . "Model"))))

 

If these conditions are met then the MText will appear. 

OR the MTEXT is too tiny to see Smiley Indifferent

 

Paste this on the command prompt right after the running the lisp

 

(sssetfirst nil (ssget "_X" '((0 . "MTEXT")(1 . "*m²")(410 . "Model"))))

IT should highlight the created MTEXT. if YES, change the TEXTSIZE variable to the desired text height

 

And yes, the objects might not be a closed polyline.

 

 

Message 38 of 39
rebeccac
in reply to: Kent1Cooper

I just realized I made the layer name BNDY not BDRY.  Ai yi yi!! Sorry for the unnecessary question. 

*EDIT* I'm also trying to make this read square feet to the whole number with "SF NET" on the end.  For some reason, it's just now returning ####.

Message 39 of 39
MSmithPEC
in reply to: pbejse

is there a way to add a second line in the same Mtext that shows acres?

delete me.JPG

I tried this line but it didn't work.

 

">%).Area \\f \"%lu2%pr2%ps[, SF]%th44\">%/p>%).Area \\f \"%lu2%pr2%ps[, AC]%ct8[2.295684113865930E-005]%th44">%"

 

 

*For now my workaround is running two lisps (PolyAreaSF & PolyAreaAC).  After running SF, move those to different layer, run AC then select similar on the AC mtext layer & move all the AC mtext down slightly..

 

Any tips would be appreciated.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report