MTRobin Posted February 22, 2021 Share Posted February 22, 2021 (edited) Hi Everyone, This script keeps crashing Vectorworks when I execute it. I have it as a custom plugin, assigned to a menu drop down, and typically recall it through a hotkey. I tried isolating the line that is giving me issues by commenting out all the others and it looks like the "Create Viewport" command is the culprit. I also tried adding wait commands at different sections of the script and that didn't help either. I was hoping someone could help diagnose what I am doing wrong. The script is designed to turn off dark background, turn off layer colors, change the layer options, set the render mode to wireframe, and then create a viewport and open the viewport dialogue window. SetPref(16, FALSE); SetPref(11, FALSE); SetPrefint(506, 3); DoMenuTextByName('Wireframe Render Chunk', 1); DoMenuTextByName('Create Viewport',0); Thank you, Maxwell Edited February 22, 2021 by MTRobin Quote Link to comment
JBenghiat Posted February 23, 2021 Share Posted February 23, 2021 Try to use direct API calls instead of DoMenu calls. Look at https://developer.vectorworks.net/index.php/VS:SetLayerRenderMode and https://developer.vectorworks.net/index.php/VS:CreateVP Quote Link to comment
michaelk Posted February 23, 2021 Share Posted February 23, 2021 @MTRobin Just tried your script in 2021. Works! Quote Link to comment
MTRobin Posted February 25, 2021 Author Share Posted February 25, 2021 (edited) On 2/22/2021 at 6:05 PM, JBenghiat said: Try to use direct API calls instead of DoMenu calls. Look at https://developer.vectorworks.net/index.php/VS:SetLayerRenderMode and https://developer.vectorworks.net/index.php/VS:CreateVP Could you please help me set these up? I don't have much experience with handles. I want to use the handle of the currently selected layer. Pretty much just recreate the DoMenuTextByName commands. Thank you, Maxwell Edited February 25, 2021 by MTRobin Quote Link to comment
Jesse Cogswell Posted February 25, 2021 Share Posted February 25, 2021 To create a viewport on the current layer, the script is as easy as: viewHand:=CreateVP(ActLayer); The viewHand variable (or whatever you want to call it) is a handle to the viewport so that you can set crop and visibilities using SetVPCropObject, SetVPClassVisibility and SetVPLayerVisibility. The ActLayer command will return the handle to the currently active layer. Quote Link to comment
MTRobin Posted February 25, 2021 Author Share Posted February 25, 2021 17 minutes ago, Jesse Cogswell said: To create a viewport on the current layer, the script is as easy as: viewHand:=CreateVP(ActLayer); The viewHand variable (or whatever you want to call it) is a handle to the viewport so that you can set crop and visibilities using SetVPCropObject, SetVPClassVisibility and SetVPLayerVisibility. The ActLayer command will return the handle to the currently active layer. Thank you. I got this to work, but it's not quite what I'm looking for. This creates a Viewport on the current layer, but what I am trying to achieve is to open the "Create Viewport" dialogue to place a viewport on a sheet layer. Thank you, Maxwell Quote Link to comment
Jesse Cogswell Posted February 25, 2021 Share Posted February 25, 2021 Ah, I see. That is much trickier, as you would basically have to recreate the dialog window in order to use the direct API calls. In this case, the DoMenuTextByName is probably the way to go. I tested this quickly in VW2019 and didn't have any troubles crashing. What version are you using? Quote Link to comment
MTRobin Posted February 25, 2021 Author Share Posted February 25, 2021 I am in VWX 2021 SP 2.1. Quote Link to comment
Jesse Cogswell Posted February 26, 2021 Share Posted February 26, 2021 Hmm. I just tested the script you posted above in VW2021 SP 2.1 and it worked like a charm without crashing VW. Quote Link to comment
MTRobin Posted February 26, 2021 Author Share Posted February 26, 2021 Does Vectorworks have a log that I can check to see what is going on in the background when I run a script? Quote Link to comment
Jesse Cogswell Posted February 26, 2021 Share Posted February 26, 2021 Vectorworks does create a .dmp file when it crashes as well as a log file (my current log file for VW2019 that I use every day is currently 56,000 lines long, but is timestamped per line, so if you know when you crashed, you should be able to find some information). On Windows, it is stored in your User Folder. So if you go to Tools - Options - Vectorworks Preferences and go to the User Folders tab and click "Explore" (or "Open in Finder" on Mac), it should open up the location of the logs. You will probably have to send the .dmp files to VW to get answers unless you have a debugging program that can open them and are comfortable with navigating them. 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.