Unlock all layer via browse folder file

Unlock all layer via browse folder file

Anonymous
Not applicable
1,048 Views
4 Replies
Message 1 of 5

Unlock all layer via browse folder file

Anonymous
Not applicable

Hello 

 

Can someone tell me code Unlock all layer via browse folder file.

 

Thanks

0 Likes
1,049 Views
4 Replies
Replies (4)
Message 2 of 5

rkmcswain
Mentor
Mentor
Are you asking how to unlock all layers in multiple drawing files?

Please clarify. Thanks.

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 5

Anonymous
Not applicable

Yep unlock all layers in multiple drawing file via browse folder.

 

 

0 Likes
Message 4 of 5

sanganaksakha
Advocate
Advocate

Hello,

 

You will have to write a batch program. There are many ways to do that. I think VBA would be easier although Vlisp also could do that.

 

Basically, you write a code to unlock all layers in a drawing and then in the main program, open each drawing. load and run the program.

 

- Sanjay Kulkarni<http://www.linkedin.com/in/sanjaykulkarnipune?

0 Likes
Message 5 of 5

patrick_35
Collaborator
Collaborator

Hi

 

Adapted from one of my lisp

;;;=================================================================
;;;
;;; LAY.LSP V1.00
;;;
;;; Déverrouiller tous les calques de tous les dessins d'un répertoire
;;;
;;; Copyright (C) Patrick_35
;;;
;;;=================================================================

(defun c:lay(/ 	att ava bl dbx express fic lay lst obj rep  s tot ver
		*errlay* msgbox dirbox ouvrir_dessin_dbx)

  ;;;---------------------------------------------------------------
  ;;;
  ;;; Gestion des erreurs
  ;;;
  ;;;---------------------------------------------------------------

  (defun *errlay* (msg)
    (or (member (strcase msg) '("FUNCTION CANCELLED" ""QUIT / EXIT ABORT"" "FONCTION ANNULEE" "QUITTER / SORTIR ABANDON"))
      (princ (strcat "\nErreur : " msg))
    )
    (vla-endundomark doc)
    (setq *error* s)
    (princ)
  )

  ;;;---------------------------------------------------------------
  ;;;
  ;;; Message
  ;;;
  ;;;---------------------------------------------------------------

  (defun msgbox (Titre Bouttons Message / Reponse WshShell)
    (setq WshShell (vlax-create-object "WScript.Shell"))
    (setq Reponse  (vlax-invoke WshShell 'Popup Message 0 Titre (itoa Bouttons)))
    (vlax-release-object WshShell)
    Reponse
  )

  ;;;---------------------------------------------------------------
  ;;;
  ;;; Choix du répertoire
  ;;;
  ;;;---------------------------------------------------------------

  (defun dirbox(/ bas cdl rep)
    (if (setq cdl (vlax-create-object "Shell.Application"))
      (progn
	(and (setq rep (vlax-invoke cdl 'browseforfolder 0 "Choose a directory to process all the drawings and unlock all layers" 512 ""))
	     (setq rep (vlax-get-property (vlax-get-property rep 'self) 'path))
	)
	(vlax-release-object cdl)
      )
    )
    rep
  )

  ;;;---------------------------------------------------------------
  ;;;
  ;;; Ouvrir un dessin via ObjectDbx
  ;;;
  ;;;---------------------------------------------------------------

  (defun Ouvrir_dessin_dbx(dwg / dbx doc lan rel)
    (and (setq dwg (findfile dwg))
      (progn
	(vlax-for doc (vla-get-documents (vlax-get-acad-object))
	  (and (eq (strcase (vla-get-fullname doc)) (strcase dwg))
	    (setq dbx doc lan T)
	  )
	)
	(and (not dbx)
	  (setq dbx (vlax-create-object (if (< (setq rel (atoi (getvar "ACADVER"))) 16)
					  "ObjectDBX.AxDbDocument"
					  (strcat "ObjectDBX.AxDbDocument." (itoa rel))
					)
		    )
	  )
	  (vla-open dbx dwg)
	)
      )
    )
    (list dbx lan)
  )

  ;;;---------------------------------------------------------------
  ;;;
  ;;; Routine principale
  ;;;
  ;;;---------------------------------------------------------------

  (vl-load-com)
  (setq s *error*
	*error* *errlay*
  )
  (if (eval 'acet-ui-progress-done)
    (setq express T)
  )
  (if (setq rep (dirbox))
    (if (setq lst (vl-directory-files rep "*.dwg" 1))
      (foreach fic lst
	(if (setq dbx (ouvrir_dessin_dbx (strcat rep "/" fic)))
	  (progn
	    (setq tot (vla-get-count (vla-get-layers (car dbx)))
		  ava 0
	    )
	    (and express
	      (acet-ui-progress-init "" tot)
	    )
	    (princ (strcat "\n Work in " fic))(princ)
	    (vlax-for lay (vla-get-layers (car dbx))
	      (and (eq (vla-get-lock lay) :vlax-true)
		(vla-put-lock lay :vlax-false)
	      )
	      (and express
		(setq ava (1+ ava))
		(acet-ui-progress-safe ava)
	      )
	    )
	    (and express
	      (acet-ui-progress-done)
	    )
	    (or (cadr dbx)
	      (progn
		(princ " ...Save")(princ)
		(vla-saveas (car dbx) (strcat rep "/" fic))
		(vlax-release-object (car dbx))
	      )
	    )
	    (princ " ...OK")(princ)
	  )
	  (princ (strcat "\n Unable to read file " fic))
	)
      )
      (msgbox "LAY" 64 (strcat "No drawing in " rep))
    )
  )
  (setq *error* s)
  (princ)
)
0 Likes