I cant figure out the problem with this lisp file.
If the layer is already frozen upon opening the drawing it wont work. I have to manually unfreeze it for this lisp to start working.
Any help would be appreciated.
(defun MVT nil (FreezeThawLayer "Model Views")
(princ)
)
(defun FreezeThawLayer ( layer / dx en )
(if (null (setq en (tblobjname "LAYER" layer)))
(entmake
(list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 layer)
'(70 . 0)
)
)
(setq en (entget en)
dx (assoc 70 en)
en (entmod (subst (cons 70 (boole 6 1 (cdr dx))) dx en))
)
)
(princ)
)
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
I just tried your code and it DOES work (C3D 2020).
Just sidenote. Don't like a bit that code allows freezing of the current layer. That should be excluded.
It worked for me [Acad2019] -- I don't know what to suggest [having no failure to analyze].
It's not working in plain AutoCAD (for this situation you talk about),
so it isn't a advance steel thing- It's a core AutpCAD thing.
To correct the statement "I have to manually unfreeze it for this lisp to start working."
@Anonymous
The code works a also in this situation as expected, but the layer objects are still not displaying!
The Layer is thawed, new objects on this layer are visible too, but not the older existed objects.
Sebastian
It needs a regen or an (entupd)
(defun MVT nil (FreezeThawLayer "Model Views")
(princ)
)
(defun FreezeThawLayer ( layer / dx en el)
(if (null (setq en (tblobjname "LAYER" layer)))
(entmake
(list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
(cons 2 layer)
'(70 . 0)
)
)
(setq el (entget en)
dx (assoc 70 el)
el (entmod (subst (cons 70 (boole 6 1 (cdr dx))) dx el))
)
)
(if en (entupd en))
(princ)
)
I am not one of the robots you're looking for
@dlanorh schrieb:
It needs a regen or an (entupd)
Just guessing or also tested?
It will not change the problem (tested with a simple plain AutoCAD-DWG in ACAD 2013,2021 and also with C3D2021).
1. Objects in model tab, layer was freezed and current view is in model tab > at the last save
2. Open the file, run the program
3. Layer is thawed after (FreezeThawLayer "Model Views"),
new objects on this layer appears but the old objects are still not visible
Switch to Layout TAB and back to model will fix the problem.
_tilemode 0 _tilemode 1
but this isn't a smart way.
Do you know how to reproduce the problem yourself (according to my instructions)?
Sebastian
@Jonathan3891 wrote:
....
If the layer is already frozen upon opening the drawing it wont work. ....
The discussion of whether a REGEN is needed raises the question: What does "it wont work" above mean? Have you tried using it and then REGEN-ing to make what's on that Layer appear? Or does it not Thaw the Layer at all? Or is the not-working some other issue?
It certainly was once true that if a Layer was frozen when the drawing was opened, AutoCAD had not thought about what's on that Layer at all yet, and if you then Thawed it, it was necessary to REGEN to see that content. But now it doesn't seem to be needed, at least in a quickie trial, but maybe there are other circumstances I haven't thought of that can sometimes still make it necessary.
1. Objects in model tab, layer was freezed and current view is in model tab > at the last save
2. Open the file, run the program
3. Layer is thawed after (FreezeThawLayer "Model Views"),
new objects on this layer appears but the old objects are still not visible
REGEN
REGENALL
REDRAW
REDRAWALL
ZOOM
PAN
creating new objects
entupd (the Layer)
entupd (the object)
still invisible
edit the object(s) by command like MOVE
or ENTMOD the object
or switching to a layout and back to model tab
and the objects appears
Sebastian
Time to go other ways, use the extended VisualLisp functions
(setq LAYER (vla-item (vla-get-layers (vla-get-activeDocument(vlax-get-Acad-Object))) "Model views"))
(vla-put-Freeze LAYER :vlax-false) / (vla-put-Freeze LAYER :vlax-true)
Sebastian
Tested, in 2012 with a named view. I cannot test any later versions of AutoCAD. The OP needs to supply a standard example drawing otherwise we are all testing in the dark. If it works on some systems and not others this suggests a possible different system variable setting somewhere.
I am not one of the robots you're looking for
How about going the other way, to the more simple and direct Layer command? Does it work for you this way [it does for me, but then so did your original]?
(defun FreezeThawLayer (layer / laydata)
(if (not (setq laydata (tblsearch "LAYER" layer)))
(command "_.layer" "_make" layer ""); then
(command "_.layer" ; else
(if (= (logand 1 (cdr (assoc 70 laydata))) 1); frozen?
"_thaw" ; then
"_freeze" ; else
); if
layer ""
;;; "_.regen" ;;; optional if needed?
); command
); if
(princ)
); defun
[It should perhaps also have something added to prevent Freezing the current Layer, but it will simply fail if you try it on that Layer, so maybe the resulting error message would be enough -- it's not like you're going to want it to Freeze some other Layer in that situation.]
Can't find what you're looking for? Ask the community or share your knowledge.