Jump to content

Help - No function definition: vlax-ename->vla-object


oonan

Recommended Posts

Hello, master.

 

I need your help for this lisp, it is my old lisp to get areas from objects but does not work in autocad 2016, i think that is in the bpoly funcion but i dont know how to fix the error: "No function definition: vlax-ename->vla-object"

 

(vl-load-com)
(defun arear (clave / nentpoly area os listapolys caso 2dacadena contador0 contador1 *Error*) 
 
  (DEFUN *ERROR* (msg) 
    (PRINC "Error >> ") 
    (princ msg)
   (if (= msg "Function cancelled")
   (arearmistake1)
   (arearmistake2))
          (quit)
    ) 

     (defun arearmistake1 ()
          (alert "\nFuncion Cancelada")
          (setvar "osmode" os)
          (foreach caso listapolys (entdel caso))
          (setvar "cecolor" colorant)
          (setvar "Clayer" CapaActual)
          (princ)
     ) 

     (defun arearmistake2 ()
          (alert "\nEl contorno no esta Cerrado")
          (setvar "osmode" os)
          (foreach caso listapolys (entdel caso))
          (setvar "cecolor" colorant)
          (setvar "Clayer" CapaActual)
          (princ)
     )

          (setq CapaActual (getvar "Clayer"))

  (if   (null (tblobjname "STYLE" "R-80")) 
  (entmake '((0 . "STYLE")(100 . "AcDbSymbolTableRecord")(100 . "AcDbTextStyleTableRecord") 
            (2 . "R-80")(70 . 0)(40 . 0.18)(3 . "ROMANS"))) 
  )


  (if   (null (tblobjname "LAYER" "A-TEXTOS 10")) 
  (entmake '((0 . "LAYER")(100 . "AcDbSymbolTableRecord")(100 . "AcDbLayerTableRecord") 
           (2 . "A-TEXTOS 10")(70 . 0)(62 . 10)(370 . -3))) 
  ) 

         (setq contador0 0)
         (setq contador1 0) 
         (setq area 0.0 
               os   (getvar "osmode")) 
         (setvar "osmode" 4) 
         (setq colorant (getvar "cecolor"))
         (setvar "cecolor" "201")

  (While 
         (setq nentpoly (bpoly (getpoint "\n<Indique punto(s)>(intro para terminar):"))) 

         (redraw nentpoly 3)

         (setq contador0 (1+ contador0))          
         (setq area (+ area (vlax-curve-getArea (vlax-ename->vla-object nentpoly))) 
               listapolys (cons nentpoly listapolys))
         (princ (strcat (fnum area) " m2"))
         (setq contador1 (1+ contador1))
         (setq areax (vlax-curve-getArea (vlax-ename->vla-object nentpoly)))
         (princ (strcat "\n(AREA " CLAVE "  "(itoa contador0)") (ACUMULADO: " (fnum area) " m2) " "(PARCIAL: " (fnum areax) " m2)"))
  )
         (setq areac (fnum area))
         (prompt (strcat "\nAREA TOTAL DE " clave ": " areac " m2"))(terpri)
         (setvar "cecolor" colorant) 
         (entmake (list '(0 . "TEXT")'(100 . "AcDbEntity")'(8 . "A-TEXTOS 10")'(100 . "AcDbText")
                        '(62 . 256)'(10 0.0 0.0 0.0)(cons 40 0.18)(cons 1 (strcat clave " = " areac "m2")) 
                        '(50 . 0.0)'(41 . 1)'(51 . 0.0)'(7 . "R-80")'(72 . 2)
                        (cons 11 (getpoint "\n<Punto para colocar el texto>"))'(210 0.0 0.0 1.0)'(100 . "AcDbText")'(73 . 1)))
         (foreach caso listapolys (entdel caso))
         (setvar "osmode" os) 
  (prin1)
 ) 



(defun fnum  (num)
  (setq f 2)                                                     ;redondea a 2 decimales
  (setq int (rtos num 2 f)
        pos (vl-string-search "." int)
        pos (if pos pos (strlen int))
        fp  (substr int (+ pos 2) (strlen int))
        int (substr int 1 pos))
  (while (< (strlen fp) f) (setq fp (strcat fp "0")))
  (repeat (/ pos 3)
          (setq int (strcat (substr int 1 (- pos 3))
                     ","
                     (substr int (- pos 2) (strlen int)))
          pos (- pos 3)))
  (vl-string-left-trim ","
  (if (zerop f) int  (strcat int "." fp))
  )
)

(defun c:CRP ()   (arear "CARPETA ASFÁLTICA"))

 

thank you for your attention.

Link to comment
Share on other sites

since the very first line of OP's code begins with (vl-load-com) my first thought would be to check if the visual lisp functions are loaded (vl.arx) in the first place.

 

 

p.s. function works here on my pc (autocad 2016) so you might have to (re)install / enable vlisp

Edited by rlx
Link to comment
Share on other sites

When you start vlisp , the visual lisp editor , if the visual lisp library is successfully loaded and vl-load-com is loaded , commands like 'vl-catch-all-apply' should appear in blue. If not , you should probably reinstall AutoCAD or search your system for vl.arx and load it via menu : tools->autolisp->load application

 

 

gr.Rlx

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...