James Russell Posted August 2, 2011 Share Posted August 2, 2011 Hey all, Working on a little automator at the moment. I have a group containing various arc and lines and then in the middle of it a circle, lines and text all within a symbol. What I want to do is copy the group around to a few places and rotate it. After rotating the full group I want all the symbols contained within to remain at a rotation of 0?. I thought I'd use this opportunity to make/try a script, and I have this thus far: {-----------------------------} Procedure Loop; Procedure RotTest(h : HANDLE); VAR rot :real; BEGIN rot:= GetSymRot(h); If GetSymName(h)='Symbol-1' Then BEGIN SetRot3D(h,0,0,0,0,0,0); ResetObject(h); sysbeep; End; END; BEGIN ForEachObjectInLayer(RotTest,0,1,1); END; RUN (Loop); {----------------------} But it doesn't work. Can someone read over and let me know if I'm on the right track? Any help appreciated. Cheers, J Ps. Sysbeeps are cool okay. Quote Link to comment
MullinRJ Posted August 2, 2011 Share Posted August 2, 2011 James, Change: ???Procedure RotTest(h : HANDLE); To: ???Function RotTest(h : HANDLE) :Boolean; All of the ForEachObj... VS calls take a FUNCTION as the callback "procedure" except ForEachObject(), which takes a PROCEDURE as the callback "procedure". If you want to terminate the loop early, then the callback "function" needs to return a TRUE value. By default, it will return a value of FALSE, even if it's not explicitly stated, and continue to the end. As to whether your callback will do what you want, I don't know. Raymond Quote Link to comment
Miguel Barrera Posted August 2, 2011 Share Posted August 2, 2011 You should also filter only symbols before the call to GetSymRot. The compiler usually gives an error if the object handle is not appropriate for the function. IF GetType(h) = 15 THEN BEGIN rot:= GetSymRot(h); ... ... END; For most 3D objects, you should use Set3DRot instead which accepts symbols. SetRot3D only works for extrudes and sweeps. And even if the function was the right one, the object would not rotate because the angles are all zeros. It should be something like: Set3DRot(h,0,0,-rot,symX,symY,symZ); Furthermore, if the symbol has only a 2D component always use HRotate such as: GetSymLoc(h,symX,symY); rot:= GetSymRot(h); HRotate(h,symX,symY,-rot); Quote Link to comment
Pat Stanford Posted August 2, 2011 Share Posted August 2, 2011 The following seems to do what you want: Procedure Test; Var H1, H2 :Handle; Rot :Real; X1,Y1,Z1 :Real; Function DoIt(H3:Handle):Boolean; Begin If GetType(H3)=11 then Begin H1:=FInGroup(H3); While H1 <> Nil do Begin if GetType(H1)=15 then Begin Get3DCntr(H1,X1,Y1,Z1); Rot:=GetSymRot(H1); HRotate(H1,X1,Y1,-Rot); end; H1:=NextObj(H1); end; end; End; Begin ForEachObjectinLayer(DoIt,0,0,0); End; Run(Test); Quote Link to comment
James Russell Posted August 3, 2011 Author Share Posted August 3, 2011 Hey all, Thanks for great responses here. I've had a read through all and have just tested your script Pat. It's all good in terms of rotating the symbol within the group and I'm pretty sure I can play with the IF constraints to isolate it to a symbol as required the only issue it that the rotation seems to be around the group centre not symbol centre. See the attached file for results and a little more insight. Thankyou for the responses Raymond and Miguel, it's little snippets like this that'll get me over the line at some stage Cheers, J 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.