Pat Stanford Posted August 30, 2011 Share Posted August 30, 2011 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); Quote Link to comment
MullinRJ Posted September 1, 2011 Share Posted September 1, 2011 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 Quote Link to comment
Pat Stanford Posted September 1, 2011 Author Share Posted September 1, 2011 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? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.