Jump to content
Developer Wiki and Function Reference Links ×

Selecting text


Onink

Recommended Posts

I made a script to select text en text callouts to change it's class to the text class.
But when I execute this it also changes the dimension lines and text in the color of the text class.
But it doesn't put them in that class.
Only if it's a single measurement, not the chain measurements.

Here's the script:

 

import vs;
vs.SelectObj("INSYMBOL & INVIEWPORT & ((T=TEXT)|(PON='Callout'))");

c='Tekst'
def DoIt(h):
    vs.SetClass(h, c)
    vs.ResetObject(h)
    return()

criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))"
vs.ForEachObject(DoIt, criteria)

 

What goes wrong here?

Edited by Onink
Link to comment

the script sees the text in the measurements as text, but because measurements are supposed to be in the measurements class it conflicts I suppose.

you could try adding C<>'Dimensions' (Class is not dimensions) in your criteria, this way it rules out all dimensions.

Edited by Kars Keizer
Link to comment

I've added some of your suggestions.

But now the dimensions and the arch sections (yes, they changed as well) turn black, but remain in their class.

Here's the script now (maatlijnen is dimensions in Dutch, for our non-Dutch readers...):

import vs;
vs.DSelectAll()
vs.SelectObj("INSYMBOL & INVIEWPORT & ((T=TEXT)|(PON='Callout')) & (C<>'Maatlijnen')");
vs.DSelectObj("INSYMBOL & INVIEWPORT & (PON='NNA_ArchSection')");   

 

c='Tekst'
def DoIt(h):
    vs.SetClass(h, c)
    vs.ResetObject(h)
    return()

criteria="(INSYMBOL & INOBJECT & INVIEWPORT & (SEL=TRUE))"
vs.ForEachObject(DoIt, criteria)
vs.DSelectAll()

 

I added the Dselect arch section line because I thought it didn't work as PON<>NNA_Archsection

I didn't test that option.

 

Does anyone have any idea why my objects turn black, but remain in their class?

Link to comment

al your types of dimensions will stay in their Dimensions (Maatlijnen) class because that is the only class they can exist in, this class you can not delete because of this reason.


if I'm correct you want all your text placed in the text class? and because this class has its text style defined it will also changed the text to that style?
you also don't want to change any dimensions and let them be as they are?

 

Do you have an example file where you want to use your script? than i can test your script whit the presets you are using.

 

you can also look at these functions to use in your script

afbeelding.thumb.png.a40ec4c90d471c79777faf0b5a776d73.png

https://developer.vectorworks.net/index.php/VS:Function_Reference#Objects_-_Text

 

PS. Peter Vandewalle and I are both also Dutch speaking. (but I will continue in English so other people can also use this thread if we find the solution)

Link to comment

At creation dimensions will be created in the dimensions class, if that option is checked in the preferences.

They can be assigned to any other class manually or by script however.

 

If I get it right you want every text and callout to be assigned to the 'Tekst' class. Not section lines, dimensions, ...

 

Then this script should do the trick:

 

def main():
    criteria="INSYMBOL & INVIEWPORT & ((T=TEXT)|(PON='Callout'))"
    vs.ForEachObject(DoIt, criteria)

def DoIt(h):
    vs.SetClass(h, "Tekst")
    vs.ResetObject(h)
main()

 

Scripts run from the resource browser don't need the 'import vs' line.

You don't need to create a selection to pass to the ForEachObject call, you can use the selection criteria.

 

 

Link to comment

You're both right, that's what I want.
I understand what happens with the dimension class, why it would be screwed up.

What I don't understand is why the elimination of the dimension class doesn't work.

 

And sadly Peter, you're script doesn't work either.

It says line#1, identifier not declared

 

I know you guys are Dutch speaking, but to do this in Dutch here wouldn't be appreciated 😉

 

I had this post on the Dutch/Belgium forum, but I didn't get any reaction there...

 

Link to comment
  • 2 weeks later...

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