Jump to content
Developer Wiki and Function Reference Links ×

Script help for classes


Recommended Posts

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,

Link to comment

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)

Link to comment

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!

Link to comment

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? :-)

Link to comment
  • 3 months later...

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!

Link to comment
  • 2 months later...
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

 

 

 

 

 

Link to comment

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.

 

Link to comment

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

Link to comment

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!

Link to comment

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.

 

 

Link to comment

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?

Link to comment
  • 2 weeks later...

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.

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...