Jump to content

VS:SetComponentName doesn't change componentname


Recommended Posts

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?

 

image.png.2d5012d5e38a9ca8b3b22c041ae02955.png

 

 

WANDSKRIPT.zip

Link to comment

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?

Link to comment

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



 

  • Like 3
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...