Basic examples for managed APIs of Pick List
Introduction
With Pick List, users can specify predefined values from a drop down list in property definition. It is for ItemType only.
The following codes are some of the basic uses of the managed APIs for Pick List.
Basic examples:
- To create Pick Lists
- To load Pick Lists from a given DGN file
- To Rename a Pick List
- To Delete a Pick List value and a Pick List
1. To create Pick Lists:
DgnFile dgnFile = GetDgnFile();
if(null == dgnFile)
return false;
PickListLibrary pickListLib = PickListLibrary.Create();
if(null == pickListLib)
return false;
PickList pickList1 = pickListLib.AddPickList(“Manufacturer”, dgnFile);
if(null == pickList1)
return false;
pickList1.AddValue(“Ford”);
pickList1.AddValue(“BMW”);
pickList1.AddValue(“Benz”);
PickListLibrary.SavePickListLibToDgn(dgnFile, pickListLib, false);
2. To load Pick Lists from a given DGN file:
DgnFile dgnFile = Session.Instance.GetActiveDgnFile();
PickListLibrary library = PickListLibrary.Create();
PickListLibrary.GetPickListLibFromDgn(dgnFile, library);
3. To Rename a Pick List:
PickList pickList = pickListLib.GetPickListByName(“Manufacturer”);
if(null != pickList)
pickList.Name = “Manufacturer2”;
4. To Delete a Pick List value and a Pick List:
PickList pickList = pickListLib.GetPickListByName(“Manufacturer”);
if(null == pickList)
return false;
pickList.RemoveValue(“Ford”);
pickListLib.RemovePickListByName(“Manufacturer”));
To use these APIs, we need reference Bentley.DgnPlatformNET.dll and use namespace Bentley.DgnPlatformNET;
More examples are coming soon.
Accreditation
To find this post and other blog posts, Wiki’s, Announcements on the Bentley Communities website, click here.
If you’re interested in speaking with a Bentley expert about making the move to MicroStation CONNECT Edition, please complete this form to have someone contact you to provide advice and assistance.
Thank you for reading!