Author Topic: LISP command broke in 2020....  (Read 1548 times)

0 Members and 1 Guest are viewing this topic.

cyclops

  • Newt
  • Posts: 21
LISP command broke in 2020....
« on: April 02, 2020, 04:00:40 PM »
This demolayer.lsp works in 2018, no go in 2020, can someone help?

The error is -->  ;error: no function definition: VLAX-ENAME->VLA-OBJECT

Thanks for the help in advance.
Cyclops
    ||
    ||
   \  /
    V
Code - Auto/Visual Lisp: [Select]
  1. ;;DemoLayer.LSP - Changes picked objects to layer with -DEMO suffix.
  2. ;;Bill Kramer 2008
  3. ;;
  4. ;; Visual LISP Example utility to change objects selected. This example
  5. ;; changes the layer name of the selected objects (appends "-DEMO") and
  6. ;; duplicates the layer definition if needed for the new layer.
  7. ;;
  8. (defun C:DemoLayer ( / SS CNT LYR vEN EN LyrNew LyrTab oLayers)
  9.   (prompt "\nChange selected objects layer by appending -DEMO to name.")
  10.   (setq SS (ssget))
  11.   (if (and SS (> (sslength SS) 0))
  12.     (progn
  13.       (setq oLayers ;;get layer table link
  14.              (vla-get-layers
  15.                (vla-get-activedocument
  16.                  (vlax-get-acad-object))))
  17.       ;;
  18.       ;;Got the objects, now stream through them
  19.       (repeat (setq CNT (sslength SS))
  20.         ;;
  21.         (setq En (ssname SS (setq CNT (1- CNT))) ;;Entity name from set
  22.               vEN (vlax-ename->vla-object En) ;;entity object reference
  23.               LYR (vla-get-layer vEN);;get the layer name
  24.               )
  25.         ;;check to see if -DEMO already there
  26.         (if (not (wcmatch LYR "*-DEMO")) ;;layer name already -DEMO type?
  27.           (progn
  28.             ;;
  29.             ;; No, first check to see if the layer with -DEMO already exists
  30.             ;;
  31.             (if (not (tblsearch "LAYER" (strcat LYR "-DEMO")))
  32.               (progn ;;add the new layer
  33.                 (setq LyrNew (vla-add oLayers (strcat LYR "-DEMO"))
  34.                       LyrTab (vla-item oLayers LYR)
  35.                       )
  36.                 ;; Clone the properties
  37.                 (vla-put-linetype LyrNew (vla-get-linetype LyrTab))
  38.                 (vla-put-truecolor LyrNew (vla-get-truecolor LyrTab))
  39.                 (vla-put-freeze LyrNew (vla-get-freeze LyrTab))
  40.                 (vla-put-layeron LyrNew (vla-get-layeron LyrTab))
  41.                 (vla-put-lineweight LyrNew (vla-get-lineweight LyrTab))
  42.                 (vla-put-lock LyrNew (vla-get-lock LyrTab))
  43.                 (vla-put-material LyrNew (vla-get-material LyrTab))
  44.                 ;(vla-put-plotstylename LyrNew (vla-get-plotstylename LyrTab))   ;<-----------
  45.                 )) ;;end layer add
  46.             ;;
  47.             ;; Update the layer name of the object
  48.             (vla-put-layer vEN (strcat LYR "-DEMO"))
  49.             )) ;;end if -DEMO already there
  50.         ) ;;end REPEAT
  51.       )) ;;end SS test
  52.   (princ)
  53.   )
  54.  
It's 'O'Neill', with three L's!!!! (Jack O'Neill)

kpblc

  • Bull Frog
  • Posts: 396
Re: LISP command broke in 2020....
« Reply #1 on: April 02, 2020, 05:10:40 PM »
Try to add (vl-load-com) to your code.
Ooops. I didn't check the code. You done it.
I got this error in case on broken install of ACAD. Maybe full reinstall could help you?
« Last Edit: April 03, 2020, 12:34:28 AM by kpblc »
Sorry for my English.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: LISP command broke in 2020....
« Reply #2 on: April 02, 2020, 06:18:32 PM »
I had the same issue on the first install of 2021 .. I removed it, then reinstalled and did not migrate profiles.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC


d2010

  • Bull Frog
  • Posts: 326
Re: LISP command broke in 2020....
« Reply #4 on: April 03, 2020, 11:56:08 AM »
If you pay me, then I can translate your-program, into 100%autolisp(for AutoCAD ver2004+ or better),
 no more (vl-load-com). If idyes then you send PM at       MessageBox(Wnd: Integer; Text: PChar)

Quote
RE: The error is -->  ;error: no function definition: VLAX-ENAME->VLA-OBJECT

« Last Edit: April 03, 2020, 12:01:06 PM by d2010 »