TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jav on September 30, 2006, 10:38:57 PM
-
hello I have this routine:
it is possible to be done that instead of selecting the polilinea in order to label the distance and the azimuth, it requests an inner point within the polygon and with that it labels the distances of each segment that compose to the polygon? not mattering if the polygon were created with polilineas lines or? thanks…
(princ "tDigite azpol p/ara iniciar ")
(defun c:azpol ()
(setvar"cmdecho" 0)
(command "osmode" 0)
(command "angbase" 270)
(command "angdir" 1)
(setq flagv "falso")
(setq controle 0)
(setq controle1 0)
(setq contador 0)
(while (= flagv "falso")
(setq mostre (entsel "nMostre a Polyline <2d> : "))
(setq linha (entget (car mostre )))
(setq verificador (cdr(assoc 0 linha)))
(if (= verificador "LWPOLYLINE")
(progn
(setq verif (cdr (assoc 70 linha)))
(setq flagv "verdade")
)
(princ "tNão é Polyline !! ")
)
)
(setq controle1 (length linha))
(setq amostra '())
(repeat controle1
(setq x (caar linha))
(if (= x 10)
(progn
(setq item (car linha))
(setq amostra (cons item amostra))
(setq contador (1+ contador))
)
)
(setq linha (cdr linha))
)
(setq amostra1 (reverse amostra))
(if (= verif 1)
(setq amostra (cons (car amostra1) amostra))
(setq contador (1- contador))
)
(setq controle contador)
(repeat controle
(setq PTO1 (cdr(car amostra)))
(setq PTO2 (cdr(car(cdr amostra))))
(AZIMUTAR)
(setq amostra(cdr amostra))
)
(princ)
)
(defun AZIMUTAR ()
(setq padroes (getvar "osmode"))
(setvar"cmdecho" 0)
(command "osmode" 0)
(setq A PTO1)
(setq B PTO2)
(setq C " - Az ")
(setq D (angtos (angle A B) 1 4))
(MUDAR)
(setq E (rtos (distance A B) 2 4))
(setq DADO (strcat E C PALAV))
(PARALELO)
(command "text" "j" "mc" ponto_meio 2.5 inicio dado )
(command "osmode" padroes)
)
(defun PARALELO ()
(setq A1 (polar A (+ (/ pi 2)(angle B A )) 2))
(setq B1 (polar B (+ (/ pi 2)(angle B A )) 2))
(setq ptx (/ (+ (car B1) (car A1)) 2))
(setq pty (/ (+ (cadr B1) (cadr A1)) 2))
(setq ponto_meio (list ptx pty))
(if (< (car A1)(car B1))
(setq inicio B1)
(setq inicio A1)
)
)
(defun MUDAR ()
(setq XL 2)
(setq J "d")
(setq COM1 (substr D 1 1))
(while (< XL 5)
(setq LETRAT (substr D XL 1))
(setq RESTOT (substr D (+ 1 XL) ))
(if (= LETRAT J)
(progn (setq J "%%d")
(setq XL 6)
(setq PALAV (strcat COM1 J RESTOT))
)
)
(setq COM1 (strcat COM1 LETRAT ))
(setq XL (1+ XL))
)
)
(defun RTD ()
(/ (* (angle A B) 180) Pi)
)
(defun DTR (AZIMUTE)
(* (/ AZIMUTE 180) Pi)
)
;==== fim===
<edit: code tags added>
-
If the polygon is one closed polyline, it should not be difficult. But in this case, I don't see a big difference between having user to pick a point inside the polygon and pick the polyline itself. If the polygon is created with lines, this seems to be a tough job. But there are quite a few experienced people in this forum.
-
you can use the command _boudary ??!
an example :
(defun c:TESTUS(/ LASTOBJ P PL)
(setq LASTOBJ(entlast))
(if (setq P(getpoint "Inside Point:"))
(progn
(command "_-BOUNDARY" "_a" "_o" "_p" "" P "")
(if(and(not(equal(setq PL(entlast)) LASTOBJ))
(wcmatch(cdr(assoc 0 (entget PL))) "*POLYLINE*")
)
(progn
;do something with PL for instance ...
(princ "\nArea: ")
(princ(vla-get-area (vlax-ename->vla-object PL)))
(princ "\nLength: ")
(princ(vla-get-length(vlax-ename->vla-object PL)))
(princ "\n")
;..
(entdel PL)
)
)
)
)
)
-
Thanks CADmium , thus I want the routine, that it asks for an Inside point, but that places the distances in each segment of the polygon, does not serve the total distance to me, you can help me?
-
Thanks CADmium , thus I want the routine, that it asks for an Inside point, but that places the distances in each segment of the polygon, does not serve the total distance to me, you can help me?
(defun c:len (/ E P)
(princ "\nSpecify internal point")
(while (setq e (bpoly (setq p (getpoint)) ))
(entmakex
(list
'(0 . "TEXT")
(cons 10 p)
(cons
1
(rtos
(vlax-curve-getDistAtParam
e
(vlax-curve-getEndParam e)
) ;_ vlax-curve-getDistAtParam
2
4
) ;_ rtos
) ;_ cons
'(40 . 10.)
'(50 . 0.)
) ;_ list
) ;_ entmakex
(entdel e)
) ;_ while
(princ)
)