Author Topic: lisp issue after autocad upgrade  (Read 2946 times)

0 Members and 1 Guest are viewing this topic.

Pad

  • Bull Frog
  • Posts: 342
lisp issue after autocad upgrade
« on: May 15, 2015, 04:53:39 AM »
Hi I have recently upgraded from 2009 to 2015 and have a little issue with the attached lisp.

The lisp will put selected objects onto a frozen layer prefixed with 'clashing-".
The problem is with attributed blocks the block remains on screen until I pan or zoom.  I have tried adding (command “zoom” sc “.99xp”)  to the end of the lisp but it hasn't fixed the issue.
I'm not sure if it is an issue with the lisp or my autocad.  Has anything changed in autocad of the last few years which could cause this behaviour?
I would appreciate it if someone could have a look please.

Code: [Select]
;; http://forums.augi.com/showthread.php?t=133972
;; Demonstration of how object layers can be manipulated.
;; Also demonstrates string parsing, destruction, and reconstruction
;; tricks available in Visual LISP.
;;

(vl-load-com)

(defun c:cl (/) (C:clashing_Levels)) ; shortcut

(defun C:clashing_Levels ( / SS CNT LYR SLYR vEN EN LyrNew LyrTab oLayers tChr nSuf nPre)

  (prompt "\nChange selected objects to layer prefixed by 'Clashing':")
  ;;

  (setq tChr "_") ;;<<-- variable delimiter
;  (setq tChr "-") ;;<<-- variable delimiter

  (setq nSuf "") ;;<<--- your new suffix
  (setq nPre "Clashing - ") ;;<<--- your new prefix
  ;;
  (setq SS (ssget))
  (if (and SS (> (sslength SS) 0))
    (progn
      (setq oLayers ;;get layer table link
     (vla-get-layers
       (vla-get-activedocument
(vlax-get-acad-object))))
      ;;
      ;;Got the objects, now stream through them
      (repeat (setq CNT (sslength SS))
;;
(setq En (ssname SS (setq CNT (1- CNT))) ;;Entity name from set
      vEN (vlax-ename->vla-object En) ;;entity object reference
      LYR (vla-get-layer vEN);;get the layer name
      sLYR LYR
      )
;;
;;check to see if already changed
;;
(if (not (wcmatch LYR (strcat nPre "*" nSuf)))
  (progn
    ;;
    ;; LYR does not match the pattern test
    ;;
    ;; Change the prefix only if nPRE is not empty and the
    ;; delimeter can be found in the source layer name.
    ;;
    (if (/= nPRE "") ;;change the prefix?
      (progn
(if (wcmatch LYR (strcat "*" tChr "*")) ;;find the delim?
    (setq LYR (vl-string->list LYR) ;;change to list
  LYR (member (ascii tChr) LYR) ;;trim to delim
  LYR (vl-list->string LYR)) ;;back to string
  )
(setq LYR (strcat nPRE LYR)) ;;add new prefix
)) ;;end IF nPRE progn
    ;;
    (if (/= nSUF "") ;;change the suffix?
      (progn
(if (wcmatch LYR (strcat "*" tChr "*")) ;;find the delim okay?
    (setq LYR (vl-string->list LYR) ;;convert LYR name to list of ASCIIs
  LYR (reverse LYR)         ;;flip it around
  LYR (member (ascii tChr) LYR) ;;trim to delim
          LYR (reverse LYR) ;;flip it back to forward
  LYR (vl-list->string LYR)) ;;back to string
    )
(setq LYR (strcat LYR nSUF))
)) ;;end IF nSUF progn
    ;;
    ;; Check to see if the new layer exists
    ;;
    (if (not (tblsearch "LAYER" LYR))
      (progn ;;add the new layer
        (setq LyrNew (vla-add oLayers LYR)
      LyrTab (vla-item oLayers sLYR)
      )
;; Clone the properties

(vla-put-linetype LyrNew (vla-get-linetype LyrTab)) ; clone layer linetype
; (vla-put-Linetype LyrNew "HIDDEN") ; set layer linetype hidden
; (vla-put-color LyrNew 6) ; set layer colour
(vla-put-truecolor LyrNew (vla-get-truecolor LyrTab)) ; clone layer colour
(vla-put-freeze LyrNew :vlax-true) ; set layer freeze state
; (vla-put-freeze LyrNew (vla-get-freeze LyrTab)) ; clone layer freeze state
(vla-put-layeron LyrNew (vla-get-layeron LyrTab))
(vla-put-lineweight LyrNew (vla-get-lineweight LyrTab))
(vla-put-lock LyrNew (vla-get-lock LyrTab))
(vla-put-material LyrNew (vla-get-material LyrTab))
;(vla-put-plotstylename LyrNew (vla-get-plotstylename LyrTab))
)) ;;end layer add
    ;;
    ;; Update the layer name of the object
    (vla-put-layer vEN LYR)
    )) ;;end if _DEMO already there
) ;;end REPEAT
      )) ;;end SS test
(command “zoom” sc “.99xp”)  ; pb added to try and fix display issue
  (princ)
  )

ChrisCarlson

  • Guest
Re: lisp issue after autocad upgrade
« Reply #1 on: May 15, 2015, 08:50:52 AM »
Instead of

Code - Auto/Visual Lisp: [Select]
  1. (command “zoom” sc “.99xp”)

Try a manual regen,
Code - Auto/Visual Lisp: [Select]
  1. (command "_.regen")

Pad

  • Bull Frog
  • Posts: 342
Re: lisp issue after autocad upgrade
« Reply #2 on: May 15, 2015, 08:58:19 AM »
Hi Chris,

thanks for your input, unfortunalty that doesnt work either. Panning with the centre wheel on the mouse corrects the ghost block.
I wonder if it is more of a problem with the graphics card.  But saying that I have the same happening on another machine (gtx 980m and quadro 400), so it muct be an autocad thing.

P

tedg

  • Swamp Rat
  • Posts: 811
Re: lisp issue after autocad upgrade
« Reply #3 on: May 15, 2015, 09:11:42 AM »
Hi Chris,

thanks for your input, unfortunalty that doesnt work either. Panning with the centre wheel on the mouse corrects the ghost block.
I wonder if it is more of a problem with the graphics card.  But saying that I have the same happening on another machine (gtx 980m and quadro 400), so it muct be an autocad thing.

P
How about (command "_.regenall")?
Windows 10 Pro 64bit, AutoCAD 2023, REVIT 2023

Pad

  • Bull Frog
  • Posts: 342
Re: lisp issue after autocad upgrade
« Reply #4 on: May 15, 2015, 09:32:02 AM »
no doesnt fix it, a simple zoom with the mouse wheel does though.
very weird.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: lisp issue after autocad upgrade
« Reply #5 on: May 15, 2015, 09:32:07 AM »
Or non command line method:

Code - Auto/Visual Lisp: [Select]
  1. (if (> (atof (getvar 'acadver)) 19)
  2. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ChrisCarlson

  • Guest
Re: lisp issue after autocad upgrade
« Reply #6 on: May 15, 2015, 09:35:44 AM »
Actually, I was able to run this perfectly on 2016

Pad

  • Bull Frog
  • Posts: 342
Re: lisp issue after autocad upgrade
« Reply #7 on: May 15, 2015, 11:06:36 AM »
Hi Ronjp,  thanks for that, but it doesnt work.
Chris, yes the lisp runs well, and creates the layer etc.  it is just the block remains on screen until I manually zoom about.

Heres is a screen cast http://autode.sk/1QPhoAS

P

ChrisCarlson

  • Guest
Re: lisp issue after autocad upgrade
« Reply #8 on: May 18, 2015, 08:04:48 AM »
I'm thinking it might be a system variable on your end. I cannot recreate it.l

Pad

  • Bull Frog
  • Posts: 342
Re: lisp issue after autocad upgrade
« Reply #9 on: May 20, 2015, 09:35:03 AM »
Thanks Chris.  Is that using 2016 or 2015?

ChrisCarlson

  • Guest
Re: lisp issue after autocad upgrade
« Reply #10 on: May 20, 2015, 01:12:41 PM »
2016

Pad

  • Bull Frog
  • Posts: 342
Re: lisp issue after autocad upgrade
« Reply #11 on: May 26, 2015, 11:20:16 AM »
Hi Chris,

The lisp is working fine now.  I think it might have something to do with having a point cloud attached or not.
Maybe a regen setting is changed when point clouds are used or something similar..

Cheers
P