Onink Posted October 20, 2020 Share Posted October 20, 2020 (edited) 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 October 20, 2020 by Onink Quote Link to comment
Kars Keizer Posted October 20, 2020 Share Posted October 20, 2020 (edited) 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 October 20, 2020 by Kars Keizer Quote Link to comment
Peter Vandewalle Posted October 20, 2020 Share Posted October 20, 2020 And also add "vs.DSelectAll()" before the selection call. 1 Quote Link to comment
Onink Posted October 20, 2020 Author Share Posted October 20, 2020 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? Quote Link to comment
Kars Keizer Posted October 21, 2020 Share Posted October 21, 2020 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 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) Quote Link to comment
Peter Vandewalle Posted October 21, 2020 Share Posted October 21, 2020 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. Quote Link to comment
Onink Posted October 22, 2020 Author Share Posted October 22, 2020 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... Quote Link to comment
LarryO Posted November 4, 2020 Share Posted November 4, 2020 Dimension class and None class are default classes that must exist in every file; therefore they cannot be deleted from a drawing file. While you can rename the Dimension class it still retains an identifier that prevents it from being deleted. 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.