A way to Lock an Entitiy

A way to Lock an Entitiy

kpennell
Collaborator Collaborator
3,398 Views
25 Replies
Message 1 of 26

A way to Lock an Entitiy

kpennell
Collaborator
Collaborator

Can anyone think of a way to lock an entity, that does not involve putting the entity on a locked layer? I'm wondering what people will come up with.

 

I think it would be a great feature request for Autodesk.

0 Likes
Accepted solutions (1)
3,399 Views
25 Replies
Replies (25)
Message 2 of 26

Kent1Cooper
Consultant
Consultant

Define it into a Block, and put the Block on a locked Layer?  You can lock multiple entities collectively that way if you want.  The entities will retain the characteristics of their native Layers, not of the locked Layer that the Block is on.

Kent Cooper, AIA
0 Likes
Message 3 of 26

john.uhden
Mentor
Mentor

Check out cadlock.com

It is run by gurus emeriti from earlier times around here.

John F. Uhden

0 Likes
Message 4 of 26

dbroad
Mentor
Mentor

Cadlock closed in 2015.  I don't see any benefit to entity locking BTW.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 5 of 26

kpennell
Collaborator
Collaborator

I have some code that 'looks' for things.  And when those 'things' are not in the drawing, or changed location, deleted, exploded, it ends up being a longer winded way to complete the drawing.

 

If I had a magical piece of code, to unlock the entity, make my change and then lock it again, I could avoid such headaches.

 

We have a culture to try to teach the right and wrongs, but someone will always try to get to the finish line their way, which screws it up for the next guy.

 

I did notice the Vault is no longer.  But I play with it, and not quite what I was looking for.  My guts tells me KC's suggestion to be better, but I haven't tested it out yet from a code perspective.

0 Likes
Message 6 of 26

john.uhden
Mentor
Mentor

Isn't Owen still running Manusoft?

John F. Uhden

0 Likes
Message 7 of 26

dbroad
Mentor
Mentor

 "I have some code that 'looks' for things.  And when those 'things' are not in the drawing, or changed location, deleted, exploded, it ends up being a longer winded way to complete the drawing."

 

Sorry Kenny.  I can't really offer a helpful reply to such a vague description of "things".

 

@john.uhden  I have no idea and don't want to speculate.  If you search for Cadlock, the message is clear though.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 8 of 26

Ranjit_Singh
Advisor
Advisor

I would recommend 'looking' for entities using entity handles (not based on their xyz location). That way even if they move it makes no difference to your searching function. Also, if you want to lock them, locked layer is the most simplest and easiest option. You can make a block as recommended. Or get even fancier and attach reactors to your entities so they can't, be moved , edited, deleted etc.

Message 9 of 26

kpennell
Collaborator
Collaborator

I would love to get into reactors.  But I have no code to reference.

 

Yes, and I do look for entities not just based on x,y, and z coordinates.  The common one for me are attributes.  People explode them and therefore creating havoc.

 

Thanks all

0 Likes
Message 10 of 26

pareson
Enthusiast
Enthusiast
Accepted solution

look here, maybe this will answer your question.

 

https://forums.autodesk.com/t5/autocad-forum/locking-objects/td-p/5917625. 

 

i'd tried this sometime ago and it works.

0 Likes
Message 11 of 26

dbroad
Mentor
Mentor

The first step to protect blocks is to make them unexplodeable.  

The second step is to pass out pick slips to the idiots who are still exploding them.  

After that, I would consider fancier options.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 12 of 26

dgorsman
Consultant
Consultant

@kpennell wrote:

Can anyone think of a way to lock an entity, that does not involve putting the entity on a locked layer? I'm wondering what people will come up with.

 

I think it would be a great feature request for Autodesk.


Define "lock an entity", and what purpose it would serve?

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 13 of 26

ActivistInvestor
Mentor
Mentor

If by "lock", you mean to make an entity completely 'read-only' where it can't be modified using any means, there is a way to do that with ObjectARX (native or managed), but unfortunately not with LISP.

0 Likes
Message 14 of 26

john.uhden
Mentor
Mentor

Are we inviting Tony T. into this fray?  (arx)

John F. Uhden

0 Likes
Message 15 of 26

kpennell
Collaborator
Collaborator

Sorry, but got an 'invalid parameters' message from the link. But it's got me curious though.

0 Likes
Message 16 of 26

SeeMSixty7
Advisor
Advisor

Just remove the period off the end of the link.

0 Likes
Message 17 of 26

kpennell
Collaborator
Collaborator

This is the most in-line with what I'm going for. I know I can work with this. I just tested, including the 'Loading', 'ObjectLockCallBack' and the 'ObjectLockGetItem' silently, will keep the entity locked by anyone who opens the file.

 

Thanks so much for this.  I'm digging into the code the afternoon to figure out how this actually works.

0 Likes
Message 18 of 26

ActivistInvestor
Mentor
Mentor

@kpennell wrote:

This is the most in-line with what I'm going for. I know I can work with this. I just tested, including the 'Loading', 'ObjectLockCallBack' and the 'ObjectLockGetItem' silently, will keep the entity locked by anyone who opens the file.

 

Thanks so much for this.  I'm digging into the code the afternoon to figure out how this actually works.


Well, It actually doesn't work.

 

There's no commands started/ended when you edit objects using the Properties Palette, most controls on the Ribbon, and various controls on toolbars. Try editing a 'locked' object using one of those means. It doesn't work, because the whole thing is dependent on objects only being modified within commands. 

 

Try using the BREAK or TRIM commands to break or trim a circle that's 'locked' (producing an arc).

 

Try using the TRIM command on a polyline, trimming it in multiple places. The code will undelete the original polyline, but it also leaves all of the new fragments created by TRIM intact.

 

 

 

 

0 Likes
Message 19 of 26

kpennell
Collaborator
Collaborator

I just noticed though, that this won't 'lock' attributes.

0 Likes
Message 20 of 26

ActivistInvestor
Mentor
Mentor

@kpennell wrote:

I just noticed though, that this won't 'lock' attributes.


Something else you may not have noticed, which I would call a deal-breaker:

 

Load that code and lock one or more objects (one will do).

 

Next, draw a circle (or anything at all).

 

Next, issue the U command to undo the creation of the circle.

 

Then, issue the REDO command to redo the undo.

 

What do you see on the command line?

 

 

0 Likes