See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: Need "just the right .LSP" for labeling areas on groups of closed plines...

  1. #1
    100 Club
    Join Date
    2006-12
    Posts
    106
    Login to Give a bone
    0

    Default Need "just the right .LSP" for labeling areas on groups of closed plines...

    OK, so this is another stab at getting a routine suited to my use... I need to put text labels for areas on closed polylines, one or a group, where the labels are TEXT objects, drawn in the CURRENT text style, size and orientation, in the CURRENT drawing units, 0 places of decimal precision, located at the centroid of the various objects, and on the CURRENT layer. I have tried so many that are just not quite there, use metric meters, use fields, work on some drawings but not others due to some mysterious variable setting, or that sort of thing...

    I have scoured the boards and other online sources; I have tried to adapt those that have come before, but my LISPing is old, my vBasic non-existent, and my brain turns to oatmeal when I get into it...

    I'm hoping one of you brainy people can take pity on the aged, and help me save the TWO live brain cells I have left...

    Thanks in advance!

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,655
    Login to Give a bone
    0

    Default Re: Need "just the right .LSP" for labeling areas on groups of closed plines...

    Lots of area labeling routines out there already. I prefer using fields as they will update if the polyline is modified. The only limitation for fields is the reference to objects is lost when they're copied to another drawing. A link or attachment of a small drawing with a closed polyline with the text label you want for would make it easy.

  3. #3
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    1

    Default Re: Need "just the right .LSP" for labeling areas on groups of closed plines...

    A try with this?
    Code:
    (vl-load-com)
    (defun c:surf_poly-closed ( / js nb ent dxf_ent ptlst n pt_ins val_txt)
    	(princ "\nSelect closed polylines")
    	(setq js
    		(ssget 
    			(list
    				'(0 . "*POLYLINE")
    				'(-4 . "<AND")
    					'(-4 . "<NOT")
    						'(-4 . "&")
    						'(70 . 120)
    					'(-4 . "NOT>")
    					'(-4 . "&")
    					'(70 . 1)
    				'(-4 . "AND>")
    				(cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
    				(cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
    			)
    		)
    	)
    	(cond
    		(js
    			(repeat (setq nb (sslength js))
    				(setq
    					ent (ssname js (setq nb (1- nb)))
    					dxf_ent (entget ent)
    					ptlst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) dxf_ent))
    					n (float (length ptlst))
    					pt_ins (list (/ (apply '+ (mapcar 'car ptlst)) n) (/ (apply '+ (mapcar 'cadr ptlst)) n))
    					val_txt (rtos (vlax-get-property (vlax-ename->vla-object ent) "Area") 2 0)
    				)
    				(entmake
    					(list
    						'(0 . "TEXT")
    						'(100 . "AcDbEntity")
    						(cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
    						(cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
    						(cons 8 (getvar "CLAYER"))
    						'(100 . "AcDbText")
    						(cons 10 pt_ins)
    						(cons 40 (getvar "TEXTSIZE"))
    						(cons 1 val_txt)
    						(cons 50 (+ pi (angle '(0 0 0) (getvar "UCSYDIR"))))
    						'(41 . 1.0)
    						'(51 . 0.0)
    						(cons 7 (getvar "TEXTSTYLE"))
    						'(71 . 0)
    						'(72 . 1)
    						(cons 11 pt_ins)
    						(cons 210  (trans '(0 0 1) 1 0 T))
    						'(100 . "AcDbText")
    						'(73 . 2)
    					)
    				)
    			)
    		)
    	)
    	(prin1)
    )
    Last edited by Bruno.Valsecchi; 2019-03-09 at 10:46 AM.

  4. #4
    100 Club
    Join Date
    2006-12
    Posts
    106
    Login to Give a bone
    0

    Default Re: Need "just the right .LSP" for labeling areas on groups of closed plines...

    Quote Originally Posted by Bruno.Valsecchi View Post
    A try with this?
    Hi Bruno... Your routine still gives results in square meters, rather than current drawing units (in this case, decimal with 0 places of precision) and at WCS orientation, instead of current settings. Is there a fix?

    Thanks

  5. #5
    100 Club
    Join Date
    2006-12
    Posts
    106
    Login to Give a bone
    0

    Default Re: Need "just the right .LSP" for labeling areas on groups of closed plines...

    Quote Originally Posted by Tom Beauford View Post
    Lots of area labeling routines out there already. I prefer using fields as they will update if the polyline is modified. The only limitation for fields is the reference to objects is lost when they're copied to another drawing. A link or attachment of a small drawing with a closed polyline with the text label you want for would make it easy.
    Hi Tom... Yep, I've tried a bunch of them, but there's always SOMETHING... Ordinarily, using fields as opposed to text would make sense, but in my case, I often have to run other processes afterwards that would require my converting fields to text first, adding another step. As I don't really change the plines, I really don't benefit from using the fields, so I go for the text instead.

    Here's a look at what I'm wanting... The upper row is what I generally get with what I've tried, and the bottom row is what I'm looking for...

    polytest1.dwg

  6. #6
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Need "just the right .LSP" for labeling areas on groups of closed plines...

    Quote Originally Posted by crbateman View Post
    Hi Bruno... Your routine still gives results in square meters, rather than current drawing units (in this case, decimal with 0 places of precision) and at WCS orientation, instead of current settings. Is there a fix?

    Thanks
    I have edited the code to fix it, try to reload it

  7. #7
    100 Club
    Join Date
    2006-12
    Posts
    106
    Login to Give a bone
    0

    Default Re: Need "just the right .LSP" for labeling areas on groups of closed plines...

    Quote Originally Posted by Bruno.Valsecchi View Post
    I have edited the code to fix it, try to reload it
    YES! This is exactly what I need! Thank you for the BIG time-saver.

  8. #8
    Member
    Join Date
    2013-12
    Posts
    2
    Login to Give a bone
    0

    Default Re: Need "just the right .LSP" for labeling areas on groups of closed plines...

    I have a lisp routine that I got off a forum that could be a start to what you want. Would like some help to understand what I need to do to combine two lisp routines so that it fills multiple fields into a block. you can extract the information from the blocks.
    draw a closed pline.
    insert roomtag.dwg
    load areatag.lsp
    type areatag
    choose pline
    choose tag box
    regen

    need help though with filling multiple fields with one selection.
    Attached Files Attached Files

Similar Threads

  1. Replies: 10
    Last Post: 2010-03-11, 12:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •