Author Topic: How to get layer locked ..  (Read 9492 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
How to get layer locked ..
« on: October 26, 2005, 03:18:50 PM »
How can I get if the selected item is layer locked or not ??

(entget (car (entsel)))

this can't tell me.. :|
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get layer locked ..
« Reply #1 on: October 26, 2005, 03:22:54 PM »
Andrea, are you joking ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How to get layer locked ..
« Reply #2 on: October 26, 2005, 03:24:17 PM »
It's not pretty but this is what I threw together:
Code: [Select]
  (vl-load-com)
  (while
    (= ent nil)
     (setq ent (car (entsel)))
     (if (= ent nil)
       (alert "\n You missed, try again...")
     )
  )
  (setq obj   (vlax-ename->vla-object ent)
lyr   (vla-get-Layer Obj)
lay   (cdr (caddr (tblsearch "layer" lyr)))
  )
  (if (= lay 4)
    (alert (strcat "\nLayer " lyr " is locked!"))
  )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get layer locked ..
« Reply #3 on: October 26, 2005, 03:25:16 PM »
« Last Edit: October 27, 2005, 12:29:43 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to get layer locked ..
« Reply #4 on: October 26, 2005, 03:28:29 PM »
maybe is a stupid question...or maybe to much work..

but this is not a joke...I'm sure it is simple...or I'm missing something...
but if some one can tell me how....I'll be glad to realize that i'm stupid.. :ugly:
Keep smile...

Dent Cermak

  • Guest
Re: How to get layer locked ..
« Reply #5 on: October 26, 2005, 03:32:27 PM »
You are not stupid, you just don't know it all yet.......like some here.  :-D   ;-) When you hit the point where you have it all figured out, let me know. I still have many questions too. :|

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get layer locked ..
« Reply #6 on: October 26, 2005, 03:32:51 PM »
Andrea, it's not stupid, just basic.
It scares me a little that someone who produces commercial software asks a question like this.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get layer locked ..
« Reply #7 on: October 26, 2005, 03:34:35 PM »
Andrea, it's not stupid, just basic.
It scares me a little that someone who produces commercial software asks a question like this.

<game buzzer>

That is correct.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to get layer locked ..
« Reply #8 on: October 26, 2005, 03:49:34 PM »
Kerry,

Don't worry...

I can teach you more than you think....in other disciplines..

I'm not programmer specialist, I Have lurn programming by my self...same as English.
so that why this website exist,  for sharing information for ALL level users isn't it ?

Also....that why some specialist like you are in....to help other.

If you are talking about my SDUCT software....
I have created this software for my personal user first...
But I've received lot of demand for this simple software...
And lot of modifications demand
to perform this utility for client specifications.

So that why I have decided to sell the program.
Time is missing here and lot of work to do.
I work over 70hour per week...

so please give me a break some one !

PS:
Kerry, please take this post like amical post. :police:

__________________

Now for the response...

thanks for the help....


Keep smile...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get layer locked ..
« Reply #9 on: October 26, 2005, 04:16:10 PM »
It is genuinely surprising, bordering on surreal that a person could knock out an application like the sduct prorgam and not know how to do this. That is all. It's not about elitism or anything like that.

However, if comments were interpretted that way, an olive branch --

Code: [Select]
(defun ObjectsLayerIsLocked ( layers object )

    ;;  pass the layers collection to the function
    ;;  why? if you're processing a lot of objects
    ;;  it makes no sense to retrieve the same info
    ;;  repeatedly. Have the caller do it once.
   
    (eq :vlax-true
        (vla-get-lock
            (vla-item
                layers
                (vla-get-layer object)
            )           
        )
    )
)

Test drive --

Code: [Select]
(defun c:Test ( / ename object layers )

    (setq layers
        (vla-get-layers
            (vla-get-activedocument
                (vlax-get-acad-object)
            )
        )
    )
   
    (while (setq ename (car (entsel)))
        (princ
            (strcat
                "object's layer <"               
                (vla-get-layer
                    (setq object
                        (vlax-ename->vla-object ename)
                    )   
                )
                "> is "
                (if (ObjectsLayerIsLocked
                        layers
                        object
                    )
                    "locked."
                    "unlocked."
                )
            )
        )
    )
   
    (princ)
   
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get layer locked ..
« Reply #10 on: October 26, 2005, 04:17:36 PM »
The file ai_utils.lsp in the ACADxxxx\\support folder has this snippet :

Code: [Select]
;;;
;;; Returns T if passed ename is on a locked layer.
;;;
(defun ai_entity_locked (ename message)
  (if (= 4 (logand 4 (cdr (assoc 70
                            (tblsearch "layer" (cdr (assoc 8 (entget ename))))
                          ))))
    (progn
      (if (= 1 message)
        (princ "\n1 object on a locked layer. ")
      )
      T
    )
    nil
  )
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to get layer locked ..
« Reply #11 on: October 26, 2005, 04:37:43 PM »
LE..

I don't have a bad attitude... :?
i'm Happy to see and lurn more each day..!!  :angel:

The last post I have put ...is only for info..
If you take personal.....i'm sorry.
but I accept all comments...bad or good.
this help me to growing up.

it's only not easy for me to explain my problem some time. :|

but this comment...

Quote
It scares me a little that someone who produces commercial software asks a question like this.

Is not a bad comment....!?  not for me..
but for users and client who see the post...and the occasion gives to doubt my competences.
that exactly my opposite mind.

am I right ?
__________________

For the DXF code..


MP...

I have tried this...

(seq a (entget (car (entsel))))

(setq b (cdr (assoc 70 a)))

But the result is NIL. :|
(I'm not very famillar with DXF group code.)



Keep smile...

LE

  • Guest
Re: How to get layer locked ..
« Reply #12 on: October 26, 2005, 04:47:21 PM »
OK... no more comments on that...

Look into KB, last post.... notice the "tblsearch".... with the "entsel", you need to extract the DFX value of 8 = layer and compare it with the layer table data.

HTH

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to get layer locked ..
« Reply #13 on: October 26, 2005, 05:00:08 PM »
Your right LE..

Kerry have a good solution..

thank you very much guys..

I really appreciate your help. :roll:
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to get layer locked ..
« Reply #14 on: October 26, 2005, 06:22:43 PM »
in the same way....

is this correct to getting the printable value..? :?

(cdr (assoc 290 (tblsearch "layer" (cdr (assoc 8 (entget ename))))))

??
Keep smile...