Hi all,
I was wondering if there was a way to store layer states , ie. lock, freeze, on/off, as a varible. One of the routines I've created draws a line then offsets that line a certain distance automaticly and then places the offset line on a specified layer. The problem I'm having is that the routine dosen't work if the offset layer is locked, off or frozen and my error routine dosen't seem to catch this flaw. So what I want to do is test this layer for one or more of these states. Store this data in a variable. Run the routine and then restore these states. Please let me know if this is possible.
Thanks in advance
🙂
Solved! Go to Solution.
Solved by BlackBox_. Go to Solution.
Without seeing your code, here's all I can slap together:
(vl-load-com) (defun c:FOO (/ *error* acDoc layerName oLayer) (defun *error* (msg) (if acDoc (vla-endundomark acDoc) ) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it ) (princ) ) ;;<-- If, some condition(s) ;; start the undomark (vla-startundomark (setq acDoc (vla-get-activedocument (vlax-get-acad-object))) ) ;; get, or create the target LayerTableRecord (setq oLayer (vla-add (vla-get-layers acDoc) (setq layerName "YourLayerName") ) ) (vla-put-layeron oLayer :vlax-true) (vla-put-lock oLayer :vlax-false) (vla-put-freeze oLayer :vlax-false) ;;<-- Do something useful (*error* nil) )
HTH
"How we think determines what we do, and what we do determines what we get."
Also, to clarify, you're after Layer Properties... Layer States are another animal altogether; see the LayerState* functions in the developer help for more information.
Cheers
"How we think determines what we do, and what we do determines what we get."
I'm sorry if I misspoke. I thought that layer properties were things like the color, line weight, ect. It looks like your accessing these properties through vla code...... I'll give this a try. I haven't tried vla yet due to the lack of vla info on the net. Thanks and I'll let you know how it goes. BTW. I love your logo. It's simple and elegant.
Oh and good point about my code.... here it is if anyone wants to look at it
(defun c:fsb (/ kw1 las las1 las2 las3 acadObject acadDocument mSpace OldLayer *error* errMarker errTempSelectionSet)
(vl-load-com)
(setvar "cmdecho" 0)
(setq acadObject (vlax-get-acad-object))
(setq acadDocument (vlax-get-property acadObject 'ActiveDocument))
(setq mSpace (vlax-get-property acadDocument 'Modelspace))
(defun *error* ( msg )
(setq *error* originalError)
(setvar "cmdecho" 0)
(while (setq errMarker (entnext errMarker))
(setq errTempSelectionSet (ssadd errMarker errTempSelectionSet ))
)
(command ".erase" errTempSelectionSet "")
(setvar "cmdecho" 1)
(setvar "filedia" 1)
(command "ucs" "p")
(setvar "CLAYER" OldLayer)
(setvar "OSMODE" oldsnap)
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(princ)
)
(if (= kw nil)(setq kw "36")
)
(setq kw1 kw)
(initget "36 18")
(setq kw (getkword (strcat"\nEnter setback distance in inches [36/18] <"kw">:")))
(if (= kw nil)
(setq kw kw1))
(setq las (entlast))
(command "_.pline")
(while (> (getvar 'cmdactive) 0)
(command pause)
); end while
(command ".undo" "begin")
(cond
(if (not (eq (setq las1 (entlast)) las))
(vl-cmdf "_.offset" kw las1 pause "")
); if
); cond
(cond
(if (tblsearch "LAYER" "FireSetBack")
(setq OldLayer (getvar "CLAYER"))
(setq OldLayer (getvar "CLAYER"))
(command "_layer" "n" "FireSetBack" "" "")
)
)
(setq las2 (entlast))
(setq las3 (vlax-ename->vla-object las2))
(vlax-put-property las3 'layer "FireSetBack")
(command "explode" las1 )
(command "explode" las2 )
(command "_layer" "m" "FireSetBack" "c" 4 "" "")
(setvar "CLAYER" OldLayer)
(command ".undo" "end")
(princ)
)
@vivifira wrote:
I was wondering if there was a way to store layer states , ie. lock, freeze, on/off, as a varible.... So what I want to do is test this layer for one or more of these states. Store this data in a variable. Run the routine and then restore these states.
@vivifira wrote:
I'm sorry if I misspoke. I thought that layer properties were things like the color, line weight, ect.
No worries; I knew what you meant, just wanted to clarify for others.
@vivifira wrote:
It looks like your accessing these properties through vla code...... I'll give this a try. I haven't tried vla yet due to the lack of vla info on the net. Thanks and I'll let you know how it goes.
You are correct; this has been one of the major complaints about the developer documentation. It is very similar to the VBA developer documentation, which is often used, as they both (VBA & Visual LISP) are ActiveX APIs.
For a more complete (not necessarily up-to-date) reference, consider this link which I've used for some time with great success:
http://entercad.ru/acadauto.en/
@vivifira wrote:
BTW. I love your logo. It's simple and elegant.
That is very kind of you to say; thank you.
Cheers
"How we think determines what we do, and what we do determines what we get."
@vivifira wrote:
Thanks for you help. It took some research but you point me in the right direction. Here is the modified code:
...
It now ignores weather my layer is on/off, frozen or locked. Thanks for making this routine more powerful. 🙂
That is kind of you to say; I'm happy to help, but you did the work.
Cheers
"How we think determines what we do, and what we do determines what we get."