Hi everybody ,
I'm trying to change the level number of a element by this way :
el.Level.Code = 0
But when executes this line I have the error :
err.Number
-2147221504
err.Description
El número de nivel ya se ha utilizado (in english , The number of level has been used).
Any idea of what can be the problem , or another way to change the level number of a element ???.
Thanks for your help , regards !!!
Hi Xavier,
Unknown said:I'm trying to change the level number of a element
This is wrong and it's not how MicroStation works.
What your code does is that is tries to change a number of level, that the element is assigned to. In other words, it tries to change level definition.
So the question is: Do you want to change a number of level or to move an element from one level to another?
I don't remember what MicroStation version do you use, but to work with level numbers is generally not recommended and I guess from V8 XM Edition it's treated as bad practice. In default MicroStation configuration it's not guaranteed the level number exists, the most of levels have no numbers today.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Solved , If a object level is used , and assign to the level of the element if works correctly :
Dim oLevel As Level Set oLevel = ActiveDesignFile.Levels("Por defecto") el.level = oLevelThanks !!
Unknown said:Set oLevel = ActiveDesignFile.Levels("Por defecto")
Set
oLevel = ActiveDesignFile.Levels(
"Por defecto"
)
One more comment: This access to a level object is correct, but is not robust in case the level does not exit and the code crashes with error. If it's ensured the level exists (e.g. dgnlib is used or your code creats the level), the code is fine.
Regards,
This article about levels may help.
Regards, Jon Summers LA Solutions