I would like to change the name of a level, but it don't work.
I use the „Text.dgn“ Example for testing.
Here is a part of the code.
I use: bentley.interop.microstationdgn
using MicroStationDGN;
private MicroStationDGN.Application msApp;
private MicroStationDGN.DesignFile msDGN;
msApp = new MicroStationDGN.Application();
// Works
String DGNLevelName = "ClipShape";
MicroStationDGN.Level dgnLevel = msApp.ActiveDesignFile.Levels.Find(DGNLevelName);
MessageBox.Show(dgnLevel.ID.ToString());
MessageBox.Show(dgnLevel.Name.ToString());
MessageBox.Show(dgnLevel.Description.ToString());
// Works (Focus in Levenmanager switch to ClipShape)
dgnLevel.IsActive = true;
// Problem part
String newName = "Clip";
dgnLevel.Name = newName;
// Works (Levelmanager reloads)
msApp.ActiveDesignFile.Levels.Rewrite();
........................................
At this - dgnLevel.Name = newName;
i alway got a „Level-ID is invalid“.
Same is if i try - dgnLevel.Description = newName;
Debugger gives me a „Level-ID is invalid“.
I have tried some other tests, like:
msApp.ActiveDesignFile.AddNewLevel("Demo_1");
or
msApp.ActiveDesignFile.DeleteLevel("Demo_1");
All works fine.
Whats wrong with my code or the „ string Name { get; set; } “
Thank you
Harry
Hi Harry,
I tested the following code and it works well.
public void ChangeLevelName() { BCOM.Application msApp = BMI.Utilities.ComApp; BCOM.Level dgnLevel = msApp.ActiveDesignFile.Levels.Find("ClipShape"); dgnLevel.Name = "Clip"; msApp.ActiveDesignFile.Levels.Rewrite(); }
So I guess if your level is in your active design file ? If your level "ClipShape" is from level library, it can't be renamed.
HTH, YongAn
And dgnLevel.IsFromLevelLibrary can determine if your dgnLevel is from a level library.
Regards, YongAn
Hi YongAn,
thanks for those fast answer.
At this moment, i do not have testet your code.
I have still another comprehension question.
Inside your Code there is: „BCOM.Application msApp = BMI.Utilities.ComApp;“
So i have: „BCOM.Application“ and: „BMI.Utilities.ComApp;“
Both are COM Components which i have to reference.
So far, so well.
I know, no i dont know, i think, i have to do:
using BMI = Bentley.MicroStation.InteropServices;
using BIM = Bentley.Interop.MicroStationDGN;
But, related to the reference, which reference i have to use for: „Bentley.MicroStation.InteropServices“?
Sometimes i read from „xft“ of which i now point that it is: „XFM Feature Toolkit“.
So, my question is, where are all those documentations from which i experience, which component i have to use and which reference i have to set? There are none API Reference or documentation about that? Most time i read: „Look inside the MicroStationVBA.chm“, all you need to know is inside that help. But it is not, as we can see.
Is the knowledge which i need all inside the „closed bentley selection AREA 51 section“?
If yes, than the only chance which i have is to go to my customer and ask him, if it is possible to make such a SELECTService account for me.
Regards,
Harry, did you read YongAn's tutorials?
Please refer to: Learning MicroStation Addins Step by Step series.
http://communities.bentley.com/members/yongan.fu/blogs/default.aspx
DanPaul,
YongAn's tutorial is in the BDN Member section. I have no SELECTE subscriber level. Thats part of my question above. The good knowledge is in the closed area ;-)
Harry, if you are going to sell your programming products (I assume that because you mentioned a customer), I think you MUST be a Commercial BDN member! Select BDN is relevant only for internal company programming.
Unknown said:If yes, than the only chance which i have is to go to my customer and ask him, if it is possible to make such a SELECTService account for me.
As far as I know...
If you are going to sell your programming products, you MUST be a Commercial BDN member!
Select BDN membership is relevant only for internal company programming.
No I do not sell the development.
And no it is not really a customer, more an acquaintance.
He is a customer of many years of Bentley Microstation.
It's more like a "can you fix this problem for me".
I'm not a Microstation User, i'm a developer.
I only wanted to know, if the expert knowledge and forum is in the BDN area.
After adding a new Level you have to rewrite the level table (class/object: Levels)
from the mvba help:
Sub ToggleLevelDisplay(att As Attachment, strLevelPattern As String)Dim lvls As Levels Dim lvl As Level Set lvls = att.Levels For Each lvl In att.Levels If lvl.Name Like strLevelPattern Then lvl.IsDisplayed = Not lvl.IsDisplayed End If Next lvls.Rewrite RedrawAllViews End Sub
Remarks from the vba help for AddNewLevel Method
This method returns the newly-created Level object.
Subsequently, you should call Levels.Rewrite to make the change permanent.
Version
08.00.00
Ohhh i see, Yogan was already saying this!
Regards
Frank
since 1985: GIS, CAD, Engineering (Civil) Senior Consultant : [Autodesk Civil 3D , Esri ArcGIS, VertiGIS: in previous days : Bentley MS V4 - V8i, GeoGraphics, Bentley Map V8i, InRoads, HHK Geograf, IBr DAVID] : Dev: [C, C++, .NET, Java, SQL, FORTRAN, UML][direct quote by: http://en.wikipedia.org/wiki/Helmut_Schmidt]: "Wer Kritik übel nimmt, hat etwas zu verbergen"Wer Grammatik- und/oder Rechtschreibfehler findet, der darf sie behalten :-)
My "Learning MicroStation Addins Step by Step" articles are in China BDN area which every Be Communities register can read.
Apologize for my disfluent English in these articles. But I promise my native Chinese is fluent. :-)
YongAn