bsalee Posted April 9, 2023 Share Posted April 9, 2023 I would like to script a gesture that I have to do several times an hour... but I'm not too versed in vectorscript. I would like to be able to check or uncheck in one click the dimensions associated with the "Dimensions" class in the Document preferences. Ideally, I would even like to be able to associate the dimensions with the class of my choice in one click. Does a VectorScript expert think this is possible? Quote Link to comment
MullinRJ Posted April 9, 2023 Share Posted April 9, 2023 @bsalee, Could you please explain in a little more detail what you want to happen? Are you referring to this setting in the Document Preferences, as the dimension class name you want to assign? Or, are you wanting to assign another class to dimensions that you click on? Or, do you want to toggle that Document Preference ON and OFF? It is possible to set it up as either a TOOL, or a SCRIPT, but there are some nuances in the way each functions. More detail will help. If you could clarify your request a bit, I or someone else might be able to help. Thank you, Raymond Quote Link to comment
Tom W. Posted April 9, 2023 Share Posted April 9, 2023 (edited) @bsalee see this thread: Is this what you are talking about or something different? I have it set up so I can toggle between two different dimension classes with a right-click menu command: Next task is to have a message appear on the screen telling me which class I've just activated but not had distraction-free moment to try this yet... Edited April 9, 2023 by Tom W. Quote Link to comment
bsalee Posted April 9, 2023 Author Share Posted April 9, 2023 Yes. Thank you VM! Quote Link to comment
bsalee Posted April 9, 2023 Author Share Posted April 9, 2023 (edited) 1 hour ago, MullinRJ said: Or, are you wanting to assign another class to dimensions that you click on? Ideally yes, with a script Edited April 9, 2023 by bsalee Quote Link to comment
MullinRJ Posted April 10, 2023 Share Posted April 10, 2023 @bsalee, If you only want assign a static class name, the script is easy. But if you want to be able to redefine a new Class Name often, the script will need to be more complicated. You can edit this script, or have multiple copies of it in your file, each with a different class name to set commonly used class names. If the class name in this script does not exist in your file, it will be created so you won't have to create it ahead of time. For starters, place the following script in one of your files by adding it to a Script Palette (new or existing). Duplicate it if you want a choice of class names. If you like how it works, you can add this script(s) to your template files so it(they) will always be there when you start new work; or make a Menu Command plug-in, where you can assign a HotKey to it; or make a Tool plug-in, which can also have an assigned HotKey. More on the second and third options when you get that far. Here's the simple script: PROCEDURE ChangeDimClassName; { Click on Dimension objects to change their class to the class name defined in "kNewClass". } { Change constant "kNewClass" to suit your needs. } { If the object you select is not a Dimension object, nothing happens and program continues. } { To STOP, click in empty drawing space, or press any key on keyboard. } { 9 Apr 2023 - Raymond Mullin } CONST kNewClass = 'New Dim Class'; kDimType = 63; VAR H :Handle; X, Y :Real; BEGIN H := FObject; { dummy handle } while (H <> nil) do begin GetPt(X, Y); H := PickObject(X, Y); if (GetTypeN(H) = kDimType) then SetClass(H, kNewClass); end; { while } END; Run(ChangeDimClassName); HTH, Raymond Quote Link to comment
bsalee Posted April 11, 2023 Author Share Posted April 11, 2023 wow ! I try this and come back Quote Link to comment
bsalee Posted April 11, 2023 Author Share Posted April 11, 2023 (edited) Eventually I used this script, fished from the other forum I modified it slightly to account for the fact that I have three classes for the dimensions (so I have three scripts at the end by just modifying C1). It gives this: Procedure SwapDimsAutoClass; {©2023 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} {With great thanks the Raymond Mullin (@MullinRJ) for help in} {identifying the proper Preference code.} CONST C1='Cotations'; VAR H1 :Handle; L1,L2,L3 :LongInt; N1 :Integer; R1 :Real; S1 :String; BEGIN S1:=Index2Name(GetPrefLongInt(546)); BEGIN SetPrefLongInt(546,Name2Index(C1)); End End; Run(SwapDimsAutoClass); THANK YOU all ! Edited April 11, 2023 by bsalee Quote Link to comment
Tom W. Posted April 11, 2023 Share Posted April 11, 2023 6 minutes ago, bsalee said: Eventually I used this script, fished from the other forum I modified it slightly to account for the fact that I have three classes for the dimensions. It gives this: Procedure SwapDimsAutoClass; {©2023 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} {With great thanks the Raymond Mullin (@MullinRJ) for help in} {identifying the proper Preference code.} CONST C1='Cotations'; VAR H1 :Handle; L1,L2,L3 :LongInt; N1 :Integer; R1 :Real; S1 :String; BEGIN S1:=Index2Name(GetPrefLongInt(546)); BEGIN SetPrefLongInt(546,Name2Index(C1)); End End; Run(SwapDimsAutoClass); @bsalee I am completely ignorant about scripting but it looks like this script sets the Dimensions class to 'Cotations' + nothing else - or is that wrong? You're saying it toggles between three different classes? Or you mean you've created three scripts, one for each class + this is just one of them? Thanks! Quote Link to comment
bsalee Posted April 11, 2023 Author Share Posted April 11, 2023 (edited) Yes, I created three scripts, one for each class + this is just one of them, and I click on one of them when needed Edited April 11, 2023 by bsalee Quote Link to comment
Tom W. Posted April 11, 2023 Share Posted April 11, 2023 Ah ok that makes sense. Be interested to know how the original script could be modified to make it cycle between three classes instead of two... Quote Link to comment
Pat Stanford Posted April 11, 2023 Share Posted April 11, 2023 Here you go Tom. Edit C1 to be a list of your classes separated by commas. No extra spaces. Edit Options to be the number of classes you put in C1. Procedure CycleDimsAutoClass; {©2023 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} {With great thanks the Raymond Mullin (@MullinRJ) for help in} {identifying the proper Preference code.} {April 11, 2023} {This script cycles between a number of different classes for } {the VW AutoDimension Class.} {HOW TO CONFIGURE} {Change the values in Options to the number of different classes} {you want to cycle through. Set C1 to the class names you want} {in the order you want to cycle through them separated by} {commas. Make sure the Options and the number of classes} {you store in C1 match.} {This version offers two different notifications of what Class} {has been activated. these are the Message and AlertInform} {lines at the bottom of the script. delete either or both if} {you don't like or need this information. AlertInform shows} {the class name in the data bar at the bottom of the Screen} {which is nice, but it also beeps. Message opens the message} {box, but scripts have not control over the size or location} {of the message box. Also the message will not clear automatically} {as you perform other functions.} CONST Options=6; C1='Dimension,None,John,Paul,George,Ringo'; VAR H1 :Handle; L1,L2,L3 :LongInt; N1, N2 :Integer; R1 :Real; S1 :String; A1 :DynArray of String; BEGIN Allocate A1[1..Options]; For N1:= 1 to Options DO BEGIN A1[N1]:=SubString(C1,',',N1); End; S1:=Index2Name(GetPrefLongInt(546)); N2:=1; For N1:=1 to Options DO Begin If S1=A1[N1] Then N2:=N1+1; End; If N2>Options then N2:=1; SetPref(44, True); SetPrefLongInt(546,Name2Index(A1[N2])); Message('The Dimension Autoclass has been set to: ',A1[N2]); AlertInform(A1[N2],'The Dimesino Autoclass has been set to:',True); End; Run(CycleDimsAutoClass); 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.