matteoluigi Posted September 9, 2024 Share Posted September 9, 2024 I try to check componentnames in one of our projects and, due to the fact, that in that project there's a huge number of wallstyles,... I try to solve it with a script. howver VS:SetComponentName doesn't change the componentnames inside that file. (as you can see in the testfile) def schichtkorrektur(hndl): wallname = vs.GetWallStyle(hndl) vs.AlrtDialog(vs.Concat('Wandstilname: ',wallname)) for i in range(1,10): componentname = vs.GetComponentName(hndl,i) cnnameeins = vs.SubString(componentname,'-',1) cnnamezwei = vs.SubString(componentname,'-',2) cnnamedrei = vs.SubString(componentname,'-',3) cnmat = vs.SubString(componentname,'-',4) cnnamefuenf = vs.SubString(componentname,'-',5) cnnamesechs = vs.SubString(componentname,'-',6) vs.AlrtDialog(vs.Concat(cnnameeins,'-',cnnamezwei,'-',cnnamedrei,'-',cnmat,'-',cnnamefuenf,'-',cnnamesechs)) vs.SetComponentName(hndl, i, (vs.Concat(cnnameeins,'-',cnnamezwei,'-',cnnamedrei,'-',cnmat,'-',cnnamefuenf,'-',cnnamesechs))) # vs.SetComponentName(hndl, i, (vs.Concat('MOIN'))) vs.ForEachObject(schichtkorrektur,('T=WALL')) #vs.ForEachObject(schichtkorrektur,'((T=WALL) & (WST=WA-I-NTR-GK*))') he doesn't even replace the componentname with "MOIN" 🤨 any ideas? WANDSKRIPT.zip Quote Link to comment
matteoluigi Posted September 10, 2024 Author Share Posted September 10, 2024 now i did reduce the code to essential problem: def changewallcomp(hndl): for i in range(1,10): vs.SetComponentName(hndl, i, (vs.Concat('MOIN'))) vs.ForEachObject(changewallcomp,('T=WALL')) theorically now all wall components should be named 'MOIN' after having executed that script. Unfortunately, that doesn't work. Did I misunderstand the "SetComponentName" function? Quote Link to comment
matteoluigi Posted September 10, 2024 Author Share Posted September 10, 2024 @Dominique Corpataux @Pat Stanford @JBenghiat sorry but, I'm stuck. vs.GetComponentName works fine. vs.SetComponentName instead doesn't change the wall-component name. Is the function really able to change a wall-component-name? Or did I misunderstand there something? Quote Link to comment
DomC Posted September 10, 2024 Share Posted September 10, 2024 Not near my Mac. I Wonder if you handle the style or the Wall. Quote Link to comment
matteoluigi Posted September 10, 2024 Author Share Posted September 10, 2024 (edited) @Dominique Corpataux Why shouldn’t I handle style and wall? D‘you mean that every change in the wallstyle normally leads to a refresh of all wall objects with this corresponding style, when performed on the usual way, so the command „setcomponentname“ won‘t work that easily? Or what did you want to tell me? Edited September 10, 2024 by matteoluigi Quote Link to comment
DomC Posted September 10, 2024 Share Posted September 10, 2024 I think it is not possible the change the component name of a styled wall. Even manually we are not able to do so. Text is greyed out Quote Link to comment
DomC Posted September 10, 2024 Share Posted September 10, 2024 Short Test. It works with an unstyled Wall. h = vs.FSActLayer() bool = vs.SetComponentName(h, 1, 'ciao') For a Styled Wall, it works by get handle of wall style and set it there: 1 Quote Link to comment
DomC Posted September 10, 2024 Share Posted September 10, 2024 If so i would not just loop the walls in drawing and changing the same stile hundreds of times. I would get the walls and collect the used style names. Then i would eliminate duplicate names and loop the style names. Or collect the Resources directly. Beside that, i would not change object swhich i collect with "ForEachObject" directly in the "ForEachObject" callback function. I would use "ForEachObject" always as a read only manipulation. something like this: wall_style_names = [] def get_objects(h): wall_style_name = vs.GetWallStyle(h) '''hinzufügen, falls nicht schon in der Liste''' wall_style_names.append(wall_style_name) if wall_style_name not in wall_style_names else None vs.ForEachObject(h,('T=WALL')) for wall_style_name in wall_style_names: wall_style_handle = vs.GetObject(wall_style_name) '''security to be sure just manipulating wall styles''' if vs.GetTypeN(wall_style_handle) == 127: #Do your component renaming code here 3 Quote Link to comment
matteoluigi Posted September 11, 2024 Author Share Posted September 11, 2024 @Dominique Corpataux great. Thank you. Makes sense, that it’s not possible editing wall styles through the wall object. thanks for your coding help! Quote Link to comment
matteoluigi Posted September 11, 2024 Author Share Posted September 11, 2024 perfect thing, first checks where positive! Now I try my script in bigger files 🙂 🤞 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.