Author Topic: How to get layer locked ..  (Read 9491 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...

LE

  • Guest
Re: How to get layer locked ..
« Reply #15 on: October 26, 2005, 06:40:30 PM »
in the same way....

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

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

??

Nope....

Use:

(tblobjname "layer" layer_name)


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get layer locked ..
« Reply #16 on: October 26, 2005, 07:01:05 PM »
or you could use ActiveX ..

.. which means you can deal directly with the Object Model.

Try, and study, this ; one line at a time.
Code: [Select]
(setq ename (car (entsel)))




(vlax-dump-object (vlax-ename->vla-object ename) T)




(setq oLayer
       (vla-item
         (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
         (cdr (assoc 8 (entget ename)))
       )
)




(setq plottable (vla-get-plottable oLayer))





(vlax-dump-object oLayer T)
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 #17 on: October 26, 2005, 08:23:24 PM »
LE !!??

tblobjname  !!??

First time I see this function !!?  :?

so I presume this will be the code line ?

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

thank you.
__________

Kerry !?

Your code seem interesting too..
but I have tried to use some VLAX function and i had
bad result...maybe I don't know how really it work..
need to make more tests and try to understand how it work.

In fact I had some PC who won't accept converting VLAX object.
same drawing, same PC configuration... :|  so I was lost..

If you have, or if anyone have any website who can refer me to lurn more about VLAX function
I'll put in my Favorites...
__________


thanks you guys...I do not know really where you are to go to learn all that ....but thanks.
Keep smile...

Dent Cermak

  • Guest
Re: How to get layer locked ..
« Reply #18 on: October 26, 2005, 08:37:59 PM »
Andrea, it's not stupid, just basic.
It scares me a little that someone who produces commercial software asks a question like this.
It shouldn't. Andrea is getting into an area where he hasn't gone before and to deride him is just plain bad manners.You and MP should be ashamed of yourselves. I am proud that you two know it all, but y'all are the exceptions here and not the rule. Many of us don't know diddly squat about programming, but we are trying to learn. When we stumble, implying that it's a sign of ignorance is just not right. Can either of you go on an Italian AUG site and convey your questions in that language? I think not. I admire Andrea for all he has accomplished and you attitude towards his question makes me want to hurl!
Don't look down on someone until you have walked a mile in his shoes or have out done him in equal circumstances. Anything else is dispicable.
This site was established to teach and help in the AutoCad environment. To be helpful and courteous to all comers. For the #2 guy on this site to forget that is truly shameful. Remember what Thumper said his mama taught him to say in the movie "Bambi"? IF YOU CAN'T SAY SOMETHING NICE, DON'T SAY NOTHING AT ALL". Very wise little bunny. Let's learn from him, otay?
And too, remember, it's not WHAT you say, it's HOW you say it. There are several people that have emailed me saying that they are afraid to post questions here because someone may jump on them for asking a stupid question. That needs to stop right now. Engage brain before putting mouth into motion.

<slinks down off of soap box>

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get layer locked ..
« Reply #19 on: October 26, 2005, 09:08:18 PM »
Dent.

I have never treated anyone here with anything but respect. Nor have I ever suggested that someone was stupid, or that their questions were anything other than deserving. If you or anyone else expects me to refrain from making comments that I consider relevant to a thread then that can be easily resolved.

Up untill now I have refrained from making any social or political comment on any of the posts in this thread. Please dont get me started.

Frankly, the last thing I need or deserve is a lesson in manners from a cartoon character.

I got a laugh from your comment that I know it all. I go through the same problems as most others to get my code to do what I want.


Regards
Kerry
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 #20 on: October 26, 2005, 09:24:45 PM »
Dent,

Thanks, I appreciate your support.

Kerry and LE are a good programmers, like many other..
the last comment was forgot. Please let turn the page..
tighten the hand and work together to develop utilities worthy of us.

.  <- Final point  :wink:

__________

Hey you guys..!!
When i have finished with my new program...i'll put for free download on my new website.
I think you will be impressed....( I hope)
 :lmao:
Keep smile...

Dent Cermak

  • Guest
Re: How to get layer locked ..
« Reply #21 on: October 26, 2005, 09:35:18 PM »
True Andrea. Keep the questions coming.
Kerry, as I stated, it's not WHAT you say, but HOW you say it. Contrary to your response, the QUOTED statemnent was insulting.
My Avatar is a cartoon character. I am not. Again another insulting statement. You do need a lesson in manners my man because your statements erase your response.
I don't program. I am from Mississippi. That does not mean that I am a cartoon character. Nor does it mean that my IQ is that of a Lily Pad.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get layer locked ..
« Reply #22 on: October 26, 2005, 09:42:46 PM »
Quote
My Avatar is a cartoon character. I am not. Again another insulting statement

and BAMBI is what. ? or Thumper, whatever character you were using to convey your moral message ?

I think you are protesting a little too loudly.

The quoted statement is not insulting. Nothing you can say will convince me otherwise.

Dent I know you are not a programmer. I checked your posts for code content before I responded.  I wonder what gives you the insight to judge my comments validity in the context it was used.
« Last Edit: October 26, 2005, 09:54:21 PM by Kerry Brown »
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.

Dent Cermak

  • Guest
Re: How to get layer locked ..
« Reply #23 on: October 26, 2005, 10:20:50 PM »
Age, experience and a subtle sense of grace.....all which you lack. :lmao:
I never insulted your intelligence.....as you did mine.....I just pointed out that you were being unnecessarily rude.
The use of Bambi characters was to point out lessons that you should have learned as a child.
I'm sorry, but I have never been able to take people who display a superiority complex through rudeness.
 Perhaps it's part of my Southern upbringing. Down here rudeness is unacceptable. In other parts of the country it is a way of life.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get layer locked ..
« Reply #24 on: October 26, 2005, 10:23:19 PM »
Out of respect for Mark, I will not follow this discussion down the road you are leading it.

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 #25 on: October 26, 2005, 11:43:55 PM »
Quote from: Dent
... and furthermore ...

It's very simple. When one becomes the very public author of commercial software there is an instant assumption of knowledge and expertise. I'm sorry, but that just goes with the territory.

It's analogous to someone setting up shop as a doctor. There are base expectations of ability, experience and fundamental know how because the doctor sign has been put up.

Now if the doctor reveals he doesn't know how to take a pulse you are going to be surprised no matter how much you like the good doctor and wonder how he could have set up shop without that fundamental skill.

More over, there would be a level of concern for those being serviced by said doctor.

Even if the good doctor does a mighty fine job as a speech therapist.

Nothing more, nothing less.

Now you can froth and twist this into something more than this if you wish but it won't change the fundamental facts.

Coda -- Imagine for a moment someone that marketed and sold services as an expert cartographer and then asked the question "what is a prime meridian?"

Please tell me at length how you wouldn't find that incredulous.
« Last Edit: October 27, 2005, 12:02:20 AM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

hudster

  • Gator
  • Posts: 2848
Re: How to get layer locked ..
« Reply #26 on: October 27, 2005, 04:17:42 AM »
This is the first time on this site I have ever seen anyone having a go at another user, and frankly I'm a little saddened by it.
I like this site because it's not pretentious.

As I was told by my father "Manners cost nothing.  If you treat people the way you want to be treated, then you'll get along fine".

So come on guys, don't fight.
Now you two kiss and make up or it's early to bed for both of you.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How to get layer locked ..
« Reply #27 on: October 27, 2005, 06:57:24 AM »
Moved to the correct forum.
TheSwamp.org  (serving the CAD community since 2003)

Dent Cermak

  • Guest
Re: How to get layer locked ..
« Reply #28 on: October 27, 2005, 09:29:39 AM »
Coda -- Imagine for a moment someone that marketed and sold services as an expert cartographer and then asked the question "what is a prime meridian?"

Please tell me at length how you wouldn't find that incredulous.

I hit that everyday. I cannot believe that AutoCad refuses to acknowledge that there is no such thing as MAJOR and Minor contours. I find it bemusing that they do not know what a depression contour is and what to do with it. Intergraph does. But with all of that I have never publicly cast dispersions on their abilities. That's just not right. If you thus doubt the validity of some software, don't buy it. Casting stones in a public forum is a whole nuther matter. It's like walking up to me and saying, "God, you're fat!". The statement is true, but it's not nice to say that.
Now, these are my final words on this issue. I just think we need to treat people with the dignity they deserve and realize that many of us here don't have a clue  when it comes to code. That does not make us bad people. That does not make us ignorant or inferior. We are here to learn. It's hard to learn when the response is "I can't BELIEVE you asked that!"
I have a boss at work that finds it odd that I do not know how to do superelevated curves, or blue top comps. I have to remind him that I am a cartographer,not a civil engineer. Everyone has their area. Some more than others. The idea is to be helpful and treat people as we would like to be treated. If you feel that someone may be- in your opinion- incompetent, then you have the right to feel that way. I just don't think you then have the right to mock them.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get layer locked ..
« Reply #29 on: October 27, 2005, 09:35:40 AM »
I just think we need to treat people with the dignity they deserve.

Agreed. Let's move forward on that note.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10640
Re: How to get layer locked ..
« Reply #30 on: October 27, 2005, 09:46:40 AM »
By appreciation, we make excellence in others our property.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

deegeecees

  • Guest
Re: How to get layer locked ..
« Reply #31 on: October 27, 2005, 11:26:33 AM »
I feel like I just watched an episode of Springer.  :-o :-D

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to get layer locked ..
« Reply #32 on: October 27, 2005, 04:39:24 PM »
Is the SEARCH not working anymore, maybe Mark should fix it. :-o
http://tinyurl.com/b5j2c
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.