Jump to content
Sign in to follow this  
Pat Stanford

Unlock All Objects

Recommended Posts

This script will recursively unlock all objects placed in a drawing. It does not change objects in symbol definitions.

Use at your own risk. Make a backup first. Use protection.

Procedure UnlockAll;

{A script to recursively unlock all objects in a file}
{Enters and unlocks objects in Groups}
{Unlocks placed Symbol Instances. Does not Changed objects in Symbol Definitions}

{Provided with no warranty. Use at your own risk.}
{Side effects may include loss of sense of smell and hysterical laughter}

{August 30, 2010}
{? 2011, Coviana, Inc - Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

Var	ObjectHandle	:Handle;


Procedure Unlock(UnlockHandle: Handle);

Begin
While UnlockHandle <> Nil do
	Begin
		If GetType(UnlockHandle)=11 then 
			Begin
				SetObjectVariableBoolean(UnlockHandle,700,False);
				Unlock(FinGroup(UnlockHandle));
				UnlockHandle:=NextObj(UnlockHandle);
			End
		Else
			Begin
				SetObjectVariableBoolean(UnlockHandle,700,False);
				UnlockHandle:=NextObj(UnlockHandle);

			End;
	End;
End;

Begin
ObjectHandle:=FObject;
While ObjectHandle<>Nil do
	Begin
		Unlock(ObjectHandle);
		ObjectHandle:=NextObj(ObjectHandle);
	End;
End;

Run(UnlockAll);

Share this post


Link to post

Hi Pat,

???Your script will only work on the first layer. NextObj() will return NIL at the end of the first layer and will not return a handle to the first object on the second layer. Of course, if your file only HAS one layer, it works perfectly.

???You could encase your loop inside a loop that steps through the layers and use FActLayer instead of FObject (been there, done that), but I'd suggest using ForEachObject() or ForEachObjectInLayer() which will step through every object in the drawing. Using the GROUP or DEEP options in the latter call will remove the need for recursion.

???This example is definitely not as sexy as your example, but it's fast and thorough; and like your example, it's untested, so caveat emptor and always wear your galoshes when it's raining.

Procedure UnlockAll;

function Unlock(ObjHandle: Handle) :Boolean;
Begin
	SetObjectVariableBoolean(ObjHandle, 700, False);
End;		{ Unlock }

BEGIN
ForEachObjectInLayer(Unlock, 0, 1, 1);	{ All Objects, All Layers, Enter Groups }
END;
Run(UnlockAll);

Raymond

Share this post


Link to post

Raymond,

Thanks for the update. You are correct.

This kind of blows my concept of how VW is organized. I thought that objects where kept in lists with an object being allowed in multiple lists.

I though there was one list for all objects that you could access with FObject (or LObject). Then there was a subset of that list that was only for the active layer (FActLayer etc.).

Since FObject give you access to a list of objects that happen to be on the same layer as the first object it seems kind of pointless.

Does anyone else see this as a bug? Does anyone actually use the features of FObject only working on one layer who would be upset if the functionality changed?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×