TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Bred on July 13, 2007, 03:38:23 AM

Title: 2008 : The layer locked... not attenuate ?
Post by: Bred on July 13, 2007, 03:38:23 AM
Hello everybody,
for 2008.
When I makes :
Code: [Select]
(vla-put-Lock (vlax-ename->vla-object (tblobjname "LAYER" "Layer")) :vlax-True)The layer is locked… but the objects does not attenuate… (LAYLOCKFADECTL at 50)

Code: [Select]
(command "_-layer" "_lock" "Layer" "" "")it's good... but  :-(

an idea?

thank you
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Jeff_M on July 13, 2007, 10:50:19 AM
Check out  THIS  (http://www.theswamp.org/index.php?topic=15677.msg190781#msg190781) post.

Oh, and welcome to theSwamp!
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Bred on July 13, 2007, 11:11:58 AM
Thanks!

But:
Code: [Select]
  (setq fadeSet(vla-getvariable activeDoc "LAYLOCKFADECTL"))
(vla-setvariable activeDoc "LAYLOCKFADECTL" 0)
(vla-setvariable activeDoc "LAYLOCKFADECTL" fadeSet)
for locked : OK
for unlocked : No....  :|
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Jeff_M on July 13, 2007, 07:02:40 PM
Heh, you are absolutely correct! Now why didn't anyone else catch that? Let me see what I can find out.
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Bred on July 17, 2007, 12:27:10 PM
Hello, then :  :?

Code: [Select]
(vla-Regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)it's good... but very heavy...  :|

and

Code: [Select]
(repeat (setq x (sslength (setq sel (ssget "_X" (list (cons 8 "my_layer"))))))
    (vla-update (vlax-ename->vla-object (ssname sel (setq x (1- x)))))
    )
it's good... except "error layer locked" ....  :x
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Jeff_M on July 19, 2007, 01:36:31 PM
Hi Bred,
The answer I got from the higher ups is:
Quote
Another suggestion for this behavior is to manipulate a “Layer state”. You don’t have do this manipulation for each and every layer you manipulate, but only when once you have finished with locking/unlocking your required layers.
So here's lisp code that does this:
Code: [Select]
;;test the lock/unlock display for "Layer1"
(defun c:locktest (/ lays *acad doc lstates)
  (vl-load-com)
  (setq *acad (vlax-get-acad-object)
doc (vla-get-activedocument *acad)
lay (vla-item (vla-get-layers doc) "Layer1"))
  (if (= :vlax-true (vla-get-lock lay))
    (vla-put-lock lay :vlax-false)
    (vla-put-lock lay :vlax-true)
    )
  (setq lstates (vla-getinterfaceobject *acad "AutoCAD.AcadLayerStateManager.17"))
  (vla-setdatabase lstates (vla-get-database doc))
  (vla-save lstates "ColorLType" (+ acLsColor acLsLineType))
  (vla-restore lstates "ColorLType")
  (vla-delete lstates "ColorLType")
  (vla-regen doc acActiveViewport)
  (princ)
  )
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Bred on July 19, 2007, 06:28:30 PM
Code: [Select]
(vla-regen doc acActiveViewport)Thanks...
but look at my message above...
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Jeff_M on July 19, 2007, 07:26:56 PM
I did, and I tested it and it did not work in 2 drawings I tested it with. The folks I spoke with that came up with this idea verified it as well.

To be sure, I just now tested and unless I use the method posted earlier the layer stays faded.

I modified my test to have the regen occur between the double setting of the sysvar and this does work.

Code: [Select]
(defun c:locktest2 (/ lays *acad doc lay fadeset)
  (setq *acad (vlax-get-acad-object)
doc (vla-get-activedocument *acad)
lay (vla-item (vla-get-layers doc) "Layer1")
)
  (if (= :vlax-true (vla-get-lock lay))
    (vla-put-lock lay :vlax-false)
    (vla-put-lock lay :vlax-true)
    )
  (setq fadeSet (vla-getvariable doc "LAYLOCKFADECTL"))
 
  (vla-setvariable doc "LAYLOCKFADECTL" 0)
  (vla-regen doc acActiveViewport)
  (vla-setvariable doc "LAYLOCKFADECTL" fadeSet)
  (princ)
  )
Oh, wait.....are you talking about this?:
it's good... but very heavy...  :|
If so, then yes, it's "heavy". Either posted method requires the use of regen, but short of Autodesk supplying a fix to the API I don't see a better way.
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Bred on July 20, 2007, 02:55:20 AM
OK !   
thank you very much...
Title: Re: 2008 : The layer locked... not attenuate ?
Post by: Kerry on July 20, 2007, 03:29:52 AM
'he aint heavy, he's my brother'

[ dedicated to soulmates who survived the 60's ]


useful solution Jeff !