Jump to content
Developer Wiki and Function Reference Links ×

Script to toggle class + layer on and off


Christiaan

Recommended Posts

11 minutes ago, Pat Stanford said:

@Tom W.Four things to check as the troubleshooting.

 

1. Is your class name exactly 'NonPlot'?  No space at the end. No underscore or dash between.

2. Rather than as a PIO just go to the resource manager and create a new script. Paste the single line script into there and run it. Does it work?

3. When you pasted the script into the PIO script edit window at the top was a pull down to choose Vectorscript or Python. The code I sent is Vectorscript.

4. Can you send me a blank file with your classes in it so I can test here?

 

Cheers Pat.

 

1. Yes.

2. Yes! When I create it as a document script + run it from a script palette it works!

3. Yes I made sure it was VS not Python. And deleted + remade the plug-in menu command several times but each time it refused to work...

4. Here is a blank file with some 2D Loci on the 'NonPlot' class + the working document script version.

 

Thanks for spending the time on this. Beyond the immediate desire to be able to turn that class on + off more easily it is an interesting + useful introduction to scripting for me!

 

Show:Hide NonPlot script.vwx

Link to comment

@Tom W.I don't know what is wrong.

 

I just went through all the steps. Copied the line exactly from the script. Created a new Command type PIO. Edited my workspace to add to both the Tools menu and the the Document Context right click.


For me it works in all three places.

 

I will DM you a 3 minute screen movie showing exactly what I did and that it worked.

 

Do you use a custom workspace? One that you have migrated from previous versions of VW? If so, try and add the PIO to one of the standard workspaces and see if it works there. If it does I recommend that you screen shot your current workspace and recreate it starting with one of the stock VW2022 versions.

 

HTH.

  • Like 1
Link to comment

@Pat Stanford unless I'm mistaken, with your help I think I've cracked it: the issue it seems was the fact I was naming my Script Plug-in 'Show/Hide NonPlot' i.e. with the backslash. In your video (thank you) you used a different name (without backslash) + it worked so I did the same: 'Show or Hide NonPlot' works but 'Show/Hide NonPlot' doesn't. Does that stack up? Interestingly 'Show/Hide NonPlot' works fine when it's a document script which didn't help in identifying the issue.

 

Anyway I now have it as  'Show or Hide NonPlot' on my right-click plus as a keyboard shortcut + I've learnt a tiny bit about scripting in the process which has been ridiculously satisfying thank you!

 

So now another thing I'm wondering: is it possible to create plug-in menu commands from scripts for:

 

Modify > Guides > Make Guide

Modify > Guides > Delete All Guides

 

?

 

I use Guides all the time + the commands aren't in the Workspace Editor as far as I know so I haven't been able to set shortcuts or assign to mouse buttons. So wondering whether can be done using scripts...

 

Thanks for your help

Link to comment

Guides in in the workspace editor, but it is a "Chunk" and contains all 5 of the Guides commands.

 

I just tried and it will add to the Object Context right click menu, but again you have to accept all 5.  Look under All Commands in the left window and scroll down to Guides.

 

Make Guides is really just setting the class to Guides. You may also have to set all of the attributes to By Class.

 

Delete All Guides is just selecting all the objects in the Guides class and deleting them.

 

Both are scriptable.

 

My guess is if you want to learn how to do them you will need at least 2-3 hours on each to figure out enough of the basics to make them work.

 

But they would be good learning projects for scripting. And I will be happy to point you in the right direction.

 

But if you don't mind the extra

  • Like 1
Link to comment

Slashes in names are always challenging.  They are used as "path separators" in a lot of cases you kind of a folder name / file name type thing.

 

I recommend either dashes (the standard dash is officially an "N" dash as the width is the same as a letter N). Or even better an "M" dash (made by Option dash on the Mac, width of the letter M) which will show in class names without making it a hierarchical  class. Or an Underscore character.

 

Slashes and colons and periods and commas are very bad choices for file names or naming classes or layers or VW objects or scripts.

  • Like 3
Link to comment

This is actually quite moot, but there are 3 dashes that are able to be typed from a Mac keyboard: 

 

1) the hyphen, or minus-sign: "-"

2) the n-dash (Option-hyphen*): "–"

3) the m-dash (Shift-Option-hyphen*): "—"

* on the Mac Keyboard

 

I'm sure you can get there from a Windows keyboard, but I don't know the escape codes off the top of my head.

Okay, I looked them up: type "Alt 0150" for an n-dash and "Alt 0151" for an m-dash. 

 

Nit–pickily yours,

Raymond

  • Like 1
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...