Julian Carr Posted May 9, 2018 Share Posted May 9, 2018 Does anyone have a sample script for a VST that uses buttons in the tool bar? Thanks! Quote Link to comment
MullinRJ Posted May 9, 2018 Share Posted May 9, 2018 Julian, If you find one, I'd love one, too. Please share. Years ago, when I first looked for the same, I believe I was told it was only achievable with the SDK. I have several tools I have made that would benefit immensely from Mode Buttons. I hope you find an example. Raymond Quote Link to comment
Hippocode Posted May 10, 2018 Share Posted May 10, 2018 I don't think you can either. In vectorscript tools are generated automatically fitting the plugin type. In the SDK, these are separate and can be customized. Quote Link to comment
JBenghiat Posted May 11, 2018 Share Posted May 11, 2018 It's possible, but not straightforwards. You need to flag the tool as event enabled. AFIK, the only way to do this is with a hex editor. The instructions for this are somewhere — either in the developer wiki, or possibly VectorDepot or such. The mode bar buttons are generally designed to be part of RunTempTool or TrackObject. These are generally best run from a menu or PIO button, though. Tool functionality is primarily why I switched to the SDK. Here's an example. It's an edited version of an actual plug-in, not a sample, so it won't necessarily work as is. PROCEDURE MyScript; CONST kToolXPropSelectionChange = 1; {tool wants selection change events.} kToolXPropUnsupported = 2; {not supported} kToolXPropWantsMoveSelection2D = 3; {tool wants kToolMoveSelection2DEvent event with nudge and move 2D commands.} k2DToolEnabledInStackedLayerMode = 4; {2D tool wants to be enabled in Unified View.} kToolXPropSetUnrestrictedMode = 5; {set unrestricted scaling mode to the 2D selection tool} kToolInitGlobals = 1; kToolDisposeGlobals = 2; kToolDoSetup = 3; kToolDoSetDown = 4; kToolGetCursor = 5; kToolDoInterface = 6; {// to be removed} kToolDoModeEvent = 7; kToolDoDoubleClick = 8; kToolDoDrawScrMod = 9; kToolDoUndrawScrMod = 10; kToolPointAdded = 100; kToolMouseMove = 101; kToolDrawingDoubleClick = 102; kToolDraw = 103; kToolHandleComplete = 104; kToolGetStatus = 105; kToolPointRemoved = 106; kToolGenericStateChange = 107; { below can be sent to Tool Definition Procedure (TDP) with Extended Properties.} kToolOnInitXProperties = 108; kToolOnSelectionChange = 109; kToolOnMoveSelection2D = 110; kToolCustomSubtypeInsert = 111; kToolOnIdleEvent = 112; kToolOnCustomBarEvent = 113; kStr_HelpSelectPoint = 3000 -1 + 1; {String in PIO. I would move these to strings file now} kStr_HelpSelectOrigin = 3000 -1 + 2; kMode1Btn1 = 'VWRName/Images/ModeViewBar/NameofImage1.png'; kMode1Btn2 = 'VWRName/Images/ModeViewBar/NameofImage2.png'; kModeGroupOrigin = 1; kModeGroupClick = 2; kOriginStore = 9001; kTokenCounter = '<count>'; VAR pt :POINT; {User click point} origin :POINT; {User origin} outAction :LONGINT; outMessage1 :LONGINT; outMessage2 :LONGINT; helpText :dynarray[] of char; result :BOOLEAN; totalPts :LONGINT; firstPt :REAL; modeInt_1 :LONGINT; i :INTEGER; startIndex :INTEGER; adjustTotal :INTEGER; boo :boolean; {---------------------------------------------------------------------} FUNCTION GetOriginMode : REAL; VAR mode:REAL; boo :BOOLEAN; BEGIN vstGetDataLong( kOriginStore, mode, boo ); IF NOT boo THEN mode := 1; GetOriginMode := mode; END; {---------------------------------------------------------------------} BEGIN vstGetEventInfo(outAction, outMessage1, outMessage2); vstGetModeValue(1, modeInt_1); CASE outAction OF kToolInitGlobals : BEGIN END; kToolDisposeGlobals : BEGIN END; kToolDoSetup : BEGIN AddRadioMode( kModeGroupOrigin, 2, kMode1Btn1, kMode1Btn2, '', '', '', '' ); vstSetPtBehavior(4); vstGetModeValue(kModeGroupOrigin, modeInt_1); IF modeInt_1 = kModeGroupOrigin THEN vstSetHelpString(GetPluginString(kStr_HelpSelectPoint)) ELSE vstSetHelpString(GetPluginString(kStr_HelpSelectOrigin)); vstSetDataReal(1, 1, result); END; kToolDoSetDown : BEGIN ReDrawAll; vstGetModeValue(kModeGroupOrigin, modeInt_1); vstSetDataLong( kOriginStore, modeInt_1, boo ); END; kToolGetCursor : BEGIN END; kToolDoInterface : BEGIN END; kToolDoModeEvent : BEGIN IF modeInt_1 = kModeGroupOrigin THEN vstSetHelpString(GetPluginString(kStr_HelpSelectPoint)) ELSE vstSetHelpString(GetPluginString(kStr_HelpSelectOrigin)); END; kToolDoDoubleClick : BEGIN END; kToolDoDrawScrMod : BEGIN END; kToolDoUndrawScrMod : BEGIN END; kToolPointAdded : BEGIN vstNumPts(totalPts); vstGetDataReal(1, firstPt, result); IF (totalPts=2) & (firstPt=1) THEN BEGIN vstSetDataReal(1, 0, result); totalPts:=1; END; IF modeInt_1=kModeGroupOrigin THEN adjustTotal:=0 ELSE adjustTotal:=-1; helpText := GetPluginString( kStr_HelpClicks ); ReplaceStr( helpText, kTokenCounter, Concat( totalPts + 1 + adjustTotal ) ); vstSetHelpString( helpText ); END; kToolMouseMove : BEGIN END; kToolDrawingDoubleClick: BEGIN END; kToolDraw : BEGIN END; kToolHandleComplete : BEGIN vstNumPts(totalPts); IF modeInt_1=kModeGroupOrigin THEN BEGIN {Drawing origin} origin.y:=0; startIndex:=1; END ELSE BEGIN vstGetPt2D(0, origin.x, origin.y, result); startIndex:=2; END; FOR i:=startIndex TO totalPts DO BEGIN vstGetPt2D(i-1, pt.x, pt.y, result); END; RefreshAllLSSched; vstSetHelpString(GetPluginString(kStr_HelpSelectPoint)); vstSetDataReal(1, 1, result); END; kToolGetStatus : BEGIN END; kToolPointRemoved : BEGIN END; kToolGenericStateChange: BEGIN END; END; {CASE} END; Run(MyScript); Quote Link to comment
MullinRJ Posted May 11, 2018 Share Posted May 11, 2018 Josh, You've got my attention. Thanks. Somewhere I've got a recipe for "using" a Hex Editor. I'll post back when I dig it up. So, in your opinion which is harder, going down this route, or learning the SDK? :-) Raymond Quote Link to comment
JBenghiat Posted May 11, 2018 Share Posted May 11, 2018 Getting the tool to work is actually not so bad. Figuring out what events are open to VS takes some trial and error, and they are different for event enabled tools, RunTempTool, and TrackObject. And there still isnt away to get a VS tool to run before the first click. Quote Link to comment
MullinRJ Posted May 11, 2018 Share Posted May 11, 2018 1 hour ago, JBenghiat said: And there still isnt away to get a VS tool to run before the first click. I have run down that dead-end alley, too. Life would be so much more colorful if it did. Thanks, Raymond Quote Link to comment
Julian Carr Posted May 12, 2018 Author Share Posted May 12, 2018 Thanks Josh. I had a bit of a play with it but as you implied, it makes Vectorscript even more of a black box than it is already. Lots of unexplained crashes and mystery. Two things I have built up immunity to over the years, but I still got the bug with this one. Quote Link to comment
MullinRJ Posted May 12, 2018 Share Posted May 12, 2018 I found an old email (GBTML*) with a reference to the Developer Wiki on how to edit a VST to be event-enabled. http://developer.vectorworks.net/index.php?title=VS:vstGetEventInfo Thank Ryan and Conrad for writing this down. Raymond * God Bless the Mailing Lists 🙂 Quote Link to comment
MarcelP102 Posted October 8, 2022 Share Posted October 8, 2022 @JBenghiat Can it be that there is no AddCheckMode option in Vectorscript? I'm looking for a way to toggle an option on or off with a button. Quote Link to comment
JBenghiat Posted October 8, 2022 Share Posted October 8, 2022 I don’t think so. You have to use a two-button radio. 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.