Hi,
Even though there is a level which is created by keyin in vba code, cannot be reached by Activedesignfile.Levels
lvlName = "building" For Each lvl In ActiveDesignFile.Levels If lvl.name = lvlName Then GoTo 10 Next lvl CadInputQueue.SendKeyin "Level Create " & lvlName ActiveDesignFile.Levels.Rewrite10:
'Set lvl = ActiveDesignFile.Levels(lvlName) Set lvl = ActiveDesignFile.Levels.Find(lvlName) lvl.UsingOverrideColor = True ....
On debug mode, I press Ctrl+E and see there is building level created, but I cannot get it by loop with Activedesignfile.levels
I dont use model file other than default model.
Even Activedesignfile.Levels.count gives less than actual level count in that case.
If I close microstation and run my vba again, everything is ok.
The Problem is I dont understand why sometimes Activedesignfile.levels doesnt give me all levels in Level Manager.
Has anybody got same problem ?
regards,
Olcay Ebcin
Mixing declarative code with queued commands sometimes leads to inconsistent results. Since you are working with ActiveDesignFile.Levels, why not simply add a level to that collection …
Dim levelName As String levelName = "level name" Dim oLevel As Level Set oLevel = ActiveDesignFile.Levels.Find (levelName) If oLevel Is Nothing Set oLevel = ActiveDesignFile.AddNewLevel (levelName) ActiveDesignFile.Levels.Rewrite EndIf
Note: in some versions of MicroStation VBA, if Levels.Find fails then it raises an error rather than returning Nothing.
Regards, Jon Summers LA Solutions