Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I'm new to scripting. Is there a way to freeze a common layer in all open drawings?
Thanks
Solved! Go to Solution.
Hi
I'm new to scripting. Is there a way to freeze a common layer in all open drawings?
Thanks
Solved! Go to Solution.
Thanks for your quick reply. Allow the user to specify a layer (which is common in all open drawings).
@tfitzhardinge wrote:
Thanks for your quick reply. Allow the user to specify a layer (which is common in all open drawings).
You need to download this function LM:listbox here--> Lee Mac | List box function
Here's the general idea
(defun c:FCLDs ( / docs Alllayers docColl cnt ltfz )
(setq Alllayers nil docColl nil);;<--- for debugging, you can remove this
(vlax-map-Collection
(vla-get-documents (vlax-get-acad-object))
(function (lambda (itm / f lnm)
(setq docColl (cons itm docColl))
(vlax-for l (Vla-get-layers itm)
(setq Alllayers
(cond
((setq
f (assoc (setq lnm (vla-get-name l)) Alllayers)
)
(cons (list (car f) (cons l (cadr f)))
(vl-remove f Alllayers)
)
)
((cons (list lnm (list l)) Alllayers))
)
)
)
)
)
)
(setq cnt (length docColl)
Alllayers (Vl-remove-if-not (function (lambda (ls)
(= (length (Cadr ls)) cnt))) Alllayers))
(setq ltfz (LM:listbox "Select layer name to freeze" (mapcar 'car Alllayers) 1))
(foreach itm ltfz
(foreach lay (cadr (assoc itm Alllayers))
(if (vl-catch-all-error-p
(Vl-catch-all-apply 'vlax-put (list lay 'Freeze -1)))
(princ "\nLayer is current")
)
)
)
;; saving the file to reflect the changes on the rest of the inactive drawings;;
(mapcar 'vla-save docColl)
(princ)
)
HTH
Thanks for the solution. I'll try it out.
Is there was a lsp script solution to this. However I don't really know my options when it comes to scripting and coding options in autocad. Is it possible to run a lsp file with autocad commands through a batch file that targets drawings in a particle folder. I ran script pro 6 years ago and ran lsp file through it. I am under the impression that script pro doesn't receive any support.
@tfitzhardinge wrote:
Thanks for the solution. I'll try it out.
Is there was a lsp script solution to this. However I don't really know my options when it comes to scripting and coding options in autocad. Is it possible to run a lsp file with autocad commands through a batch file that targets drawings in a particle folder. I ran script pro 6 years ago and ran lsp file through it. I am under the impression that script pro doesn't receive any support.
I see, what you asked for, "in all open drawings", the posted code will do as you ask.
As for running through files on a folder. Yes Script pro is still in the mix
Try this.. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-freeze-thaw/td-p/6801628
;;-------------------------------------------------------------------------------;;
;; START Batch Freeze ;;
;;-------------------------------------------------------------------------------;;
command:batchfreeze
command:c:batchthaw
Try codes posted at post # 1 & 4
post # 1 : prompts the user for a specific layer
Command: BATCHFREEZE
Specify layer to freeze <exit>: *Cancel*
post # 4 : List of layers present on the current drawing
and another dialog to select the files.
HTH
@pbejse thank you so much for your assistance on this matter. I need to test out the solution but for now I'll accept the solution. I'll open it up if after I have done enough testing I have additional queries.
Thanks