rosebud5 Posted April 18, 2016 Share Posted April 18, 2016 Hello all, I had great help with my last line weight request (script to change line weights) Now I would like to create a script for when I click on an object it automatically transfers to the chosen class, i.e., select object, run script that puts object in specified class according to script. Any ideas. Selected object is currently in NONE class and, ideally, I click "furniture class script" and it puts it into furniture class. I know that i can do this from the OIP, but would love to make a speedier way to go about it. Thanks, Quote Link to comment
DomC Posted April 18, 2016 Share Posted April 18, 2016 If it may be python: #python code c='class-1' def changeclass(h): vs.SetClass(h, c) return() vs.ForEachObjectInLayer(changeclass, 2, 1, 2) If you use this, check http://developer.vectorworks.net/index.php?title=VS:ForEachObjectInLayer for options Because "selectec object" could mean different things (all selected everywhere, just visible objects, etc.) You can use also: c='class-2' def changeclass(h): vs.SetClass(h, c) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(changeclass, criteria) Quote Link to comment
rosebud5 Posted April 22, 2016 Author Share Posted April 22, 2016 Hi Thanks for the quick reply, I am not familiar with python so I choose your second option. I am trying to click on the selected item that is currently in the "None" class and put it an existing class called "Apt Construction" I put put that class name as the first line that read c='Apt construction' def changeclass(h): vs.SetClass(h, c) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(changeclass, criteria) I am thinking that maybe it should read c='None' def changeclass(Apt Construction): vs.SetClass(h, c) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(changeclass, criteria) Thanks for your help! Quote Link to comment
DomC Posted April 24, 2016 Share Posted April 24, 2016 Hi I think its just a problem of actualisation of the info-palette-view. The Objects change the class, but you do not see that immediately. To fix that, you could use "vs.ResetObject(h)" in the script Try this: c='Apt Construction' def DoIt(h): vs.SetClass(h, c) vs.ResetObject(h) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(DoIt, criteria) To unterstand the stript: 1. c='class', just set c to 'class'. Instead of that we could use also vs.SetClass(h, 'class') To use there a variable is better, because maybe later you want to input that class name in a dialog box etc. So it is better "ask" for the variable valuesat the beginning of a script. I am thinking that maybe it should read c='None' def changeclass(Apt Construction): vs.SetClass(h, c) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(changeclass, criteria) not really, if you want to work whith an activated object. Your idea goes in a direction to put all objects in "None" to another class. (Which also could be realized) the function ( which starts with "def"), containes a callback function for ForEachObject (FEO). And FEO takes a handle to the object and input it in the function as "h". Your Class Name you do not have to input by "FEO", because you defined it at start with c='Apt Construction' FEO loops all objects by a criteria and "def" says, what to do with them. Above I renamed the function to "DoIt". This makes it more clear, what happens. All clear? :-) Quote Link to comment
rosebud5 Posted April 25, 2016 Author Share Posted April 25, 2016 Amazing, you really know you stuff, thank you, greatly appreciated and thanks for the video, huge help!!!! Quote Link to comment
rosebud5 Posted August 24, 2016 Author Share Posted August 24, 2016 Hello, I have been using my class script that DomC helped me with (see above). However, when I use the script to change the class of certain objects, for example, walls, it does not take on the attributes. It changes the class and some attributes like dash line but not line wieight. Any suggestions would be greatly appreciated. Thanks! Quote Link to comment
rosebud5 Posted August 24, 2016 Author Share Posted August 24, 2016 Also, when I click on the object and manually go to the class in the nav. palette and "assign to selection" it takes on the attributes, line weight, dash, etc. just fine. Quote Link to comment
Hippocode Posted August 24, 2016 Share Posted August 24, 2016 When you assign a class by script I don't think the object is "redrawn". Try resetting each object after you change the class. Quote Link to comment
Lilith Gardell Posted November 22, 2016 Share Posted November 22, 2016 On 24.4.2016 at 7:19 PM, DomC said: c='Apt Construction' def DoIt(h): vs.SetClass(h, c) vs.ResetObject(h) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(DoIt, criteria) Hi, how happy was I to find your questions and answers about setting the class of an activated object to a certain class. I am quite new to work with scripts (and in this forum). I gave it a try and just copied the above script and changed the name of the class to the one I need. Maybe you could help me with this error: File "<string>", line 3 vs.SetClass(h, c) ^ IndentationError: expected an indented block Do you know what I should change? Thanks a lot, Lilith Quote Link to comment
Patrick Winkler Posted November 22, 2016 Share Posted November 22, 2016 Hello Lilith, other than in the most programming languages code blocks are nested by intendation in Python. (usualy by 4 whitespaces or one tab) I hope now it works: c='Apt Construction' def DoIt(h): vs.SetClass(h, c) vs.ResetObject(h) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(DoIt, criteria) Quote Link to comment
Lilith Gardell Posted November 22, 2016 Share Posted November 22, 2016 Hello Patrick, thank you very much! I`m not there yet. Now there is a Syntax Error with invalid syntax in the last line. Quote Link to comment
Marionette Maven Marissa Farrell Posted November 22, 2016 Marionette Maven Share Posted November 22, 2016 c='Apt Construction' def DoIt(h): vs.SetClass(h, c) vs.ResetObject(h) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(DoIt, criteria) Maybe this will work? 1 Quote Link to comment
Lilith Gardell Posted November 22, 2016 Share Posted November 22, 2016 It works! Thank you very much, MarissaF! Life will be so much easier now. And I definitely have to learn more about scripting... Quote Link to comment
Lilith Gardell Posted November 22, 2016 Share Posted November 22, 2016 Hhm... well... it behaves differently than expected. When I blend out this special class, all other objects are also blended out - as if they are set to this class too even if they are not and the info palette doesn`t say so either. I have to change the class to another class and then back to the original class for them not to blend out too. The objects are lighting instruments. I guess I should have said so. Other objects don`t show this behavior (like rectangles or circles). With them it works as expected. Quote Link to comment
Patrick Winkler Posted November 23, 2016 Share Posted November 23, 2016 Could you provide an example VWX? Quote Link to comment
Lilith Gardell Posted November 23, 2016 Share Posted November 23, 2016 Hi Patrick, I did some tests to get the idea with what kind of object it works and with what kind it doesn't. Symbols from the VWX library that are not lighting instruments work. Drawn objects work. I change them to be a lighting device - it still works. I change them to be a symbol in my library - it doesn't work. I don't get the pattern yet. If you blend out the class "spielt nicht mit" - you can see the results. Script_Tests_Klasse_zuordnen_v2.vwx Quote Link to comment
Patrick Winkler Posted November 24, 2016 Share Posted November 24, 2016 When I select all Objs and run the script they all are put into 'spielt nicht mit'. Sorry if I can't follow you. Mayber you should check the criteria. You can easily create create them with the criteria dialog (click in the left corner of the script dialog): Quote Link to comment
Lilith Gardell Posted November 24, 2016 Share Posted November 24, 2016 Hi Patrick, I would like to select lighting instruments, run the script to put just the selected ones into the class 'spielt nicht mit' and leave all the other lighting instruments unchanged. At the moment it puts all lighting instruments into the class wether they are selected or not. So the criteria should be "activated" or "selected". I will have a look at the criteria dialog you mentioned. Thank you, Patrick! Quote Link to comment
Patrick Winkler Posted November 24, 2016 Share Posted November 24, 2016 Hi Lilith, (SEL=TRUE) should do it. Notice that the Objects in the Symbol defintion will stay in old class while the instances get placed into 'spielt nicht...' Quote Link to comment
Lilith Gardell Posted November 24, 2016 Share Posted November 24, 2016 Yes, the objects stay in their old class - that`s what the info palette says - but they are blended out anyway when I blend out 'spielt nicht mit'. Only lighting instruments behave like that. That was the test about I tried to explain above. They are somehow in both classes now. You can blend them out with their old class or with 'spielt nicht mit'. That's kind of weird. Quote Link to comment
Lilith Gardell Posted November 24, 2016 Share Posted November 24, 2016 c='spielt nicht mit' def DoIt(h): vs.SetClass(h, c) vs.ResetObject(h) return() criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))" vs.ForEachObject(DoIt, criteria) (SEL=TRUE) is already part of the criteria, but it somehow doesn`t work. At least I don`t get how. Quote Link to comment
Lilith Gardell Posted November 24, 2016 Share Posted November 24, 2016 Okay... I changed it to criteria="((SEL=TRUE))" and it seems to work like I would expect. I will run some more tests. Quote Link to comment
Lilith Gardell Posted November 24, 2016 Share Posted November 24, 2016 Hello, after some tests I figured out that I need to find a way to exclude both groups and layouts and objects that are not visible at the moment (for the last I found something: (NOTINDLVP & NOTINREFDLVP & (V)) otherwise there will be bad surprises. Or train myself to never ever leave something activated/selected in a group or layout or in a class or layer that is not visible... no, wait, if I change the class of an object to another class that is not visible (which I need to do very often) I`d have to change this new class to be visible again, deselect all objects, hide the class again and then go on with my work. That seems to be more work than to do all that without the script... hhm... Are there any other ideas? Quote Link to comment
bcd Posted December 2, 2016 Share Posted December 2, 2016 Have you tried setting up Saved Views to control class visibilities ? &/or simply locking those instruments that you don't want to be mitgespielt. Quote Link to comment
Lilith Gardell Posted December 2, 2016 Share Posted December 2, 2016 Hi bcd! I am searching for a faster way via script to "park" lighting devices into a certain class that is invisible in my layouts. (During rehearsal process the lighting devices of our standard equipment tend to be thrown out and then be part of the play again and so on.) Saved Views don't help with that, do they? What does locking instruments mean? I got some ideas from one of the instructors how to adjust the criteria. Didn't have time yet to test them. 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.