Andreas Posted October 18, 2023 Share Posted October 18, 2023 Dear VectorWorks forum: I need to write a script in order to change the rotation angle of some object with a specified parameter. But I have an issue using this python function: - vs.SetAngle(h, value) - cause nothing change after the script run. vs.HAngle(h) works perfectly, I can get the rotation parameter. I think I'm writing something wrong in the parameters method. Here the script: def SetRot(h): rotValue = vs.HAngle(h) vs.AlrtDialog(rotValue) vs.SetAngle(h, 75.0 ) vs.SetDSelect(h) vs.SelectObj("INSYMBOL & INVIEWPORT & ((PON='Data Tag') & (PST=''))") vs.ForEachObjectInLayer(SetRot, 2, 0, 2) Thanks Quote Link to comment
Andreas Posted October 18, 2023 Author Share Posted October 18, 2023 Also with a marionette script doesn't work.. Here attached fileVS-SetAngle issue.vwx Quote Link to comment
MullinRJ Posted October 18, 2023 Share Posted October 18, 2023 Hello @Andreas, I tried to use vs.SetAngle() on Lines, Arcs, and Rects to no avail. I tried in VW 2024 and VW 2015 with the same result. I also tried in Python and Pascal, still nothing. It appears the command is not functioning as advertised. There are other ways to set the angle of objects. Here's a short Pascal script that shows the current angle of a Symbol or PIO (which includes the Data Tag), and changes it to the user's value. Here's a short script to show how to set an angle without using vs.SetAngle() import vs # Example script to change the angle of a Symbol or PIO. Ang0 = vs.GetSymRot(vs.FSActLayer()) Ang = vs.RealDialog("Angle: ", vs.Concat(Ang0)) InsPt = vs.GetSymLoc(vs.FSActLayer()) vs.HRotate(vs.FSActLayer(), InsPt, Ang-Ang0) vs.SysBeep() Raymond Quote Link to comment
Marionette Maven Marissa Farrell Posted October 18, 2023 Marionette Maven Share Posted October 18, 2023 Hi all - without Vectorworks in front of me, I think SetAngle may be looking for a vector and not a degree value. The dev wiki implies that to me, but again, I haven't been able to check. Quote Link to comment
MullinRJ Posted October 18, 2023 Share Posted October 18, 2023 Hi @Marissa Farrell, The Function Reference, HTML and online versions, call for a REAL number input. I haven't tried a VW version earlier than 2015 yet to see if it ever worked, but I'm about to fire up an old computer in a minute to see. More soon. Regardless if it ever worked, it doesn't seem to work now. All the best, Raymond Quote Link to comment
Marionette Maven Marissa Farrell Posted October 18, 2023 Marionette Maven Share Posted October 18, 2023 I've asked a colleague to look into this and I'll report back once I know more 🙂 I'm out of office for a while, so unable to really check for myself at this time. Quote Link to comment
MullinRJ Posted October 18, 2023 Share Posted October 18, 2023 I launched VW 2009 on an older Mac and confirmed SetAngle() does work, but only on Rectangles and Ovals as far as I could discern. It does not work on Arcs, Lines, Images, Symbols, or PIOs. I then restarted VW 2024, and got the same results. Conclusion: The function SetAngle() is not broken, it is just severely limited in what it will operate upon. For most needs, use HAngle() instead. Raymond Quote Link to comment
Marionette Maven Marissa Farrell Posted October 18, 2023 Marionette Maven Share Posted October 18, 2023 Thanks! I just had the chance to check this myself and wasn't running into issues, so this helps me to not need to ask for more information 🙂 Quote Link to comment
Andreas Posted October 19, 2023 Author Share Posted October 19, 2023 Thanks for yours replies @MullinRJ and @Marissa Farrell I changed function and using " vs.Set3DRot( handle , angX, angY, angZ, oX, oY, oZ ) " works well for all objects types. 15 hours ago, MullinRJ said: Here's a short Pascal script that shows the current angle of a Symbol or PIO (which includes the Data Tag), and changes it to the user's value Thanks also for this solution, I'll keep " vs.HRotate() " in mind 🙂 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.