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

error: no function definition: VLAX-ENAME->VLA-OBJECT; (vl-load-com) is there!

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
Anonymous
15391 Views, 19 Replies

error: no function definition: VLAX-ENAME->VLA-OBJECT; (vl-load-com) is there!

Dear All,

 

I try to export the coordinates of the points belonging to a polyline and I use "plist.lsp" created by Tony Hotchkiss, downloaded from:  http://www.cadalyst.com/general-software/autolisp-solutions-export-point-coordinates-5263.

 

I get the error message ";error: no function definition: VLAX-ENAME->VLA-OBJECT".

In line 84 I found "obj (vlax-ename->vla-object ent)".

"(vl-load-com)" is in line 5 of the code.

Please advise me.

 

I ask myself some questions:

  • Is AutoCAD2018 student version able to use AutoLISP?
  • Is AutoCAD2018 student version using ActiveX methods by default, or they must be explicitly activated?

 

Thank you in advance for the answers.

Any help is greatly appreciated!

 

The according code is:

(defun vert (/         filterlist  vla-obj-list
         lwlist     2dlist         ptlist     vlist1
         vlist2     vlist3
        )
  (vl-load-com)
  (setq    filterlist   (make-filter)
    vla-obj-list (get-objects filterlist)
    lwlist         (nth 0 vla-obj-list)
    2dlist         (nth 1 vla-obj-list)
    ptlist         (nth 2 vla-obj-list)
    vlist1         nil
    vlist2         nil
    vlist3         nil
  ) ;_ end-of setq
  (if lwlist
    (setq vlist1 (make-list lwlist 2))
  ) ;_ end of if
  (if 2dlist
    (setq vlist2 (make-list 2dlist 3))
  ) ;_ end of if
  (if ptlist
    (setq vlist3 (make-list ptlist 3))
  ) ;_ end of if
  (write-text vlist1 vlist2 vlist3)
  (princ)
) ;_ end of vert

(defun make-list (p-list n / i vlist obj coords ca j x y z xy)
  (setq    i (- 1)
    vlist nil
  ) ;_ end of setq
  (repeat (length p-list)
    (setq obj     (nth (setq i (1+ i)) p-list)
      coords (vlax-get-property obj "coordinates")
      ca     (vlax-variant-value coords)
      j     (- 1)
    ) ;_ end-of setq
    (repeat (/ (length (vlax-safearray->list ca)) n)
      (setq x (vlax-safearray-get-element ca (setq j (1+ j))))
      (setq y (vlax-safearray-get-element ca (setq j (1+ j))))
      (if (= n 2)
    (setq xy (list x y))
    (progn
      (setq z (vlax-safearray-get-element ca (setq j (1+ j))))
      (setq xy (list x y z))
    ) ;_ end of progn
      ) ;_ end of if
      (setq vlist (append vlist (list xy)))
    ) ;_ end-of repeat
  ) ;_ end-of repeat
) ;_ end-of make-list

(defun make-filter (/ filter)
  (setq    filter '((-4 . "<OR")
         (0 . "LWPOLYLINE")
         (0 . "POLYLINE")
         (0 . "POINT")
         (-4 . "OR>")
        )
  ) ;_ end of setq
) ;_ end of make-filter

(defun get-objects (filter  /        ss        k        lwp-list
            2dp-list        pt-list no-ent  obj        pl
            2d        pt
           )
  (setq no-ent 1)
  (while no-ent
    (setq ss       (ssget filter)
      k       (- 1)
      lwp-list nil
      2dp-list nil
      pt-list  nil
      obj       nil
      pl       "AcDbPolyline"
      2d       "AcDb2dPolyline"
      pt       "AcDbPoint"
    ) ;_ end-of setq
    (if    ss
      (progn
    (setq no-ent nil)
    (repeat    (sslength ss)
      (setq    ent (ssname ss (setq k (1+ k)))
        obj (vlax-ename->vla-object ent)
      ) ;_ end-of setq
      (cond
        ((= (vlax-get-property obj "ObjectName") pl)
         (setq lwp-list (append lwp-list (list obj)))
        )
        ((= (vlax-get-property obj "ObjectName") 2d)
         (setq 2dp-list (append 2dp-list (list obj)))
        )
        ((= (vlax-get-property obj "ObjectName") pt)
         (setq pt-list (append pt-list (list obj)))
        )
      ) ;_ end-of cond
    ) ;_ end-of repeat
      ) ;_ end-of progn
      (prompt "\nNo polylines or points selected, try again.")
    ) ;_ end-of if
  ) ;_ end-of while
  (list lwp-list 2dp-list pt-list)
) ;_ end-of get-objects

(defun write-text (vl1 vl2 vl3)
  (setq    fn (getfiled "Text File" "" "txt" 1))
  (setq f (close (open fn "w")))
  (setq msg "Points from LW-Polylines")
  (do-points fn vl1 msg 2)
  (setq msg "Points from 2d-Polylines")
  (do-points fn vl2 msg 3)
  (setq msg "Points from Point entities")
  (do-points fn vl3 msg 3)
  (princ)
) ;_ end of write-text

(defun do-points (fn vl msg n)
  (setq f (open fn "a"))
  (write-line msg f)
  (write-line "  x,  y,  z" f)
  (write-line "" f)
  (foreach point vl
    (setq x (nth 0 point)
      y (nth 1 point)
    ) ;_ end of setq
    (if    (= n 2)
      (setq str (strcat (rtos x) "," (rtos y)))
      (progn
    (setq z (nth 2 point))
    (setq str (strcat (rtos x) "," (rtos y) "," (rtos z)))
      ) ;_ end of progn
    ) ;_ end of if
    (write-line str f)
  ) ;_ end of foreach
  (setq f (close f))
  (princ)
) ;_ end of defun

(defun c:pts ()
  (vert)
  (princ)
) ;_ end-of defun

(prompt "PLIST.LSP by Tony Hotchkiss - enter PTS to start ")

 

19 REPLIES 19
Message 2 of 20
_gile
in reply to: Anonymous

Hi,

 

Student versions support the same as standard versions. The AutoLISP support restrictions are:

AutoCAD LT does not support LISP at all

AutoCAD MAC does not support ActiveX



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 20
ВeekeeCZ
in reply to: Anonymous

Well, that's a big issue and often - try search - it requires reinstall. E.g. see THIS thread.

 

Message 4 of 20
Anonymous
in reply to: _gile

Thank you!

 

I tried to solve the problem following two directions:

1. identification of the precise sequence where the program fails: I indented all the lines of the code in order to quickly identify the start-stop sequences; I added plenty of '(prompt "'code_module' '999_sequence_no' 'explanation' \n")' lines in order to trace the execution; I added comments/remarks;

2. examples: I used the example presented here: https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-AutoLISP/file....

 

Conclusions:

1. the trace messages are displayed and the sequence where the application fails is "obj (vlax-ename->vla-object ent); Transforms an entity to a VLA-object";

2. following the aforementioned address: the AutoCAD prompt command "(princ e)" displays "<Entity name: xxx-xxxxxxxx><Entity name: xxx-xxxxxxxx>" and the command "(vlax-ename->vla-object e)" displays "; error: no function definition: VLAX-ENAME->VLA-OBJECT".

 

So, there is a problem with "vlax-ename".

 

Is there any library missing? Eventually an ActiveX library?

 

Thank you very much for your help!

Message 5 of 20
Anonymous
in reply to: Anonymous

I found "vl.arx" in "C:\Autodesk\WI\Autodesk AutoCAD 2018\x64\acad\Program Files\Root" so it isn't missing!

Message 6 of 20
_gile
in reply to: Anonymous

Assuming you're using a plain AutoCAD Windows version.

 

In your code execution (vlax-ename->vla-object ...) is the first call to an ActiveX function (vla-*, vlax-* or vlr-* functions). Line 7 the get-objects routine is called and this routine calls vlax-ename->vla-object (line 84).

 

You can also try to enter (vl-load-com) (setq acad (vlax-get-acad-object)) you'd get the same error.

 

That means the ActiveX function are not loaded despite you run (vl-load-com). As @ВeekeeCZ said, only a clean uninstall / reinstall of AutoCAD can solve your issue.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 7 of 20
Anonymous
in reply to: _gile

Dear All

 

As you suggested, I reinstalled AutoCAD and now it works.

 

Thank you very much!

 

Emil

Message 8 of 20
Anonymous
in reply to: Anonymous

Is not necessary to reinstall Autocad. It's missing the registry key to pinpoint the vl16.tlb file.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{A4081F53-974E-479E-A26E-E6DE9A5B2489}]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{A4081F53-974E-479E-A26E-E6DE9A5B2489}\1.0]
@="Visual Lisp ActiveX module"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{A4081F53-974E-479E-A26E-E6DE9A5B2489}\1.0\0]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TypeLib\{A4081F53-974E-479E-A26E-E6DE9A5B2489}\1.0\0\win32]
@="C:\\Program Files\\Autodesk\\AutoCAD 2016\\vl16.tlb"

 

where "C:\\Program Files\\Autodesk\\AutoCAD 2016\\vl16.tlb" is the location of the file, it had to be modified to the source of Autocad directory. 

 

 

Message 9 of 20
Anonymous
in reply to: ВeekeeCZ

Hello, i have a client that have this problem too, the routine work perfectly but one day vlax-ldata-get no fonction definiton 

I found that I need to reinstall AutoCAD 2016 to fix the problem 

my question is do you have a solution to fix permenantly this problem?

thanks

solgti

Message 10 of 20
Scottu2
in reply to: Anonymous

 topocmddb,

 

I was re-writing programs to workaround this vlax-ename->vla-object issue.

In the registry, I added the keys (sub-folders) and updated the default values to have the text as you noted in quotes.

And change it for Autocad 2019.

 

Thank you for this registry fix!   🙂

 

Message 11 of 20
john_nordmark1
in reply to: Anonymous

I had problems with this. I Reinstalled AutoCAD Architecture 2018, and it worked, for a while. Then it stopped working again. I tried this Registry hack and now it seems to work fine. Thanks for the tip @Anonymous !

Message 12 of 20
Nick_Antonov
in reply to: Anonymous

Thanks for this hack, It saved me the hassle to reinstall my 2020 products,

I paste your Registry keys in Notepad..I just renamed 2016 to 2020 path (first I made sure the file is in the directory). Then saved the file as ".Reg", Run it and "merged" it into the windows registry.

At first I was worried that it did not solved the issue, But after I closed and opened my AutoCAD Map3D , it worked, So I suppose AutoCAD reads the registry keys not on demand(when you execute the code) but as it loads at first..

Thanks for that

 

 

Message 13 of 20

Thanks! It works!

Message 14 of 20
drubinW4ZLK
in reply to: Nick_Antonov

Worked like a charm. Thanks

Message 15 of 20
jack_foster
in reply to: Nick_Antonov

You are a rocket scientist!  I can't believe I have to do all of this work to make something that was working now work.  I am also having a problem with the paths and file names not matching the instructions in here.  I searched for VL16.tlb and found it but I am running 2021 version.  The file was found in ...\AutoCAD 2019; ... 2020 and ... 2021 folders.  There is also a vl16.u.tlb file found with ...2021 folder.  I searched for a vl21.tlb and it was not found.  I have read where it says to change the registry to what version you are running.  I have tried to edit the file you so nicely provided but it will not let me do such.  I have tried using notepad with no luck.  I realize you are not tech support and not obligated to help and if you are too busy I understand.  What should happen is AutoCAD should make a fix for this.  I mean how many users would be able to do this.  I have 30 years of computer experience and I am scared to do this.  Thank you for any and all help you may be able to give me.  Stay safe from the Virus to.  

Message 16 of 20
jack_foster
in reply to: Nick_Antonov

My apologies for bothering you with previous post.  I just opened Notepad and change file types and I was able to open and edit the file changing 2020 to 2021.  Now I will run the program and cross my fingers that it works.  Worst case scenario as others mentioned is to just reinstall AutoCAD.  Hopefully AutoCAD will figure out to stop such insanity as this from happening in the future.  THANK YOU WA WHOLE BUNCH!!!

Message 17 of 20
Nick_Antonov
in reply to: jack_foster

Hi Jack, I am sorry I only read your message now,(It was night in Africa 🙂 )

 

I hope you sorted it out,

What I figured that looks like all versions are using same file vl16.tlb maybe it appeared back in Ver2016 but looks like it carries on So only the path to the "broken"  AutoCAD version we have to change..

 

I amended the Reg file for AutoCAD2021.

 

Below instructions are for anyone that is not familiar how to add registry keys to the system registry.

 

When you edit the Reg file ,extract it first on your Hard drive, Then Right click on it and chose Edit, It should open it in the Note pad for editing, If by any chance your default editing app was changed then right click and choose  OPEN WITH ->, Chose Notepad but don't tick on "Always use this app to open .reg files"

When open on Note pad and you do your correction make sure at the bottom below File name you change to "All Files (*.*)" , This will allow the file extension to be .REG  instead of Notepad adding TXT to it.

Once saved just double click on the file to initiate merging the code into the system registry, Accept all the prompts, 

 

f you want to use the code from the post above(or any code you found on the net that you know is safe and won't disturb your system), Start Notepad, Copy only the lines with the code (No empty lines above or below) and paste them in the Notepad window, Then save as and follow instructions above to save as Reg.File

If you are not sure what you are doing Backup your registry or create restore point before merging any registry keys. Just in case,

In my practice I never had issues, But no body knows.. I cant guarantee for everyone.

 

Regards

Nick

Message 18 of 20
jack_foster
in reply to: Nick_Antonov

Thank you a whole bunch.  I did run what I modified and it appears to all be working now.  Very nice of you to take the time to reply and create a new file for 2021.  If we could just get AutoCAD to fix some things that quickly it would be great.  Take care and stay safe.

Message 19 of 20
Nick_Antonov
in reply to: jack_foster

I agree, Autodesk should acknowledge the problem and issue a "Hotfix" , so the the users that are not that IT knowledgeable, can fix it without need to reinstall the product or do "scary" registry editing.

Also imagine, in Corporate environment where permissions of the end user are limited, and the IT crowd are always suspicious of our requests 🙂

I just wonder what the reasons behind this fault?

Is it custom Code that we run - disturbers the Registry, Or Windows specific update? Or another software .

 

Thanks to all smart community out there , That's why we love AutoDESK products, The communal support is as good as it can gets 🙂

And kudos to AutoDESK that they support the open line and don't lock it in proprietary "prison".

 

Message 20 of 20
jack_foster
in reply to: Nick_Antonov

Very well stated!  Thank you again for your great help!  Take care and stay safe.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report