Basic examples for managed APIs of Pick List

Bentley MicroStation
MicroStation CONNECT SDK
2 min readDec 4, 2019
Photo by Joshua Aragon on Unsplash

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:

  1. To create Pick Lists
  2. To load Pick Lists from a given DGN file
  3. To Rename a Pick List
  4. 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!

--

--

Bentley MicroStation
MicroStation CONNECT SDK

MicroStation is used by the world’s leading infrastructure professionals for design, documentation, and visualization of projects of any scale and complexity.