Jump to content
Developer Wiki and Function Reference Links ×

Script to go direct to the Edit Symbol Mode from the drawing (Via the Resource Manager ...)


Recommended Posts

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

Link to comment

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 🙂 

Link to comment

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);

 

  • Like 3
Link to comment
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

Link to comment
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...:

 

1723460325_Screenshot2023-03-28at20_39_42.thumb.png.f8befad1012cc5b0b60b11473c481232.png

 

 🤪  🤪  🤪  🤪  🤪  🤪 

 

(unfortunately editing the symbol options here has no effect on the symbol definition so all in all not a very useful discovery 🙂)

 

 

Link to comment
  • 1 month later...

  

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.

Link to comment

@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.

  • Like 2
Link to comment
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.

  • Like 1
Link to comment

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

Link to comment

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.

Link to comment

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.  🙂

 

  • Like 1
Link to comment

@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

Link to comment

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

  • Like 1
Link to comment

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. 

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...