Boh Posted September 17, 2019 Share Posted September 17, 2019 I can’t write script but I do use the inbuilt custom selection and visibility tools to create my own custom scripts a lot. I can’t figure out how, using the Vw menu commands, to create a simple script that simply assigns a currently selected object or objects to a class. Can anyone point me in the right direction? ive started using object styles a lot however for plug in style symbols there is no option to assign a class on insertion. They simply go to the active class. We always leave “none” as our active class so I’m repeatedly having to reassign the class of some plug-in style symbols as soon as I insert them. It would be nice to have a set of little scripts tucked in a palette off to the side which when run will assign the selected object(s) to a predetermined class. Can anyone help? Its probably one line of script?... Quote Link to comment
Julian Carr Posted September 17, 2019 Share Posted September 17, 2019 You could try this: SetClassN(FSActLayer, 'my class name', True); I likely won't work in groups or symbols though. If used on a group (not in a group), the last argument (true or false) will determine if all the objects in the group also get the class assignment. Quote Link to comment
Boh Posted September 18, 2019 Author Share Posted September 18, 2019 Brilliant! Thanks very much Julian. Quote Link to comment
drelARCH Posted September 19, 2019 Share Posted September 19, 2019 (edited) Hi guys, lately i' ve been searching for exactly same script, but I cant make it work I paste line SetClassN(FSActLayer, 'my class name', True); in script window (python), change 'my class name' to my custom one...and save it to resource browser. However when I have selected some object and initiate script i get error messages Am I missing something? In terms of scripting I am beginner. Thanks you in advance for directing me right way. Pavol Edited September 19, 2019 by drelARCH Quote Link to comment
Julian Carr Posted September 19, 2019 Share Posted September 19, 2019 Set the above script to be Vectorscript, not Python. If you can't do that, in python it will be something like this: vs.SetClassN(vs.FSActLayer(), 'my class name', True) but I know nothing about python. Quote Link to comment
Boh Posted September 19, 2019 Author Share Posted September 19, 2019 It’s working perfect for me. If Julian’s suggestions don’t work there is a chance your browser may be introducing erroneous characters when you copy and paste. This has happened to me before but when I did exactly the same copy and paste but with a different browser (firefox in that case) it worked. Try a different browser or simply type the script yourself rather than copy and paste. Quote Link to comment
drelARCH Posted September 19, 2019 Share Posted September 19, 2019 Thanks @Boh for quick response. It's working now for me too. I had to change scripting language to Vectorscript. Pavol 1 Quote Link to comment
Boh Posted October 3, 2019 Author Share Posted October 3, 2019 On 9/18/2019 at 9:46 AM, Julian Carr said: I likely won't work in groups or symbols though. If used on a group (not in a group), the last argument (true or false) will determine if all the objects in the group also get the class assignment. This little script is great@Julian Carr. Unfortunately it doesn't seem to work in viewport annotation space. Is it easy to fix this? Quote Link to comment
grant_PD Posted October 7, 2019 Share Posted October 7, 2019 I can't seem to get this to work. This is what I have, and I get error messages. As I understand it, I have the object selected that I want to change all of its parts and pieces to the current active class, run the command, and it will do this? Quote Link to comment
Boh Posted October 7, 2019 Author Share Posted October 7, 2019 (edited) 4 hours ago, grant_PD said: As I understand it, I have the object selected that I want to change all of its parts and pieces to the current active class No, that script changes the selected object to a particular class - In that case a class called 'my class name'. I don't know of a script that will change objects to the current active class though I imagine that it wouldn't be hard to write one - unfortunately I don't know how to script. I always have 'none' as the active class. If you do that too then you could change 'my class name' in the script to 'none' and the selected objects will then be placed in the none class. It doesn't work within groups or annotations. Edited October 7, 2019 by Boh Quote Link to comment
grant_PD Posted October 8, 2019 Share Posted October 8, 2019 Thanks. I often get confused whether to class everything inside a group/symbol in its proper class, or just the symbol/group itself. I find that classing everything is preferable because it makes the class visibility option work better, but it is a pain to do consistently. Quote Link to comment
Boh Posted October 8, 2019 Author Share Posted October 8, 2019 I always keep the none class as the active class so that I don’t inadvertently create objects on random classes they shouldn’t be on. The none class is always set to visible so I always create the objects on the none class then class them as required (hence why I wanted this “assign class” script). With this way of working groups will always be on the none class with the objects inside classed. That way the grouped objects vp visibilities is only dependant on the class they are on and not also the class the group is on. For most “standard” symbols I do it the other way around where the symbol instance is on a class and the objects inside the symbol are on the none class. I do it this way so: 1. I can set up the symbol to insert straight into a specified class (in edit symbol options). 2. The symbol can be used in different files without bringing in additional classes. 3. The symbol’s visibility still only relies on a single class. Quote Link to comment
Boh Posted February 11, 2020 Author Share Posted February 11, 2020 Coming back to this. The script to assign an object to a class is: SetClassN(FSActLayer, 'my class name', True); I am doing a lot of work in annotation space however this awesome script doesn't work in annotation space or groups. I wish I could edit the script myself to work inside groups/annotations space however I need to resort to any helpful scripters out there who don't mind having a look. If it is a major exercise then I will just leave it but I'm hoping it is simple and would only take a few minutes for someone to tweek... Thanks in advance! Quote Link to comment
Boh Posted February 11, 2020 Author Share Posted February 11, 2020 Many thanks to @Julian Carr for tweeking the assign to class script to work within viewports and groups. Posting here (with his permission) for anyone interested: Procedure SetTheClass; CONST kCName = 'My Class Name'; VAR gh1 : HANDLE; Function DoIt(h1 : HANDLE) : BOOLEAN; BEGIN SetClassN(h1, kCName, True); END; BEGIN Locus(0, 0); gh1 := LNewObj; ForEachObjectInList(DoIt, 2, 2, FInGroup(GetParent(gh1))); DelObject(gh1); END; Run(SetTheClass); 2 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.