Author Topic: Help : filter dimension layer  (Read 448 times)

0 Members and 1 Guest are viewing this topic.

mhy3sx

  • Newt
  • Posts: 166
Help : filter dimension layer
« on: June 30, 2024, 01:32:13 PM »
Hi I want to to search the drawin and if any dimensions in the drawing to move them to layer DIM, but if not any dimensions to
Code: [Select]
    (princ "No dimensions found.") 

and aboard the code.

The code bellow works perfect if dimension exist in drawing , but if there is no dimension gives me this error

Code: [Select]
Current layer: DIM
Enter an option [?/New/Make/Set/Color/Ltype/LWeight/Plot/ON/OFF/Freeze/Thaw/LOck/Unlock/Rename/Description/DELete/stAte/TRansparency]: DIM
Invalid keyword.


Code - Auto/Visual Lisp: [Select]
  1. (defun c:DLDL (/ sel1 CLAYER )
  2.    (command "_.Tilemode" 1) ; ;Switch from Layout Tab To Model Tab before stating LISP
  3.  
  4.   (if (setq sel1 (ssget "X" '((0 . "DIMENSION") (-4 . "<NOT") (8 . "ARROWLINE") (-4 . "NOT>")))) ; SELECT ALL DIMENSION
  5.      (progn
  6.       (setq OLDLAYER (getvar "CLAYER")) ;GET CURRENT LAYER
  7.       (setvar "CLAYER" OLDLAYER) ; SET ACTIVE LAYER TO PREVIOUS
  8.          
  9.          (if (=(tblsearch "layer" "DIM") nil)
  10.       (command "_layer" "_m" "DIM" "_c" "7" "" "_lw" "0.30" "" "")
  11.      );end if
  12.          
  13.       (command "CHPROP" sel1 "" "LAYER" "DIM" "")  ; CHANGE DIMENSION LAYER TO NEW LAYER
  14.       (command "._draworder" sel1 "" "_f")
  15.           (command "-DIMSTYLE" "R" "STANDARD")
  16.      );end progn
  17.     (princ "No dimensions found.") ; Handle case when no dimensions are selected
  18.   );end if
  19. ;Layer 0
  20. (mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1))
  21.     (princ)
  22. )
  23. );end def
  24.  

Thanks

mhy3sx

  • Newt
  • Posts: 166
Re: Help : filter dimension layer
« Reply #1 on: June 30, 2024, 05:12:58 PM »
I update  hte code , but gives me

Code: [Select]
Command: DLDL
Invalid keyword.
Error: Function cancelled
Enter an option [?/New/Make/Set/Color/Ltype/LWeight/Plot/ON/OFF/Freeze/Thaw/LOck/Unlock/Rename/Description/DELete/stAte/TRansparency]:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:DLDL (/ sel1 CLAYER )
  2.    (command "_.Tilemode" 1) ; ;Switch from Layout Tab To Model Tab before stating LISP
  3.  
  4.   (if (setq sel1 (ssget "X" '((0 . "DIMENSION") (-4 . "<NOT") (8 . "ARROWLINE") (-4 . "NOT>")))) ; SELECT ALL DIMENSION
  5.      (progn
  6.       (setq OLDLAYER (getvar "CLAYER")) ;GET CURRENT LAYER
  7.       (setvar "CLAYER" OLDLAYER) ; SET ACTIVE LAYER TO PREVIOUS
  8.          
  9.          (if (=(tblsearch "layer" "DIM") nil)
  10.       (command "_layer" "_m" "DIM" "_c" "7" "" "_lw" "0.30" "" "")
  11.      );end if
  12.          
  13.       (command "CHPROP" sel1 "" "LAYER" "DIM" "")  ; CHANGE DIMENSION LAYER TO NEW LAYER
  14.       (command "._draworder" sel1 "" "_f")
  15.           (command "-DIMSTYLE" "R" "STANDARD")
  16.      );end progn
  17.     (princ "No dimensions found.") ; Handle case when no dimensions are selected
  18.   );end if
  19. ;Layer 0
  20. (mapcar 'setvar '(clayer cecolor celtype celweight) (list "0" "BYLAYER" "BYLAYER" -1))
  21.     (princ)
  22. );end def
  23.  
  24.  
  25.  

Any ideas?

Thanks

ribarm

  • Gator
  • Posts: 3327
  • Marko Ribar, architect
Re: Help : filter dimension layer
« Reply #2 on: June 30, 2024, 05:49:07 PM »
You don't need lines 6 and 7... And you don't have CLAYER variable to localize it in (defun...( / ... ))
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

mhy3sx

  • Newt
  • Posts: 166
Re: Help : filter dimension layer
« Reply #3 on: June 30, 2024, 06:00:56 PM »
Thanks  ribarm .  :smitten: