James Russell Posted November 25, 2010 Share Posted November 25, 2010 Attempting a script that searches my lighting devices and finds the ones rotated less than 180 degrees and applies my second label legend. This is what I have thus far: Procedure Loop; Procedure RotTest; VAR h :handle; rot :integer; BEGIN SetSelect(h); rot:= GetSymRot(h); If rot<180 THEN BEGIN SetRField(h,'Lighting Device','Use Legend','Legend Rotated'); End; END; BEGIN ForEachObjectInLayer(RotTest, 2, 0, 4); END; RUN (Loop); I get a Boolean error and I am unsure why. Any advice/better solutions? Much appreciated, J Quote Link to comment
maarten. Posted November 25, 2010 Share Posted November 25, 2010 The problem is that ForEachObjectInLayer needs a Function in stead of a Procedure. You also forget the Handle. So Procedure RotTest; should be Function RotTest(h : HANDLE) : BOOLEAN; SetSelect(h); This isn't necessary. Most of the time, you don't need to select your objects to adjust them in VS rot :integer; Better would be to make it a Real in stead of an Integer. Otherwise your value will get rounded. So 179,8 will become 180 and i don't think that is what you want (could be wrong of course). ForEachObjectInLayer(RotTest, 2, 0, 4); Here you're passing almost every object on the active layers to the Procedure RotTest. That way you'll also try to adjust that record field even if the object doesn't have that record attached. Better would be: ForEachObject(RotTest,(R IN ['Lighting Device'])); Now you'll only pass that objects that have that record attached. But be aware, this will pass objects on all layers while ForEachObjectInLayer only passed objects on the layers you choosed. Also, this procedure doen't need a Function to call, but a Procedure. Quote Link to comment
James Russell Posted November 26, 2010 Author Share Posted November 26, 2010 (edited) Maarten, Your help has led to something so so helpful to me thankyou. For those of you who are interested in a finished product or for me reading this later when I can't remember what I did: Procedure Loop; Procedure RotTest(h : HANDLE); VAR rot :real; BEGIN rot:= GetSymRot(h); If GetRField(h,'Lighting Device','Device Type')='Light' THEN BEGIN If rot<=0 THEN BEGIN SetRField(h,'Lighting Device','Use Legend','Legend Rotated'); ResetObject(h); sysbeep; End ELSE BEGIN SetRField(h,'Lighting Device','Use Legend','Regular'); ResetObject(h); sysbeep; End; End; END; BEGIN ForEachObject(RotTest,(R IN ['Lighting Device'])); END; RUN (Loop); Mission success! Thanks all! J Ps. sysbeeps are just for fun! Edited November 26, 2010 by James Russell Quote Link to comment
Miguel Barrera Posted November 27, 2010 Share Posted November 27, 2010 From your code which uses ResetObject, it seems that the lighting device is a PIO. So assuming this is true, did you know that with an event enabled PIO and with reset on rotation checked, the legend can be updated automatically when the PIO is rotated? Quote Link to comment
JBenghiat Posted November 28, 2010 Share Posted November 28, 2010 Actually, in this case the Lighting Device PIO is part of Spotlight, so the code has to be in an external script. -Josh 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.