stephen.coff
2007-07-22, 02:51 PM
Guys,
I have routine by Fixo that will allow you to select a polyline and display it's area. I have altered it some what to place the area on a particular layer and style. I want it to be able to select multiple polylines and label each one selcted with a number ie "Zone 1" Zone 2" etc. I think I have it correct so it will count out the zones. How ever, I want to get the "WHILE" function to work with "ENTER" after a polyline selection to be the condition to exit the "WHILE" function.
Unother words, while you keep selecting polylines it will keep running and label the next polylines as a zone number higher than the previous. When the enter button is pressed after selecting the polyline the routine will end.
See below for the routine as it stands:
;;; Altered ARL.lsp by FIXO (AUGI) 22.07.07
(defun c:Atxt (/ ent adoc acsp obj mtx myNum)
(vl-load-com)
(if (= (getvar "USERI1") 0)
(setvar "USERI1" 1)
(progn
(setvar "USERI1" 1)
(alert "\n USERI1 Has Been Reset To: 1 ")
)
)
(setq oldunits (getvar "insunits"))
(command "-layer" "m" "-M-AREA" "C" "20"
"-M-AREA" "Lt" "DASHED2" "-M-AREA" "p"
"n" "-M-AREA" ""
)
(command "_style" "AREA" "arial" "500" "1" "0" "n" "n")
(or adoc
(setq adoc (vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(or acsp
(setq acsp (vla-get-modelspace
adoc
)
)
)
(while
(setq ent
(entsel
"\nSelect The Polyline You Wish To Calculate Area For (ENTER to exit): "
)
)
(setq obj (vlax-ename->vla-object (car ent)))
(if (wcmatch (vla-get-objectname obj) "*Polyline")
(progn
(setq myNum (getvar "USERI1"))
(setq cpt (getpoint "\PICK LOCATION FOR AREA TEXT"))
(setq pt1 (mapcar '+ cpt (list 0 175 0)))
(setq pt2 (mapcar '+ cpt (list 0 -175 0)))
(setq txt1 (strcat "Zone " myNum))
(command "_text" "style" "area" "justify" "bc" pt1 "0" txt1)
;;: Displayed In Meters To 1 Decimal Place.
(setq newunits (setvar "insunits" 4))
(setq
txt2 (strcat "%<\\AcObjProp Object (%<\\_ObjId "
(itoa (vlax-get obj 'ObjectID))
">%).Area \\f \"%lu6%qf1%ct8%pr1[1e-006]\">%"
)
)
(alert "THIS IS NOT A POLYLINE")
)
)
(command "_text" "style" "area" "justify" "Tc" pt1 "0" txt2)
(vla-regen adoc acallviewports)
(setvar "USERI1" (+ myNum 1))
(setq myNum (itoa myNum))
)
(setvar "insunits" oldunits)
(setvar "USERI1" 0)
(princ)
)
I have routine by Fixo that will allow you to select a polyline and display it's area. I have altered it some what to place the area on a particular layer and style. I want it to be able to select multiple polylines and label each one selcted with a number ie "Zone 1" Zone 2" etc. I think I have it correct so it will count out the zones. How ever, I want to get the "WHILE" function to work with "ENTER" after a polyline selection to be the condition to exit the "WHILE" function.
Unother words, while you keep selecting polylines it will keep running and label the next polylines as a zone number higher than the previous. When the enter button is pressed after selecting the polyline the routine will end.
See below for the routine as it stands:
;;; Altered ARL.lsp by FIXO (AUGI) 22.07.07
(defun c:Atxt (/ ent adoc acsp obj mtx myNum)
(vl-load-com)
(if (= (getvar "USERI1") 0)
(setvar "USERI1" 1)
(progn
(setvar "USERI1" 1)
(alert "\n USERI1 Has Been Reset To: 1 ")
)
)
(setq oldunits (getvar "insunits"))
(command "-layer" "m" "-M-AREA" "C" "20"
"-M-AREA" "Lt" "DASHED2" "-M-AREA" "p"
"n" "-M-AREA" ""
)
(command "_style" "AREA" "arial" "500" "1" "0" "n" "n")
(or adoc
(setq adoc (vla-get-activedocument
(vlax-get-acad-object)
)
)
)
(or acsp
(setq acsp (vla-get-modelspace
adoc
)
)
)
(while
(setq ent
(entsel
"\nSelect The Polyline You Wish To Calculate Area For (ENTER to exit): "
)
)
(setq obj (vlax-ename->vla-object (car ent)))
(if (wcmatch (vla-get-objectname obj) "*Polyline")
(progn
(setq myNum (getvar "USERI1"))
(setq cpt (getpoint "\PICK LOCATION FOR AREA TEXT"))
(setq pt1 (mapcar '+ cpt (list 0 175 0)))
(setq pt2 (mapcar '+ cpt (list 0 -175 0)))
(setq txt1 (strcat "Zone " myNum))
(command "_text" "style" "area" "justify" "bc" pt1 "0" txt1)
;;: Displayed In Meters To 1 Decimal Place.
(setq newunits (setvar "insunits" 4))
(setq
txt2 (strcat "%<\\AcObjProp Object (%<\\_ObjId "
(itoa (vlax-get obj 'ObjectID))
">%).Area \\f \"%lu6%qf1%ct8%pr1[1e-006]\">%"
)
)
(alert "THIS IS NOT A POLYLINE")
)
)
(command "_text" "style" "area" "justify" "Tc" pt1 "0" txt2)
(vla-regen adoc acallviewports)
(setvar "USERI1" (+ myNum 1))
(setq myNum (itoa myNum))
)
(setvar "insunits" oldunits)
(setvar "USERI1" 0)
(princ)
)