The Hamma Posted October 28, 2022 Share Posted October 28, 2022 (edited) Trying to filp the source polyline in an extrude but my scipt does not work. Any ideas! def FlipIt(h): if vs.GetTypeN(h) == 21: if vs.Random() >= .5: vs.SetSelect(h) vs.FlipVer() # doesn't flip the poly, but if I replace this command with vs.HDuplicate(h) it will duplicate it def ResetIt(h): vs.ResetObject(h) vs.ForEachObjectInLayer(FlipIt,2,2,0) vs.ForEachObjectInLayer(ResetIt,2,0,0) Edited October 28, 2022 by The Hamma Quote Link to comment
michaelk Posted October 28, 2022 Share Posted October 28, 2022 I think FlipVer only works on selected objects. Have you tried vs.Mirror(h, dup, p1, p2): return HANDLE Quote Link to comment
The Hamma Posted October 29, 2022 Author Share Posted October 29, 2022 Tried this but no luck def FlipIt(h): if vs.GetTypeN(h) == 21: if vs.Random() >= .5: vs.Mirror(h,True, (0,0), (5,0)) def ResetIt(h): vs.ResetObject(h) vs.ForEachObjectInLayer(FlipIt,2,2,0) vs.ForEachObjectInLayer(ResetIt,2,0,0) Quote Link to comment
Pat Stanford Posted October 29, 2022 Share Posted October 29, 2022 Sorry, I am too lazy to try and convert to Python tonight. But it appears to be a redraw/refresh issue with the extrude. Take a look at the extrude in the attached file. See that the polygon profile matches with the extrude. Run the script. Check the profile of the extrude. Note that the profile has been flipped. Exit the extrude and watch the extrude flip and move to the flipped location. All the redraw, reset, move(0,0) garbage at the bottom are my attempts to force a redraw/refresh of the extrude. All failing. If you can find the proper incantation to force the redraw of the extrude you should have what you need. I am out of ideas. Good Luck. Flip Extrude Profile.vwx Quote Link to comment
The Hamma Posted October 29, 2022 Author Share Posted October 29, 2022 (edited) Thanks, I just came to same conculsion after I got this script to work minus the refreshing issue. def FlipIt(h): h1= vs.FIn3D(h) if vs.GetTypeN(h1)==24: h2 =vs.FIn3D(h1) if vs.GetTypeN(h2) == 21: if vs.Random() >= .5: vs.Mirror(h2,False, (0,0), (5,0)) vs.ResetObject(h1) vs.ResetObject(h) vs.ForEachObjectInLayer(FlipIt,2,2,0) Edited October 29, 2022 by The Hamma Quote Link to comment
Pat Stanford Posted October 29, 2022 Share Posted October 29, 2022 ResetObject says that it is supposed to work on Extrudes. Worth a bug report. 1 Quote Link to comment
MullinRJ Posted October 30, 2022 Share Posted October 30, 2022 Hello David, Okay, this works, but it is like throwing a hand grenade over the wall. Using Pat's script as a starting point I tried the not so obvious as it's something that's worked for me in the past. CUT & PASTE. Since you're working in 3D, I assume the final stacking order is not critical. The result in the script below will end up on the top of the stack. If it is critical, you can save the extrude's original position using NextObj() or PrevObj(), and use hMoveBackward() on your flipped extrude to reposition it to its original neighbors. More lines of code, but doable. After you get your script running, you should still file a bug. PROCEDURE Test; VAR H1,H2 :Handle; P1,P2 :Point; BEGIN P1.x := 1; P1.y := 0; P2.x := 2; P2.y := 0; H1 := FinGroup( FSActLayer ); { the Poly profile } H2 := Mirror( H1, False, P1, P2 ); DoMenuTextByName( 'Cut', 0 ); DoMenuTextByName( 'Paste In Place', 0 ); H2 := LActLayer; { for future reference } SysBeep; { make noise when done } END; Run(Test); HTH, Raymond Quote Link to comment
MullinRJ Posted October 30, 2022 Share Posted October 30, 2022 David (@The Hamma), I was not able to get your script to work, and even tried it on a lone extrude without the first "vs.FIn3D()" and the "if vs.Random()" lines. If it's working for you then ignore the following. Cut & Paste works on the entire selection and probably won't work the way you've structured your script. By making some assumptions, I was able to get this version to work, but it assumes you are only working on one group at a time. A selection of multiple groups will get merged into one (not ideal). Again, if you got your script to work, please ignore the following. def FlipIt(h): if vs.GetTypeN(h) == 24: h2 = vs.FIn3D(h) if vs.GetTypeN(h2) == 5: if vs.Random() > 0.5: vs.Mirror(h2, False, (0,0), (5,0)) vs.Ungroup() vs.ForEachObjectInLayer(FlipIt, 2, 2, 0) vs.DoMenuTextByName('Cut', 0) vs.DoMenuTextByName('Paste In Place', 0) vs.Group() vs.SysBeep() Raymond 1 Quote Link to comment
The Hamma Posted November 3, 2022 Author Share Posted November 3, 2022 Funny thing is both scripts work if the interal shape is a polyline but it does not work if it is a Polygon. See attached file. Flip Extrude Profile.vwx Quote Link to comment
michaelk Posted November 4, 2022 Share Posted November 4, 2022 Also doesn't work on rectangles or circles. Curious. Quote Link to comment
michaelk Posted November 4, 2022 Share Posted November 4, 2022 This is interesting. The points defining the reflection are relative. If you rotate the extrude and run the script it flips left and right. It remembers the location where the polygon was originally drawn and the reflection line is always relative to that no matter where you drag the extrude. Everybody probably already knew that 🙂 If you edit the extrude that contains a polygon, circle, rectangle and run the script while in the edit mode…. it works. Edit: In the edit mode the vector script works. The python script doesn't. If you run the vector script on an extrude that "doesn't work" then edit, the polygon, circle, rectangle etc will appear in a flipped position. And after a successful reflection the selection is wrong. 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.