tbexon Posted January 25 Share Posted January 25 HI All I'm sure I'm missing something obvious, but I've been searching through the Function reference aswell as preference selectors, and I'm struggling to find what I'm looking for. Basically within a PIO I need to set the view to a specific view, then for a better User Experience I want to return the user to their previous view (Code Below). This works fine if the user is in a 3d view, however if they are in Top/Plan it will always swap to 3d, which whilst not a massive disaster also isn't ideal. What i'm looking for is some kind of command where I can check whether the user is in a 3d view or 2d, and then, if in 2D, set the view BACK to 2d once the operation has been completed. xAngleR, yAngelR, zAngleR, offset = vs.GetView() # Saves current view for Later vs.SetView("0d", "0d", "0d", "0", "0", "0") # Sets view to top down vs.SetView(xAngleR, yAngelR, zAngleR,offset[0], offset[1],offset[2]) # Resets View back to previous user view Thanks in Advance! Quote Link to comment
Jayme McColgan Posted January 25 Share Posted January 25 here's what I use to find out if I'm in top plan. topplan = vs.GetProjection(vs.ActLayer()) if topplan != 6: vs.SetView(xAngleR, yAngleR, zAngleR, offsetPt[0], offsetPt[1], offsetPt[2]) #0 = Orthogonal #1 = Perspective #2 = Cavalier Oblique 45 #3 = Cavalier Oblique 30 #4 = Cabinet Oblique 45 #5 = Cabinet Oblique 30 #6 = Plan #7 = Section #8 = Section Plus 1 Quote Link to comment
JBenghiat Posted January 25 Share Posted January 25 And if you need to return from a 3D view to top/plan, you can also set the projection: https://developer.vectorworks.net/index.php?title=VS:Projection Alternatively, you can use vs.VSave/VRestore/VDelete() to save the current view and restore it at the end of the script. You can also use SetPref(9873,TRUE) to prevent a screen redraw when the view is changed but then you MUST call SetPref(9873,FALSE) after you set the view back. You will see the largest speed increase in a 3D view from this. You may also be able to avoid changing the view by setting the planar ref ID to a plan in the orientation you want. (Assuming you're changing the view to perform an extrude) 1 Quote Link to comment
tbexon Posted January 29 Author Share Posted January 29 Amazing thanks! Working code if it's of help for anyone: projectionMode = vs.GetProjection(vs.ActLayer()) if projectionMode != 6: # If the user is NOT in 2D Top/Plan View xAngleR, yAngelR, zAngleR, offset = vs.GetView() # Saves current view for Later vs.SetView("0d", "0d", "0d", "0", "0", "0") # Sets view to top down vs.SetPref(tb.PreferenceSelectors.DisableScreenRedraw, True) # Disables screen redraws temporarily # ------------- Other Code here ----------------------# if projectionMode != 6: # If user is NOT in Top/Plan, then reset 3d view vs.SetView(xAngleR, yAngelR, zAngleR,offset[0], offset[1],offset[2]) vs.SetPref(tb.PreferenceSelectors.DisableScreenRedraw, False) # Enables screen redraws 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.