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

Dyn Block Updating Attributes from Polyline Length/Area

1 REPLY 1
Reply
Message 1 of 2
cmer
1013 Views, 1 Reply

Dyn Block Updating Attributes from Polyline Length/Area

Hi everyone,

 

currently I'm connecting a polyline to a dynamic block (by ID), read the area of that line and write that to a field (It's a room tag /w automatic area field). The code I did not write myself but picked it up on the web (unfortunately can't remember where, so can't give credit).

 

Now I would like to as well write the perimeter of that polyline to another field and at the same time ideally check, if the polyline is closed.

 

It'd be great if anyone could help out, I still find it quite hard to understand LISP code.

 

Any hints are appreciated.

 

Best

C

 

[code]
 (defun C:linktoblock ( / pline tagblock attribute e d attobj plineobj)
 	(setq pline (car (entsel "\nPolylinie waehlen: ")))
 	(setq tagblock (car (entsel "\nRaumstempel waehlen: ")))
 	(setq e (entnext tagblock))
 	
	(while (and (not attribute)	(/= "SEQEND" (cdr (assoc 0 (setq d (entget e))))))
 		
	(if (eq "AREA" (cdr (assoc 2 d)))
 	(setq attribute e)
	)
 	
	(setq e (entnext e))
 	)
 
	(if attribute
 	(progn
 		(setq attobj (vlax-ename->vla-object attribute))
 		(setq plineobj (vlax-ename->vla-object pline))
 		(setq plineid (vla-get-objectid plineobj))

	 (vla-put-textstring attobj
 
	(strcat 
 	"%<\\AcObjProp.16.2 Object(%<\\_ObjId "
 	(itoa plineid)
 	">%).Area \\f \"%lu2%pr2%ps[A= , m²]%ds44%zs8%th46\">%"
 	)
	)
 
	(vlax-release-object attobj)
	(vlax-release-object plineobj)

	)
	)
(princ)
)
[/code]

 

1 REPLY 1
Message 2 of 2
paullimapa
in reply to: cmer

Doing a search on the web will get you lots of info on this subject. To help you get started:

 

To read up on how to check if pline is closed:

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/polyline-not-closed-is-there-an-indic...

The key is this function:

(vlax-curve-isClosed entityname)

 

To read up on getting the perimter:

http://www.autolisp.com/forum/threads/590-Perimeter-and-area-calculation

The key is this function:

(vla-get-Length (vlax-ename->vla-object entityname))

 

 

Area Object Link-Exchange App Store | Dwg Setup-Exchange App Store | Feet-Inch Calculator-Exchange App Store

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

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

Post to forums  

Autodesk Design & Make Report

”Boost