Elite Exhibits Posted March 23, 2023 Share Posted March 23, 2023 Script to go direct to the Edit Symbol Mode from the drawing (Via the Resource Manager ...) Is it possible to have a script to go direct to the Edit Symbol Mode from a selected symbol on the drawing (Via the Resource Manager ...) Because of the continuing issues, I have, with editing existing / older / hybrid container objects in VectorWorks, I find myself repeatedly selecting, then right clicking a symbol, in the drawings, and pulling down to the Locate in Resource Manager option at the bottom, then scrolling to actually find the identified Symbol in the Resource Manager , then right clicking this symbol to edit the 3D component, then closing the Resource Manager (on a laptop) so I am able to see the Symbol edit mode... A script to cut to the chase ? I would edit the symbol directly on the drawing as was the case for years, except that is where the problems lie. Advice and answers are always appreciated Peter Quote Link to comment
michaelk Posted March 23, 2023 Share Posted March 23, 2023 If I understand your question correctly, you can do that now. Double click the symbol in the drawing and you will be asked if you want to edit the 2D, 3D, 3D Wall Hole Component, or Wall Closure Component. Or you can right click on the symbol and all those choices are there. I'd like to see Edit Symbol Options … added 🙂 Quote Link to comment
Jesse Cogswell Posted March 24, 2023 Share Posted March 24, 2023 Peter, there is a way to do that through script sort of. You can open up the edit container, but not "in place" where you can see other objects while editing, but based on your prompt, that might be the desired effect since you're opening up the symbol edit through the Resource Manager anyway. As @michaelk stated, double clicking a symbol on a drawing will automatically open the edit container for the symbol after selecting which edit container you want to edit (though you can set one as a default). In any case, the script below will do what you are looking for. It will work on groups or symbols. In the case of symbols, it will open either the 2D component or the 3D component depending on what the current view is when you run the script. I should also note that it only works on objects that are one the active layer. One potentially huge caveat is that it will not launch the standard symbol edit widget, allowing you to switch between the 2D and 3D components without exiting the edit container. The key is SetObjectVariableInt with the selector set to 9743. It's one of those nifty things not covered in the documentation. PROCEDURE OpenEditContainer; {* Opens selected object's edit container based on current view Developed by: Jesse Cogswell Date: 3/23/2023 Revisions: *} CONST kEdit = 9743; kSymbol = 15; kTopPlan = 6; VAR h:HANDLE; symDef:STRING; BEGIN h:=FSActLayer; IF(GetTypeN(h)=kSymbol) THEN BEGIN symDef:=GetSymName(h); IF(GetProjection(ActLayer)=6) THEN SetObjectVariableInt(GetObject(symDef),kEdit,0) ELSE SetObjectVariableInt(GetObject(symDef),kEdit,7); END ELSE SetObjectVariableInt(h,kEdit,7); END; Run(OpenEditContainer); 3 Quote Link to comment
Elite Exhibits Posted March 28, 2023 Author Share Posted March 28, 2023 On 3/23/2023 at 5:45 PM, michaelk said: If I understand your question correctly, you can do that now. Double click the symbol in the drawing and you will be asked if you want to edit the 2D, 3D, 3D Wall Hole Component, or Wall Closure Component. Or you can right click on the symbol and all those choices are there. I'd like to see Edit Symbol Options … added 🙂 michaelk Thank you ... Because I wish to avoid the aggravating issues editing in a container... . I skip the simplicity of double clicking on a copy in the drawing - based on comments by Andy B - I only edit through the Resource Manager, a circuitous route. (Insert ... I work on a laptop here) Peter Quote Link to comment
Tom W. Posted March 28, 2023 Share Posted March 28, 2023 On 3/23/2023 at 9:45 PM, michaelk said: I'd like to see Edit Symbol Options … added 🙂 For some bizarre reason if you flip a symbol then double-click on it...: 🤪 🤪 🤪 🤪 🤪 🤪 (unfortunately editing the symbol options here has no effect on the symbol definition so all in all not a very useful discovery 🙂) Quote Link to comment
Elite Exhibits Posted March 28, 2023 Author Share Posted March 28, 2023 That Said ... I must say to Jesse Cogswell - this script is excellent ! (Its like magic ...) Many Thanks I may never go back to the Double Click option when VW corrects the anomalies... Peter Quote Link to comment
twk Posted May 21, 2023 Share Posted May 21, 2023 On 3/24/2023 at 5:43 PM, Jesse Cogswell said: The key is SetObjectVariableInt with the selector set to 9743. It's one of those nifty things not covered in the documentation. Hey Jesse cool find, two quick questions: 1. How on earth did you find this. I have a run a content search accross the sdk zip file and found nothing regarding the 9743 variable 2. I'm trying to do the reverse of this. If my active view is within a container, in my case the viewport annotation group, I want to exit this container via script. If I use my trick of vs.Layer(<layer i'm wanting to go to>) to set the active layer, my active view remains still in the annotations space. Maybe a bug, but I was wondering whether you knew of any other jedi variables. Cheers. Quote Link to comment
Jesse Cogswell Posted May 22, 2023 Share Posted May 22, 2023 @twk It was knowledge passed down from on high, and by that I mean @JBenghiat told me. I was trying to get to a symbol's edit container using EditObjectSpecial and could not get it to work, so I asked on the forum. I have no idea where he acquired said knowledge. For the reverse, you have to do a DoMenuTextByName( 'Group Navigation Chunk', 2); call. That will dump you back out to where you were before going into the edit container, and totally works to exit a Viewport Annotation container. 2 Quote Link to comment
twk Posted May 22, 2023 Share Posted May 22, 2023 Of course, one of the script-masters, @JBenghiat. I will test the DoMenuTextByName route, will post back findings. Thanks again. Quote Link to comment
JBenghiat Posted May 22, 2023 Share Posted May 22, 2023 14 hours ago, Jesse Cogswell said: @twk It was knowledge passed down from on high, and by that I mean @JBenghiat told me. I was trying to get to a symbol's edit container using EditObjectSpecial and could not get it to work, so I asked on the forum. I have no idea where he acquired said knowledge. A kindly Vectorworks engineer took pity on my coding soul and tossed me that bone. It's one of a handful of tips and tricks I keep in a running list. 1 Quote Link to comment
twk Posted May 23, 2023 Share Posted May 23, 2023 20 hours ago, Jesse Cogswell said: For the reverse, you have to do a DoMenuTextByName( 'Group Navigation Chunk', 2); call. That will dump you back out to where you were before going into the edit container, and totally works to exit a Viewport Annotation container. This works perfectly!, thanks @Jesse Cogswell Quote Link to comment
Elite Exhibits Posted May 23, 2023 Author Share Posted May 23, 2023 Thanks again to @twk & @Jesse Cogswell Almost... a great addition to our workflow - One script from @Jesse Cogswellworks to get to the Symbol Edit The reverse from @twk takes us back to where we were ... to easy One addition would be Decrease zoom by a factor of 2 Unable to find what works with DoMenuTextByName Assume I should find it in https://developer.vectorworks.net/index.php/VS:Function_Reference ¿ or ... It is NOT a menu item ? ********************************************************* PROCEDURE OpenEditContainer; {* Opens selected object's edit container based on current view Developed by: Jesse Cogswell Date: 3/23/2023 Revisions: *} CONST kEdit = 9743; kSymbol = 15; kTopPlan = 6; VAR h:HANDLE; symDef:STRING; BEGIN h:=FSActLayer; IF(GetTypeN(h)=kSymbol) THEN BEGIN symDef:=GetSymName(h); IF(GetProjection(ActLayer)=6) THEN SetObjectVariableInt(GetObject(symDef),kEdit,0) ELSE SetObjectVariableInt(GetObject(symDef),kEdit,7); END ELSE SetObjectVariableInt(h,kEdit,7); DoMenuTextByName('Select All',0); {select all} DoMenuTextByName('Fit To Objects',0); {Zoom - Fit To Objects} DoMenuTextByName('Decrease zoom by a factor of 2',0); {Zoom Out Cmd+2} END; Run(OpenEditContainer); ********************************************************* As always, any applicable advice and answers are aptly appreciated. Peter Quote Link to comment
Jesse Cogswell Posted May 23, 2023 Share Posted May 23, 2023 There isn't a DoMenuTextByName command for decreasing the zoom by a factor of 2. However, you can get the same effect by adding this line to your code: SetZoom(0.5 * GetZoom); 2 Quote Link to comment
Pat Stanford Posted May 23, 2023 Share Posted May 23, 2023 Or. SetZoom(GetZoom/2); (I couldn't resist, since Jesse beat me to the answer while I was testing.) 😉 1 Quote Link to comment
Jesse Cogswell Posted May 23, 2023 Share Posted May 23, 2023 Not sure if it is true or anecdotal, but I remember learning that multiplication is far easier for compilers to do than division, so it's usually preferential to do * 0.5 rather than / 2. But I also suppose that it depends on the compiler/language. And where we are with computing at this point, the speed difference probably doesn't matter in the big scheme of things. Quote Link to comment
Pat Stanford Posted May 23, 2023 Share Posted May 23, 2023 Certainly for a one time operation in a Vectorscript it will not make a measurable difference. If these were Integers or LongInts, then multiply/divide by 2 becomes really easy in that you just shift left or right one bit instead of multiplying or dividing. But since the Zoom is a Real, then that means it is probably running through an IEEE floating point numeric routine to do the math either way. And the ability to read the code is probably more important than the execution time. And to me if you want to zoom out by a factor of 2 it is easier to read at X/2 than X * 0.5. The multiplication takes more of my limited brain power to recognize what it is doing that the division. Just my $0.02. And all in good fun. Do whatever works best for you. 🙂 1 Quote Link to comment
Jesse Cogswell Posted May 23, 2023 Share Posted May 23, 2023 Can Vectorscript do bit shifting? I guess I never tried... Quote Link to comment
Pat Stanford Posted May 23, 2023 Share Posted May 23, 2023 Actually it does not look like VS can do shift. I am pretty sure I did it in Turbo Pascal 35 years ago, so I just kind of assumed it was possible, but I have never needed it. Python certainly can. And C. 🙅♂️ Quote Link to comment
Elite Exhibits Posted May 23, 2023 Author Share Posted May 23, 2023 @Jesse Cogswell DoMenuTextByName('Standard Views',2); {sets view to top} Adding this at the beginning of the Script above, edits a 3D Only Symbol in 3D - if not, then you see nothing, as VW assumes (When the drawing is in Top/Plan ...) that the symbol edit is 2D, or the 2D component of a Hybrid Question: DoMenuTextByName('Standard Views',?); does not appear to have a number that sets the drawing to Top/Plan view first - assume it to be Zero... (See attached) ¿ An alternate to DoMenuTextByName for this is ? Peter Standard Views VectorScript_1.pdf Quote Link to comment
Jesse Cogswell Posted May 23, 2023 Share Posted May 23, 2023 DoMenuTextByName( 'Projection', 1); 1 Quote Link to comment
MullinRJ Posted May 23, 2023 Share Posted May 23, 2023 There is also Projection(6, 0, 10, -2, -2, 2, 2); , if you don't want to use DoMenuTextByName(). The magic number is 6. The second term sets the rendering mode (0=Wireframe), and the last 5 numbers can be ignored as they apply to Perspective Views. Raymond 1 Quote Link to comment
MullinRJ Posted May 23, 2023 Share Posted May 23, 2023 Shifting can be done with integers and longints with "n DIV 2" (right shift) and " n * 2" (left shift). Without some complicated code, you will have trouble with the sign bit. For values that do not encompass the full range of bits, "DIV 2" and "* 2" work quite well. Quote Link to comment
Elite Exhibits Posted February 6 Author Share Posted February 6 @Jesse Cogswell @twk Looking to Modify the above script so that ... In place of the Direct to Edit Mode One is able to Select a Symbol on the Drawing and go direct to the rename dialog ? ...without the usual multi steps in between & without opening the Resource Manager Peter Quote Link to comment
JBenghiat Posted February 6 Share Posted February 6 Not via DoMenuText commands, but once you have the handle of the symbol definition, you can use GetName(), StrDialog(), and SetName(). The caveat is that you don't have any error checking to see if the name is valid. You would need to do something like test for Name2Index() = 0, and add an incrementing suffix until it's true. 1 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.