Mickey Posted January 9, 2009 Share Posted January 9, 2009 I asked about this a few years ago, and there was nothing possible. That was back in V11. So I ask again. When I bring an autocad file it brings with it sometimes thousands of classes. If they would just use a dash instead of a space it would sub class them so much better. See below for a partial list of classes in one document. What I want to do is assign these to the class "Set-" and have them keep all the rest of their class name. Any idea if that's possible? Quote Link to comment
Pat Stanford Posted January 9, 2009 Share Posted January 9, 2009 VW2009 (and I think VW2008) do have an option to automatically add a prefix when you import a DWG/DXF. Even better, you can now use Design Layer Viewports to encapsulate the autocad layers in a single file so they don't add to your class list in your working file. Quote Link to comment
panta rhei Posted January 9, 2009 Share Posted January 9, 2009 Mickey, it's your lucky day: I happen to be in a good mood! Instead of adding a prefix when importing, one can rename existing classes with a script PROCEDURE RenameClasses; { ? Petri Sakkinen 1997 } VAR className, newName, firstPart, secondPart : STRING; i, n : INTEGER; BEGIN FOR i:=3 TO CLASSNUM DO BEGIN className:=CLASSLIST(i); n := POS(' ', className); firstPart := COPY(className, 1, n-1); secondPart := COPY(className, n+1, LEN(className)); newName:=CONCAT(firstPart, '-', secondPart); RENAMECLASS(className, newName); END; END; RUN(RenameClasses); Quote Link to comment
Mickey Posted January 16, 2009 Author Share Posted January 16, 2009 Excuse my ignorance. I created a new script in my object resource browser, but I don't think I'm filling out the script correctly. Am I supposed to list all the class names that need to get re-named? Mickey, it's your lucky day: I happen to be in a good mood! Instead of adding a prefix when importing, one can rename existing classes with a script PROCEDURE RenameClasses; { ? Petri Sakkinen 1997 } VAR className, newName, firstPart, secondPart : STRING; i, n : INTEGER; BEGIN FOR i:=3 TO CLASSNUM DO BEGIN className:=CLASSLIST(i); n := POS(' ', className); firstPart := COPY(className, 1, n-1); secondPart := COPY(className, n+1, LEN(className)); newName:=CONCAT(firstPart, '-', secondPart); RENAMECLASS(className, newName); END; END; RUN(RenameClasses); Quote Link to comment
panta rhei Posted January 16, 2009 Share Posted January 16, 2009 Ahh! That script renames all classes with a space in their names. (A quick modification of a stock script that I sometimes use immediately after import.) This is a bit cleverer: it renames only classes with names starting with the trigger string. PROCEDURE RenameClasses; { ? Petri Sakkinen 1997 - 2009 } CONST trigger = 'Set '; { change this as needed - note the space! } replacement = 'Set-'; VAR className, newName : STRING; i, j, n : INTEGER; BEGIN j := LEN(trigger); FOR i := 3 TO CLASSNUM DO BEGIN className := CLASSLIST(i); n := POS(trigger, className); IF (n=1) THEN BEGIN newName := className; DELETE(newName, 1, j); RENAMECLASS(className, CONCAT(replacement, newName)); END; END; END; RUN(RenameClasses); Quote Link to comment
renardruse Posted January 27, 2009 Share Posted January 27, 2009 hi, i don't understand any of the above. I am struggling with the class mapping dialogue tool. How do I run a script and where do you get it? I hoped once I had saved a few class mapping files I could re-use them on many autocad drawings. Sadly each new drawing from each new consultant with all their xrefs bring in a huge array of nonsensical encrypted garbage classes (totally counterproductive by making it too complicated to apply any discipline so that nothing is in its correct layer and the drawing is a clumsy useless bag of poo). I have to merge this tosh with my sensible, plain english, set of classes each time. I was going to ask if there was a way of introducing a wildcard to cover say the front part of an xref set but i see the discussion is more sophisticated already. But can anyone assist? Also - I'm only on VW 12.0.1 Is the answer simply to upgrade? Quote Link to comment
Christiaan Posted January 27, 2009 Share Posted January 27, 2009 Renardruse, there is another way of mapping Classes. When you import a DWG there's an option under the Graphic Attributes tab called 'Add prefix to imported layers' (don't ask me why it's under the Graphic Attributes tab). Check this and specify a prefix and this will allow you to map all classes to a new top level Class. Doesn't allow you to map individual Classes as Class Mapping does but it may suit your purposes. Quote Link to comment
Ray Libby Posted January 27, 2009 Share Posted January 27, 2009 You should definitely update to 12.5.3 It would really help to know your version of Vectorworks, create a signature with that info and computer specs. Here is how to use scripts: http://techboard.nemetschek.net/ubbthreads/ubbthreads.php?ubb=showflat&Number=93218#Post93218 Quote Link to comment
Ajychau Posted August 1, 2012 Share Posted August 1, 2012 That's a pretty awesome Script...looking at making it more user friendly with input dialogs for what the 'trigger' and the 'replacement' could be.. Quote Link to comment
Ajychau Posted August 21, 2012 Share Posted August 21, 2012 (edited) So I added dialog boxes so anyone can just type in the strings of text that need replacing... PROCEDURE FindRenameClasses; { Modded by Andrew Chau based on Renameclasses by ? Petri Sakkinen 1997 - 2009 } VAR className, newName, cs1, cs2 {cs1 is the trigger or to be replaced, cs2 is the replacement} : STRING; i, j, n : INTEGER; BEGIN cs1:=StrDialog(Concat('Find text string in class name to rename...',Chr(13),Chr(13),'Find:'), 'S_'); IF NOT DidCancel THEN cs2:=StrDialog(Concat('Rename text string in class name...',Chr(13),Chr(13),'Replace:'),'X_S-'); j := LEN(cs1); FOR i := 3 TO CLASSNUM DO BEGIN className := CLASSLIST(i); n := POS(cs1, className); IF (n=1) THEN BEGIN newName := className; DELETE(newName, 1, j); RENAMECLASS(className, CONCAT(cs2, newName)); END; END; END; RUN(FindRenameClasses); Edited August 21, 2012 by Ajychau 1 Quote Link to comment
DianaK Posted October 13, 2015 Share Posted October 13, 2015 Ajychau-you're my Hero! 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.