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

VLAX-ENAME->VLA-OBJECT

18 REPLIES 18
SOLVED
Reply
Message 1 of 19
dwk1204
16056 Views, 18 Replies

VLAX-ENAME->VLA-OBJECT

I have been using a lisp routine someone in the duscussion group pointed me to for the last three days with no problems. I used it a couple of times today and then on the 4th or 5th try I got this "Select object on layer: ; error: no function definition: VLAX-ENAME->VLA-OBJECT"...Can anyone help me out on what this may mean?

 

Greatly appreciate any help, thanks...

18 REPLIES 18
Message 2 of 19
Kent1Cooper
in reply to: dwk1204


@dwk1204 wrote:

I have been using a lisp routine someone in the duscussion group pointed me to for the last three days with no problems. I used it a couple of times today and then on the 4th or 5th try I got this "Select object on layer: ; error: no function definition: VLAX-ENAME->VLA-OBJECT"...Can anyone help me out on what this may mean?

 

Greatly appreciate any help, thanks...


The (vl...) functions need to be loaded to be usable.  It's good practice to build that into any routine that uses them, but I sometimes forget, too, because my ADT overlay does it for me.  You may have used some other routine that loaded them on the other occasions, prior to using that routine, but not on the occasion when it gave you an error.  Add this line to the routine somewhere before any (vl...) function occurs:

 

(vl-load-com)

Kent Cooper, AIA
Message 3 of 19
dwk1204
in reply to: Kent1Cooper

Third time this week you bailed me out Kent!! Thanks, greatly appreciated, have a good weekend!!

Message 4 of 19
lowend15
in reply to: dwk1204

AWESOME.  THANKS!

Message 5 of 19
waov72
in reply to: lowend15

tengo este problema:

 

(DEFUN c:areas (/ old_error *error* cmd0 refobj por-terreno pol-exp pto-interseccion
cant-pto-interseccion cont-int Xpto-int Ypto-int Zpto-int lista-int
1pto-int 2pto-int parametro pto distancia-pto-inicio distan Pto-med
lin lin1 pol-cont area-exc area-relleno)

(SETQ old_error *error*)
(SETQ *error* #error#)
(SETQ cmd0 (GETVAR "cmdecho")) ;guardo el eco de pantalla
(SETVAR "cmdecho" 0) ;desactiva el eco de pantalla
(COMMAND "._undo" "_begin") ;desacer inicio
(SETQ refobj (GETVAR "osmode")) ;guardo la referencia a objetos
(SETVAR "osmode" 0) ;desactiva la referencia a objetos


(PRINC "\nSelecciona perfil del CAMINO.:")
(SETQ pol-terreno (CAR (ENTSEL)))

(IF (NOT (EQUAL (CDR (ASSOC 0 (ENTGET pol-terreno))) "LWPOLYLINE"))
(PROGN
(ALERT "La entidad Seleccionada \nTIENE que ser una POLILINEA")
(EXIT)
) ;fin PROGN
) ;fin IF


(PRINC "\nSelecciona perfil de la CARRETERA.:")
(SETQ pol-exp (CAR (ENTSEL)))

(IF (NOT (EQUAL (CDR (ASSOC 0 (ENTGET pol-exp))) "LWPOLYLINE"))
(PROGN
(ALERT "La entidad Seleccionada \nTIENE que ser una POLILINEA")
(EXIT)
) ;fin PROGN
) ;fin IF

;;; #error#............

(vl-load-com)

(SETQ pol-terreno (vla-ename->vla-object pol-terreno))
(SETQ pol-exp (vla-ename->vla-object pol-exp))


;;paso los nombres a vla


(SETQ pto-interseccion (vla-IntersectWith pol-terreno pol-exp acExtendNone)
;;acExtendNone equivale a 0 es decir que no extienda ningun objeto
pto-interseccion (vlax-safearray->list (vlax-variant-value pto-interseccion))
;; con esto sacamos la X, Y, Z de la matriz que teniamos
;;sacamos la interseccion de los dos objetos
) ;fin SETQ
(SETQ cant-pto-interseccion (/ (vl-list-length pto-interseccion) 3))
(SETQ cont-int 0)
(REPEAT cant-pto-interseccion
(SETQ Xpto-int (NTH cont-int pto-interseccion))
(SETQ cont-int (1+ cont-int))
(SETQ Ypto-int (NTH cont-int pto-interseccion))
(SETQ cont-int (1+ cont-int))
(SETQ Zpto-int (NTH cont-int pto-interseccion))
;;saco los puntos para convertirlos en puntos individuales y como pares punteados

(SETQ lista-int (CONS (LIST Xpto-int Ypto-int Zpto-int) lista-int))
(SETQ cont-int (1+ cont-int))
) ;fin REPEAT
(SETQ lista-int (VL-SORT lista-int (FUNCTION (LAMBDA (n1 n2)(< (CAR n1) (CAR n2))))))
;;la funcion vl-sort ordena la lista de menor a mayor respecto al primer numero del par punteado

(SETQ cant-pto-interseccion (vl-list-length lista-int))
;;saco la cantidad de puntos de interseccion que tenemos
(SETQ cont-int 0)

(REPEAT (1- cant-pto-interseccion)
(SETQ 1pto-int (NTH cont-int lista-int) ;saco el primer punto de la lista de intersecciones
cont-int (1+ cont-int)
2pto-int (NTH cont-int lista-int) ;saco el segundo punto de la lista de intersecciones
distan (/ (DISTANCE 1pto-int 2pto-int) 2)) ;saco la distancia entre ellos

(SETQ parametro (vlax-curve-getParamAtPoint pol-terreno 1pto-int)
distancia-pto-inicio (vlax-curve-getDistAtParam pol-terreno parametro))
;; saco la distancia al inicio del punto primero de los dos evaluados
(SETQ distan (+ distancia-pto-inicio distan))
;;saco la distancia para calcular el pto medio entre las dos intersecciones
(SETQ Pto-med (vlax-curve-getpointatparam pol-terreno (vlax-curve-getparamatdist pol-terreno distan)))
;;saco el punto medio entre las dos intersecciones

(VL-CMDF "._line" Pto-med (POLAR Pto-med (/ PI 2) 1) "")
;;creo una linea para ver la interseccion con el terreno y asi poder saber si es relleno o excavacion
(SETQ lin (ENTLAST)) ;capturo el nombre de la linea para sacar la interseccion y luego borrarla
(SETQ lin1 (vlax-ename->vla-object lin)) ;pasamos el nombre de la linea a vla
(SETQ pto-interseccion (vla-IntersectWith pol-exp lin1 acExtendOtherEntity)
;;acExtendOtherEntity equivale a 2 es decir que extienda el objeto pasado en segundo termino
pto-interseccion (vlax-safearray->list (vlax-variant-value pto-interseccion))
;; con esto sacamos la X, Y, Z de la matriz que teniamos
;;sacamos la interseccion de los dos objetos
) ;fin SETQ
(ENTDEL lin) ;borro la linea creada antes para la interseccion

(IF (< (CADR pto-interseccion) (CADR Pto-med))
(PROGN ;si es mayor la Y del pto-interseccion el area es excavacion
(VL-CMDF "._-boundary" (POLAR Pto-med (* 1.5 PI) (/ (DISTANCE Pto-med pto-interseccion) 2)) "")
;;genero una polilinea de contorno
(setq pol-cont (entlast))
(setq area-exc (CONS (vla-get-area (vlax-ename->vla-object pol-cont)) area-exc))
;;saco el area de excavacion capturando
(entdel pol-cont) ;borro la polilinea de contorno
) ;fin del PROGN

(PROGN ;si es menor la Y del pto-interseccion el area es relleno
(VL-CMDF "._-boundary" (POLAR Pto-med (/ PI 2) (/ (DISTANCE Pto-med pto-interseccion) 2)) "")
;;genero una polilinea de contorno
(setq pol-cont (entlast))
(setq area-relleno (CONS (vla-get-area (vlax-ename->vla-object pol-cont)) area-relleno))
;;saco el area de excavacion capturando
(entdel pol-cont) ;borro la polilinea contorno
) ;fin del PROGN
) ;fin de IF
) ;fin de REPEAT
(SETQ area-exc (APPLY '+ area-exc)) ;saco el total sumando todos los parciales del area de excavacion
(SETQ area-relleno (APPLY '+ area-relleno)) ;saco el total sumando todos los parciales del area de relleno

(IF (= area-relleno nil)
(SETQ area-relleno 0.000)
) ;fin de IF
(IF (= area-exc nil)
(SETQ area-exc 0.000)
) ;fin de IF

(SETVAR "osmode" refobj) ;vuelvo a dejar las ref a objetos que hubiera

(SETQ pto (GETPOINT "\nIndique punto para insertar los texto de las Areas.:"))
(VL-CMDF "_TEXT" "_j" "_mc" pto "" 0 (STRCAT "Relleno: " (RTOS area-relleno 2 3) " m2"))
;; texto del Area de Relleno
(VL-CMDF "_TEXT" "_j" "_mc" (POLAR pto (* 1.5 PI) 4) "" 0 (STRCAT "Excavacion: " (RTOS area-exc 2 3) " m2"))
;; texto del Area de Excavacion

(COMMAND "._undo" "_end") ;desacer final, para me desaga hasta el inicio
(SETVAR "cmdecho" cmd0) ;dejo el eco de pantalla como estaba
(SETQ *error* old_error)
(PRINC) ;evita que salga el ultimo resultado en pantalla


);fin Defun

(PROMPT "\nCalcular Areas de Relleno y Desmonte")
(PRIN1)
(PROMPT "\nPrograma realizado por Antonio Lancho.")
(PRIN1)
(PROMPT "\nNuevo Comando \"Areas\" Cargado") ;la \" es para que salgan las "
(PRIN1)

 

;;-------------------------------------------------
;;esta funcion es para Tratamiento de errores
;; -- Función #error#
(DEFUN #error# (msg)
(PRINC msg)
(COMMAND "_undo" "_end")
(COMMAND "_undo" "1")
(PROMPT "\n¡Comando Anulado. Se ha restituido el dibujo a su estado inicial!")
(SETVAR "osmode" refobj) ;vuelvo a dejar las ref a objetos que hubiera
(SETVAR "cmdecho" cmd0) ;dejo el eco de pantalla como estaba
(SETQ *error* old_error)
) ;fin DEFUN
;;-------------------------------------------------

 

 

donde coloco el (vl-load-com) ?

 

Gracias por su ayuda

Message 6 of 19
Kent1Cooper
in reply to: waov72


@waov72 wrote:

...

(SETQ pol-terreno (vla-ename->vla-object pol-terreno))
(SETQ pol-exp (vla-ename->vla-object pol-exp))

....


Welcome to these Forums!  I hope I understand what you need [I speak only English].  The part quoted above should be:

...

(SETQ pol-terreno (vlax-ename->vla-object pol-terreno))
(SETQ pol-exp (vlax-ename->vla-object pol-exp))

....


Kent Cooper, AIA
Message 7 of 19
devitg
in reply to: waov72

(vl-load-com)

(DEFUN c:areas (/ old_error *error* cmd0 refobj por-terreno pol-exp pto-interseccion
cant-pto-interseccion cont-int Xpto-int Ypto-int Zpto-int lista-int
1pto-int 2pto-int parametro pto distancia-pto-inicio distan Pto-med
lin lin1 pol-cont area-exc area-relleno)
Message 8 of 19
waov72
in reply to: Kent1Cooper

OK, GRACIAS

 

LO HICE!

 

SALUDOS

Message 9 of 19
waov72
in reply to: devitg

OK, GRACIAS
Message 10 of 19
sayed.kamels
in reply to: Kent1Cooper

HI Kent,

 

i have the same problem with samllestrectangle lisp routine.

it was working perfectly for months, but suddenly started to give me "error: no function definition: VLAX-ENAME->VLA-OBJECT"

i tried to insert (vl-load-com) in different places prior VLAX-ename but without success.

i would be very appreciated if you can adjust the attached routine and send it back.

 

thanks a million in advance

 

regards,

 

sayed.

Message 11 of 19
marko_ribar
in reply to: sayed.kamels


@sayed.kamels wrote:

HI Kent,

 

i have the same problem with samllestrectangle lisp routine.

it was working perfectly for months, but suddenly started to give me "error: no function definition: VLAX-ENAME->VLA-OBJECT"

i tried to insert (vl-load-com) in different places prior VLAX-ename but without success.

i would be very appreciated if you can adjust the attached routine and send it back.

 

thanks a million in advance

 

regards,

 

sayed.


I use this lisp for that purpose... It's very precise and I am strongly suggesting that you use it as if you have SPLINE entities bounding box function will give you wrong results, so Kent's version here has lacks...

 

Please test it and let me know what do you think...

HTH, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 12 of 19
Kent1Cooper
in reply to: sayed.kamels


@sayed.kamels wrote:

.... 

i have the same problem with samllestrectangle lisp routine.

it was working perfectly for months, but suddenly started to give me "error: no function definition: VLAX-ENAME->VLA-OBJECT"

i tried to insert (vl-load-com) ....


Welcome to these Forums!

 

I'm sorry to say that I don't have any idea what to do about that problem.  The (vl-load-com) is already there, and before any of the functions are called that use (vl...) functions.  Has anything changed about your installation?  [A new version of AutoCAD?]  Do you have other routines that now have the same problem?

Kent Cooper, AIA
Message 13 of 19
sayed.kamels
in reply to: Kent1Cooper

Dear Kent,

 

yes the issue appears when i migrated my settings from an older version of autocad.

it was also noticed on other list but not all.

i did restored factory setting for the autocad, but the problem persists.

 

any idea how to solve it?

 

thank you

Sayed

Message 14 of 19
sayed.kamels
in reply to: marko_ribar

Hi Marko,

 

thank you for your reply and the below lisp provided,

howewer i am not lisp expert, i just know how to load it and execute it 😉

kindly advise me how to run your lisp, i am used to run simple lisp routine by typing the name after defun and hitting enter.

 

reg,

 

Sayed.

Message 15 of 19
marko_ribar
in reply to: sayed.kamels


@sayed.kamels wrote:

Hi Marko,

 

thank you for your reply and the below lisp provided,

howewer i am not lisp expert, i just know how to load it and execute it 😉

kindly advise me how to run your lisp, i am used to run simple lisp routine by typing the name after defun and hitting enter.

 

reg,

 

Sayed.


Simply select lisp and save it on HD under name "min+maxbbrec-2dents.lsp"... Then you load it with APPLOAD command, or just copy+paste it into ACAD interface and then start it with "min+maxbbrec-2dents" (without "") at Command: prompt... You'll be asked to select 2d entities and after that lisp will find min and max enclosing rectangle...

 

HTH, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 16 of 19
jvparker
in reply to: dwk1204

Hi guys,  I'm new to the forum here but I've used AutoCAD for several years. I came across this issue after trying to run an Incremental Numbering LSP. I get the very same "error: no function definition: VLAX-ENAME->VLA-OBJECT" 

Using the suggestions here I went into the lsp file and added (vl-load-com) before defun within the text but I'm still getting the same error.  This tool would be extremely helpful to me and I'm hoping someone here can offer a tip or two.  Thanks!  

 

I'm attaching the lsp file below and I'm using AutoCAD Architecture 2018 if that makes any difference.

Message 17 of 19
gherysalinas
in reply to: sayed.kamels

Tengo el mismo problema con una rutina, y lo raro es que dicha rutina funciona en una cpu y en otra no, donde en las dos computadoras se tiene la misma versión de AutoCAD 2018. 

Alguien puede ayudarme?

gherysalinas@gmail.com

este es el código:

 

; Calcula las areas en los puntos indicados o en objetos seleccionados

; Programa desarrollado por Mario Torres Pejerrey
; http://www.construcgeek.com/

;|Este es un lisp en formato original, se puede ver el código fuente, la intención, es de que el código fuente
; pueda ser modificado y adaptado a la necesidad de cada usuario, lo único que siempre se solicita en estos
; casos es de que siempre se haga referencia al autor del mismo (es decir que no se modifique la autoría del lisp),
; salvo que este se modifique ampliamente, si se construye un nuevo programa tomando como partes un lisp publicado,
; se debería de hacer el comentario de que parte del nuevo programa esta basado en el autor original.|;

; Programa descargado desde http://www.construcgeek.com
; ConstrucGeek 2008-2011

; Ultima actualización: 7.4 - 07 Julio 2011

;-----------------------------------------------------------------------------------------------------------------

; Cargar las funciones ActiveX (Visual Lisp)
(vl-load-com)
(setq AcadObj (vlax-get-acad-object))
(setq AcadDocument (vla-get-activedocument AcadObj))
(setq mspace (vla-get-modelspace AcadDocument))


; Función principal: Comando
(defun c:ax()
;Verificar existencia del archivo acetutil.fas;arx
(VerificarAcetutilTemp)

(setq ExisteEntidades (entnext)) ;Buscar entidades en el dibujo
(if (not (null ExisteEntidades)) ;Si existen
(progn ;Corra el programa

;Declaración de variables
(InicializarVariables)

;Cuerpo
(Main)

;Restablecer las variables a su estado original
(RestablecerVariables)

(acet-error-restore)
)
(acet-ui-message "Para hallar areas debe de existir entidades en el dibujo." "No se encontraron entidades" (+ (+ 0 48) 0))
)
(princ)
)


; Funciones complementarias============================================================
;======================================================================================

(defun VerificarAcetutilTemp()
(if (findfile "ai_utils.lsp")
(if (null ai_abort)
(if (= "not" (load "ai_utils" "not"))
(exit)
)
)
(exit)
)
)

 

(defun InicializarVariables()

(acet-error-init(list (list "cmdecho" 0 "osmode" 0 "DIMZIN" 1) T ))
;Guardamos los valores de las variables de AutoCAD para restablecerlas luego

(setq cmd (getvar "cmdecho"))
(setq osa (getvar "osmode"))
(setq supr (getvar "DIMZIN"))

(if (/= (getvar "Clayer") "__AX-ConstrucGeek__")
(setq CapaActual (getvar "Clayer"))
(setq CapaActual "0")
)

(setq hp1 (getvar "HPANG"))
(setq hp2 (getvar "HPBOUND"))
(setq hp3 (getvar "HPDOUBLE"))
(setq hp4 (getvar "HPNAME"))
(setq hp5 (getvar "HPSCALE"))
(setq hp6 (getvar "HPSPACE"))

(setq NombreUltEntIn (cdr (assoc 5 (entget (entlast))))) ;Tomar el nombre de la ultima entidad creada

(setq Pin 0)
(setq UBT 0)
(setq AREA 0)
(setq AreaHallada 0)
(setq InsertoTexto 0)

;Variable para resumir la ruta de ubicacion en el registro de AX
(setq ClaveAX "HKEY_CURRENT_USER\\Software\\Construcgeek.com\\AreasX.Lsp\\")
(SETVAR "modemacro" "http://www.construcgeek.com/")

;Descripción por defecto
(setq TextoDescripcion "")
(setq metroc "")

;Verificamos en el registro de windows y los valores del cuadro de diálogo Opciones de AX
;================================================================================================================================
;Verificamos el numero de decimales
(setq numDecimalesDef (vl-registry-read (strcat ClaveAX "Opciones") "Número de decimales"))
(if (null numDecimalesDef)(setq numDecimalesDef 2)) ;Si no esta almacenado en el registro: Nro de decimales por defecto

;Verificamos el color del achurado
(setq colAchuradoDef (vl-registry-read (strcat ClaveAX "Opciones") "Color de sombreado"))
(if (null colAchuradoDef)(setq colAchuradoDef "136")) ;Si no esta almacenado en el registro: Color 136
(setq colAchurado colAchuradoDef)

;Verificamos la escala de sombreado por defecto
(setq eSombreadoDef (vl-registry-read (strcat ClaveAX "Opciones") "Escala de sombreado"))
(if (null eSombreadoDef)
(setq eSombreadoDef 0.01)
(setq eSombreadoDef (atof eSombreadoDef))
)

;Verificamos la altura de texto a insertar por defecto
(setq hTextoDef (vl-registry-read (strcat ClaveAX "Opciones") "Altura de texto por defecto"))
(if (null hTextoDef)(setq hTextoDef 0.2)(setq hTextoDef (atof hTextoDef)))

;Verificamos si aplican conversiones al area hallada
(setq AplicarConverDEF (vl-registry-read (strcat ClaveAX "Opciones") "Aplicar conversiones al area"))
(if (null AplicarConverDEF)(setq AplicarConverDEF "0")) ;No se genera ninguna conversión

(setq AplicarConverValorDEF (vl-registry-read (strcat ClaveAX "Opciones") "Aplicar conversiones al area - Valor"))
(if (null AplicarConverValorDEF)(setq AplicarConverValorDEF 0.00)(setq AplicarConverValorDEF (atof AplicarConverValorDEF))) ;Por defecto 0.00

;Verificamos si se generan los sombreados
(setq GenSombreadoDEF (vl-registry-read (strcat ClaveAX "Opciones") "Generar el sombreado"))
(if (null GenSombreadoDEF)(setq GenSombreadoDEF "1")) ;Si se generan

;Verificamos el nombre del sombreado por defecto
(setq NomSombreadoDEF (vl-registry-read (strcat ClaveAX "Opciones") "Nombre del sombreado"))
(if (null NomSombreadoDEF)(setq NomSombreadoDEF "Solid"))

;Verificamos si se retiene el achurado
(setq RetAchuradoDEF (vl-registry-read (strcat ClaveAX "Opciones") "Retener el sombreado"))
(if (null RetAchuradoDEF)(setq RetAchuradoDEF "0"))

;Verificamos si se retienen los contornos
(setq RetConfornoDEF (vl-registry-read (strcat ClaveAX "Opciones") "Retener el contorno"))
(if (null RetConfornoDEF)(setq RetConfornoDEF "0"))


;Crea la capa por defecto de los objetos temporales
(CrearCapa "__AX-ConstrucGeek__")


(setq Msg "\nIndique un punto interno del área o [Seleccionar objeto/Opciones]<terminar>: ")

)

;Principal
;======================================================================================
(defun Main()
(while (not (null Pin))
(initget "Seleccionar Decimales Hatch Insertar HTexto Opciones Color")
(setq Pin (getpoint msg))

(Cond
;Se indicó un punto en pantalla
((EQ (type Pin) 'LIST)
(command "_-boundary" "_a" "_o" "_r" "_i" "_n" "" "" Pin "")
(setq NombreBOtEnt(cdr (assoc 5 (entget (entlast))))) ;Obtenemos el nombre de la ultima entidad creada
(setq TipoBOtEnt (cdr (assoc 0 (entget (entlast)))))
(setq ent (entlast))

;Si este nombre coincide con el almacenado al inicio del comando significa que no se ha creado ningun contorno
;por lo tanto no se llevan cabo las acciones
(if (and (/= NombreBOtEnt NombreUltEntIn) (/= "HATCH" (cdr (assoc 0 (entget (entlast))))))
(progn
(HallarArea ent)
(if (= GenSombreadoDEF "1")
(SombrearObjeto ent)
)
)
(acet-ui-message (strcat "El punto que a indicado no se encuentra en el interior de una área cerrada, ó debe de aproximarse mas a ella." "\nIndique un punto en el interior de un contorno válido.") "Indique un punto interno válido" (+ (+ 0 64) 0))
)
)

;Si se indico la opcion "Objeto"
((= Pin "Seleccionar")
(setq EntObjeto (ENTSEL "\nSeleccione las entidades polilínea a obtener el área: "))
(if (not (null EntObjeto))
(progn
(HallarArea (car EntObjeto))
(if (= GenSombreadoDEF "1")
(SombrearObjeto (car EntObjeto))
)
) ;Progn
) ;If
)

;Opcion "Insertar Texto"
((= PIN "Insertar")
(if (/= Area 0)
(progn
(setq UBT (GETPOINT "\nUbicación del texto de área:"))

(if (not (null UBT))
(progn
(setvar "Clayer" CapaActual)
(setq TextoAreaI (vla-AddText mspace (STRCAT "Area = " (RTOS AREA 2 NUMDECIMALESDEF) " m2") (vlax-3d-point (trans UBT 1 0)) HTEXTODEF))
(setq MSG "\nIndique un punto interno del área o [Seleccionar objeto/Opciones]<terminar>: ")
(command "_-layer" "_S" "__AX-ConstrucGeek__" "")
)
)
(setq InsertoTexto 1) ;Se inserto un texo
(setq AREA 0)
)
(acet-ui-message (strcat "Para poder insertar un texto con el área debe de" "\nhallar una nueva área de un contorno válido.") "Halle una área nueva" (+ (+ 0 64) 0))
)
)


;Si se indico la opcion "oPciones"
((OR (= PIN "Opciones") (= PIN "Decimales")(= PIN "Color")(= PIN "Hatch")(= PIN "HTexto"))
(Opciones)
)

;Se presionó enter y no se ha hallado ninguna aerea hasta el momento
((and (null pin) (= AREA 0))
(progn
(setq Pin nil)
(if (= InsertoTexto 1) ;Si se inserto un texto al finalizar tambien se deben de borrar los objetos de sombreado
(BorrarObjetos)
(BorrarCapa) ;Si no solo borrar la capa temporal
)
)
(princ)
)

;Se presionó enter y se ha hallado aerea
((and (null pin) (/= AREA 0))
(progn
(CambiarTexto)
(BorrarObjetos)
)
)
);Cond
);While
);Defun

 

(defun HALLARAREA (EntArea)

(SETQ ObjArea (vlax-ename->vla-object EntArea))
(if (vlax-property-available-p ObjArea 'Area)
(progn
(setq AREAHALLADA (vlax-get-property objArea "Area"))

(cond
((= AplicarConverDEF "0")
(Setq Textconver "\nConversión: Ninguna")
)
((= AplicarConverDEF "1")
(Setq Textconver (strcat "\nConversión: Suma [Valor: " (rtos AplicarConverValorDEF 2 3) "]"))
(setq AREAHALLADA (+ AREAHALLADA AplicarConverValorDEF))
)
((= AplicarConverDEF "2")
(Setq Textconver (strcat "\nConversión: Resta [Valor: " (rtos AplicarConverValorDEF 2 3)"]"))
(setq AREAHALLADA (- AREAHALLADA AplicarConverValorDEF))
)
((= AplicarConverDEF "3")
(Setq Textconver (strcat "\nConversión: Multiplicación [Valor: " (rtos AplicarConverValorDEF 2 3)"]"))
(setq AREAHALLADA (* AREAHALLADA AplicarConverValorDEF))
)
((= AplicarConverDEF "4")
(Setq Textconver (strcat "\nConversión: División [Valor: " (rtos AplicarConverValorDEF 2 3)"]"))
(setq AREAHALLADA (/ AREAHALLADA AplicarConverValorDEF))
)
)

(setq AREA (+ AREA AREAHALLADA))

(setq PRINA (STRCAT "\n\nArea hallada = " (RTOS AREAHALLADA 2 NUMDECIMALESDEF) " m2; Acumulada = " (RTOS AREA 2 NUMDECIMALESDEF) " m2"))
(setq PRINTOTAL (STRCAT "\n\nArea Acumulada = " (RTOS AREA 2 NUMDECIMALESDEF) " m2"))
(PRINC Textconver)
(PRINC PRINA)
(setq MSG "\nIndique un punto interno del área o [Seleccionar objeto/Insertar texto área/Opciones]<cambiar texto>: ")
)
(acet-ui-message (strcat "El objeto seleccionado no contiene un área." "\nSeleccione un objeto del cual se pueda obtener su área." ) "Seleccione un objeto válido" (+ (+ 0 64) 0))
)
)

 

(Defun SombrearObjeto (EntSomb)
(setq TIPOOBJETO (CDR (ASSOC 0 (ENTGET EntSomb))))
;Filtramos los objetos permitidos
(If (or (= TIPOOBJETO "LWPOLYLINE")(= TIPOOBJETO "ELLIPSE")(= TIPOOBJETO "CIRCLE")(= TIPOOBJETO "REGION"))
(progn
;(command "-hatch" "O" "S" (strcat (rtos (car Pin) 2 3)"," (rtos (cadr pin) 2 3)) "N" "P" "ansi31" eSombreadoDef "0" "S" EntSomb "")
(command "_hatch" NomSombreadoDEF eSombreadoDef "0" EntSomb "")
(command "_change" "_l" "" "_p" "_c" colAchuradoDef "")
)
)
)


(defun CAMBIARTEXTO()
(setq ENT (ENTSEL "\nSeleccione el texto o atributo a cambiar la medida <Mostrar>: "))
(if (not (null ent))
(progn
(setq TIPOOBJETO (CDR (ASSOC 0 (ENTGET (CAR ENT)))))

(COND
((or (= TIPOOBJETO "TEXT") (= TIPOOBJETO "MTEXT"))
(setq NENT (CAR ENT))
(setq ENTTEXTSEL (vlax-ename->vla-object NENT))
(setq TEXTO (vla-get-TextString ENTTEXTSEL))

(cond
((wcmatch TEXTO "*=*")
(setq UBI= (VL-STRING-POSITION (ASCII "=") TEXTO))
)
((wcmatch TEXTO "*:*")
(setq UBI= (VL-STRING-POSITION (ASCII ":") TEXTO))
)
((and (not (wcmatch TEXTO "*=*"))(not(wcmatch TEXTO "*:*")))
(setq UBI= nil)
)
)

(if (not (null UBI=))
(progn
(setq DespuesDeIgual (SUBSTR TEXTO (+ UBI= 2) (strlen texto)))
(if (wcmatch DespuesDeIgual " *")
(setq TEXTODESCRIPCION (strcat (SUBSTR TEXTO 1 (+ UBI= 1)) " "))
(setq TEXTODESCRIPCION (SUBSTR TEXTO 1 (+ UBI= 1)))
)
(if (wcmatch DespuesDeIgual "* m*")
(setq metroc " m2")
(progn
(if (wcmatch DespuesDeIgual "*m*")
(setq metroc "m2")
(setq metroc "")
)
)
)

)
(setq TEXTODESCRIPCION "" metroc "")
)


(vla-put-TextString ENTTEXTSEL (strcat TEXTODESCRIPCION (rtos AREA 2 NUMDECIMALESDEF) metroc))

)

((= TIPOOBJETO "INSERT")
(SETQ ObjBloque (vlax-ename->vla-object (car ENT)))
(if (equal (vlax-get-property objBloque "HasAttributes") :vlax-true)
(progn
(setq UBIATRIBUTO (CADR ENT))
(command "_-ATTEDIT" "" "" "" "" UBIATRIBUTO "" "_v" "_R" (RTOS AREA 2 NUMDECIMALESDEF) "_n")
)
(acet-ui-message "El bloque seleccionado no tiene atributos." "Error de selección" (+ (+ 0 64) 0))
)
)

((AND (/= TIPOOBJETO "TEXT") (/= TIPOOBJETO "MTEXT")(/= TIPOOBJETO "INSERT"))
(acet-ui-message "Debe de seleccionar un TEXTO O ATRIBUTO para reemplazarlo por el área hallada." "Error de selección" (+ (+ 0 64) 0))
(CAMBIARTEXTO)
)
)
)

(progn
(setq PRINTOTAL (STRCAT "\n\nArea = " (RTOS AREA 2 NUMDECIMALESDEF) " m2"))
(princ PRINTOTAL)
)

) ;If
);Defun

 

(defun CrearCapa(NombreCapa)
(setq NombreCapaObj (vl-catch-all-apply 'vla-add (list (vla-get-layers AcadDocument) NombreCapa)))
;(vla-put-color NombreCapaObj colAchuradoDef)
(vla-put-color NombreCapaObj "30")
(command "_-layer" "_S" NombreCapa "")
)


(defun CrearCapaPerman(NombreCapa ColorCapa)
(setq NombreCapaObjPerman (vl-catch-all-apply 'vla-add (list (vla-get-layers AcadDocument) NombreCapa)))
(vla-put-color NombreCapaObjPerman ColorCapa)
(command "_-layer" "_S" NombreCapa "")
)


(defun BORRAROBJETOS ()

(IF (= RetAchuradoDef "0") ;Si se ha elegido no retener el sombreado despues de arear
(progn
(setq conj (ssget "x" (list (cons 8 "__AX-ConstrucGeek__") (cons 0 "HATCH"))))
(if (not (null conj))(command "_Erase" conj ""))
)
) ;IF

(IF (= RetConfornoDEF "0") ;Si se ha elegido no retener el contorno despues de arear
(progn
(setq conj (ssget "x" (list (cons 8 "__AX-ConstrucGeek__") (cons 0 "REGION"))))
(if (not (null conj))(command "_Erase" conj ""))
)
)

(IF (and (= RetAchuradoDef "0")(= RetConfornoDEF "0"))
(BorrarCapa)
(BuscarYCambiarCapa "SombreadoAreas" colAchuradoDef)
)

) ;Defun

 

(Defun BuscarYCambiarCapa(NombreCapaBusCrear ColorCapa)
(setq CapaSombreadoAreas (tblsearch "LAYER" NombreCapaBusCrear T)) ;Buscamos la capa
(if (null CapaSombreadoAreas) ;Si no existe la capa "SombreadoAreas" la creamos
(crearCapaPerman NombreCapaBusCrear ColorCapa)
)
(setq conj (ssget "x" (list (cons 8 "__AX-ConstrucGeek__")))) ;Cambiamos los achurados a la nueva capa creada
(if (not (null conj))(command "_change" conj "" "_p" "_LA" NombreCapaBusCrear ""))
(BorrarCapa)
)

 

(defun BorrarCapa ()
(setvar "Clayer" CapaActual)
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list (vl-catch-all-apply 'vla-item (list (vla-get-layers AcadDocument) "__AX-ConstrucGeek__")))))
nil ; name cannot be purged or doesn't exist
T ; name purged
)
)


;Crear el archivo temporal de definición de cuadros de diálogo
(defun Crear_CuadroDialogoOpciones ( / fn Cuadro1A Cuadro1B Cuadro2 Cuadro3A Cuadro3B Cuadro4)

(setq fname (vl-filename-mktemp "Ax.dcl"))
(setq fn (open fname "w"))

(setq Cuadro1A "dlg_AreasX : dialog {
label = \"AreasX 7.4\";
: boxed_column {
label=\"Areas\";
: column {
: edit_box { key = \"txtNumeroDecimales\"; fixed_height = true; allow_accept = true; fixed_width = true; alignment = center; label = \"Número de decimales \"; mnemonic = \"N\";}
: edit_box { key = \"txtAlturaTexto\"; fixed_height = true; allow_accept = true; fixed_width = true; alignment = center; label = \"Altura del texto a insertar\"; mnemonic = \"A\";}
}
spacer;
}

: boxed_column {
label=\"Conversiones de areas\";

: radio_button {
key = \"rbcNinguno\" ;
label = \"&Ninguno\" ;
value = \"1\" ;
}

: radio_button {
key = \"rbcSumar\" ;
label = \"S&umar \" ;
value = \"0\" ;
}

: radio_button {
key = \"rbcRestar\" ;
label = \"&Restar\" ;
value = \"0\" ;
}

: radio_button {
key = \"rbcMultiplicar\" ;
label = \"Mu&ltiplicar\" ;
value = \"0\" ;
}

: radio_button {
key = \"rbcDividir\" ;
label = \"&Dividir\" ;
value = \"0\" ;
}

: edit_box { key = \"txtConversionArea\"; fixed_height = true; allow_accept = true; fixed_width = true; alignment = center; label = \"Valor\"; mnemonic = \"V\";}

spacer;
}

: boxed_column {
label= \"Sombreado \";

: toggle {
label = \"Aplicar sombreados\";
key = \"chkSombrearAreas\";
mnemonic = \"S\";
fixed_width = true;
}


: edit_box { key = \"txtNomSombreado\"; fixed_height = true; allow_accept = true; fixed_width = true; alignment = center; label = \"Nombre del sombreado \"; mnemonic = \"o\";}

spacer;
: row {
: edit_box { key = \"txtEscalaHatch\"; fixed_height = true; allow_accept = true; fixed_width = true; alignment = center; label = \"Escala \"; mnemonic = \"E\";}
: text {label = \"Color\"; key = \"lblColor\";}

: image_button {
key = \"imagenColor\";
color = 0;
fixed_height = true;
fixed_width = true;
width = 9.3;
height = 1.5;
}
}
spacer;
}" )

(setq Cuadro1B "
: boxed_column {
label= \"Terminado el areado \";
: toggle {
label = \"Retener los contornos\";
key = \"chkRetContorno\";
mnemonic = \"c\";
fixed_width = true;
}

spacer;

: toggle {
label = \"Retener el sombreado\";
key = \"chkRetSombreado\";
mnemonic = \"R\";
fixed_width = true;
}
spacer;
}

spacer_1;

: row {
fixed_width=true;
alignment = centered;
: button { fixed_width=true; is_default=true; key=\"accept\"; label= \"Aceptar\"; mnemonic = \"A\"; }
: button { fixed_width=true; is_cancel=true; key=\"cancel\"; label= \"Cancelar\"; mnemonic = \"C\"; }
: button { fixed_width=true; is_cancel=false; key=\"Acerca\"; label= \"Acerca...\"; mnemonic = \"r\"; }
}
spacer;
}" )

(setq Cuadro2 "dlg_Acerca: dialog {
label = \"Acerca de AreasX\";

:paragraph {
spacer_1;
: text {label=\" Programa AreasX, Versión 7.4, Comando: AX\";}
spacer_1;
: text {label=\" Lisp Desarrollado por Mario Torres Pejerrey. 1999-2011\";}
: text {label=\" Web: www.construcgeek.com\";}
: text {label=\" Ultima actualización: 07 Julio 2011\";}
}

spacer_1;
: row {
fixed_width=true;
alignment=right;

: button {
fixed_width=true;
width=13;
key=\"accept7\";
is_default=true;
label= \"&Aceptar\";
}
}


spacer;
}")


(write-line Cuadro1A fn)(write-line Cuadro1B fn)(write-line Cuadro2 fn)
(close fn)

);defun

 

;CUADRO DE DIALOGO OPCIONES (PRINCIPAL)
;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
(defun Opciones()
(crear_CuadroDialogoOpciones)
(setq ind (LOAD_DIALOG fname));(Cargar_CuadroOpciones)
(if (not (new_dialog "dlg_AreasX" ind))(exit))
(valoresOpciones)
(accionesOpciones)
(START_DIALOG)

(UNLOAD_DIALOG ind)

(vl-file-delete fname)

(princ)
)

(defun valoresOpciones ()
; Se define los valores por defecto.

(SET_TILE "txtNumeroDecimales" (ITOA numDecimalesDef))
(MODE_TILE "txtNumeroDecimales" 2)

(SET_TILE "txtAlturaTexto" (Rtos hTextoDef))
(MODE_TILE "txtAlturaTexto" 3)


(Setq ValorrbcNinguno "0")
(Setq ValorrbcSumar "0")
(Setq ValorrbcRestar "0")
(Setq ValorrbcMultiplicar "0")
(Setq ValorrbcDividir "0")
(MODE_TILE "txtConversionArea" 0)
(SET_TILE "txtConversionArea" (Rtos AplicarConverValorDEF))

(cond
((= AplicarConverDEF "0")
(Setq ValorrbcNinguno "1")
(MODE_TILE "txtConversionArea" 1)
)
((= AplicarConverDEF "1")
(Setq ValorrbcSumar "1")
)
((= AplicarConverDEF "2")
(Setq ValorrbcRestar "1")
)
((= AplicarConverDEF "3")
(Setq ValorrbcMultiplicar "1")
)
((= AplicarConverDEF "4")
(Setq ValorrbcDividir "1")
)
)

(SET_TILE "rbcNinguno" ValorrbcNinguno)
(SET_TILE "rbcSumar" ValorrbcSumar)
(SET_TILE "rbcRestar" ValorrbcRestar)
(SET_TILE "rbcMultiplicar" ValorrbcMultiplicar)
(SET_TILE "rbcDividir" ValorrbcDividir)

(SET_TILE "chkSombrearAreas" GenSombreadoDEF)

(SETQ ACTDESOM (- 1 (atoi GenSombreadoDEF))) (MODE_TILE "txtNomSombreado" ACTDESOM) (MODE_TILE "txtEscalaHatch" ACTDESOM) (MODE_TILE "imagenColor" ACTDESOM) (MODE_TILE "lblColor" ACTDESOM) (MODE_TILE "chkRetSombreado" ACTDESOM)


(SET_TILE "txtNomSombreado" NomSombreadoDEF)

(SET_TILE "txtEscalaHatch" (Rtos eSombreadoDef))

(MODE_TILE "txtEscalaHatch" 3)
(SET_TILE "chkRetContorno" RetConfornoDEF)

(SET_TILE "chkRetSombreado" RetAchuradoDEF)

(setq ancho (DIMX_TILE "imagenColor") alto(DIMY_TILE "imagenColor"))
(START_IMAGE "imagenColor")
(FILL_IMAGE 0 0 ancho alto (atoi colAchuradoDef))
(END_IMAGE)

)


(defun accionesOpciones()

(ACTION_TILE "imagenColor" "(SeleccionarColor)")

(ACTION_TILE "rbcNinguno" "(setq AplicarConver \"0\") (MODE_TILE \"txtConversionArea\" 1)")
(ACTION_TILE "rbcSumar" "(setq AplicarConver \"1\") (MODE_TILE \"txtConversionArea\" 0)")
(ACTION_TILE "rbcRestar" "(setq AplicarConver \"2\") (MODE_TILE \"txtConversionArea\" 0)")
(ACTION_TILE "rbcMultiplicar" "(setq AplicarConver \"3\") (MODE_TILE \"txtConversionArea\" 0)")
(ACTION_TILE "rbcDividir" "(setq AplicarConver \"4\") (MODE_TILE \"txtConversionArea\" 0)")

(ACTION_TILE "chkSombrearAreas" "(SETQ ACTDESOM (- 1 (atoi $Value))) (MODE_TILE \"txtNomSombreado\" ACTDESOM) (MODE_TILE \"txtEscalaHatch\" ACTDESOM) (MODE_TILE \"imagenColor\" ACTDESOM) (MODE_TILE \"lblColor\" ACTDESOM) (MODE_TILE \"chkRetSombreado\" ACTDESOM) ")

(ACTION_TILE "accept" "(chequearErr) (IF erroresChek () (Aceptar))")
(ACTION_TILE "cancel" "(DONE_DIALOG)")
(ACTION_TILE "Acerca" "(acercade)")
)

 

(defun SeleccionarColor()
(setq colAchurado (acad_colordlg (ATOI colAchurado)))

(if (null colAchurado)
(setq colAchurado colAchuradoDef)
(progn
(setq colAchurado (ITOA colAchurado))
(START_IMAGE "imagenColor")
(FILL_IMAGE 0 0 ancho alto (ATOI colAchurado))
(END_IMAGE)
)
)
)


(Defun chequearErr()
(SETQ erroresChek nil)
;Numero de decimales
(if (< (ATOI (GET_TILE "txtNumeroDecimales")) 0)
(progn
(SETQ erroresChek T)
(acet-ui-message "El número de decimales para las areas no puede ser menor que 0." "Error en los decimales para areas" (+ (+ 0 64) 0))
(MODE_TILE "txtNumeroDecimales" 2)
)
)

(if (<= (ATOF (GET_TILE "txtAlturaTexto")) 0)
(progn
(SETQ erroresChek T)
(acet-ui-message "La altura del texto a insertar no puede ser 0 ó menor que 0." "Error en la altura de texto" (+ (+ 0 64) 0))
(MODE_TILE "txtAlturaTexto" 2)
)
)

(if (< (ATOF (GET_TILE "txtConversionArea")) 0)
(progn
(SETQ erroresChek T)
(acet-ui-message "El valor de conversión no puede ser menor que 0." "Error en el valor de conversión" (+ (+ 0 64) 0))
(MODE_TILE "txtConversionArea" 2)
)
)

(if (<= (ATOF (GET_TILE "txtEscalaHatch")) 0)
(progn
(SETQ erroresChek T)
(acet-ui-message "La escala del achurado no puede ser 0 ó menor que 0." "Error en la escala de achurado" (+ (+ 0 64) 0))
(MODE_TILE "txtEscalaHatch" 2)
)
)

)

 

(defun aceptar()

(SETQ NUMDECIMALESDEF (ATOI (GET_TILE "txtNumeroDecimales")))
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Número de decimales" NUMDECIMALESDEF)

(SETQ HTEXTODEF (ATOF (GET_TILE "txtAlturaTexto")))
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Altura de texto por defecto" (rtos HTEXTODEF 2 3))

(setq AplicarConverDEF AplicarConver)
(SETQ AplicarConverValorDEF (ATOF (GET_TILE "txtConversionArea")))
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Aplicar conversiones al area" AplicarConver)
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Aplicar conversiones al area - Valor" (rtos AplicarConverValorDEF 2 3))

(setq GenSombreadoDEF (GET_TILE "chkSombrearAreas"))
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Generar el sombreado" GenSombreadoDEF)

(SETQ NomSombreadoDEF (GET_TILE "txtNomSombreado"))
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Nombre del sombreado" NomSombreadoDEF)

(setq ESOMBREADODEF (ATOF (GET_TILE "txtEscalaHatch")))
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Escala de sombreado" (rtos ESOMBREADODEF 2 3))

(setq RetConfornoDEF (GET_TILE "chkRetContorno"))
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Retener el contorno" RetConfornoDEF)

(setq RetAchuradoDEF (GET_TILE "chkRetSombreado"))
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Retener el sombreado" RetAchuradoDEF)

(setq colAchuradoDef colAchurado)
(VL-REGISTRY-WRITE (strcat ClaveAX "Opciones") "Color de sombreado" colAchuradoDef)

(DONE_DIALOG 1)
)

;Cuadro de mensaje tipo Visual Basic
(defun Msgbox (Mensaje Titulo Tipo Icono BotonDefecto / Respuesta)

(setq acet-id (acet-ui-message Mensaje Titulo (+ (+ Tipo Icono) BotonDefecto)))

(cond
((= acet-id 1) (setq Respuesta "OK"))
((= acet-id 2) (setq Respuesta "CANCEL"))
((= acet-id 3) (setq Respuesta "ABORT"))
((= acet-id 4) (setq Respuesta "RETRY"))
((= acet-id 5) (setq Respuesta "IGNORE"))
((= acet-id 6) (setq Respuesta "YES"))
((= acet-id 7) (setq Respuesta "NO"))
((= acet-id 😎 (setq Respuesta "CLOSE"))
((= acet-id 9) (setq Respuesta "HELP"))
;(t nil)
)
)


(defun RESTABLECERVARIABLES ()
(SETVAR "HPANG" HP1)
(SETVAR "HPBOUND" HP2)
(SETVAR "HPDOUBLE" HP3)
(SETVAR "HPNAME" HP4)
(SETVAR "HPSCALE" HP5)
(SETVAR "HPSPACE" HP6)
(SETVAR "osmode" OSA)
(SETVAR "DIMZIN" SUPR)
)


(defun acercade()
(if (not (new_dialog "dlg_Acerca" ind))(exit))
(ACTION_TILE "accept7" "(DONE_DIALOG)")
(START_DIALOG)
(princ)
)


(setq MODEACT (getvar "MODEMACRO"))

(PRINC "\nPrograma AreasX")
(PRINC "\nVersión 7.4")
(PRINC "\nLisp Desarrollado por Mario Torres Pejerrey. - 1999 - 2011")
(PRINC "\nUltima actualización 08/07/2011")
(PRINC "\nHalla areas a partir de objetos.")
(PRINC "\nNombre de comando: AX")
(setvar "modemacro" "http://www.construcgeek.com/")
(PRINC)

 

 

Message 18 of 19
ВeekeeCZ
in reply to: gherysalinas

Look HERE...

Message 19 of 19
henry.cremieux
in reply to: ВeekeeCZ

done everything like said on the page linked in your post but still doesn't work

Autocad 2022 & REVIT 2021 sur PC de bureau avec Windows 7 pro sp.1 64 bits CPU intel coreI7 6700 GPU Nvidia quadro K420 DIRECTX 11.1 RAM 32G Corsair DDR4

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

Post to forums  

Autodesk Design & Make Report

”Boost