I've got a feature of type PolygonCollection in my map dgn.
In the schema the fature has a fillcolor and a pattern set.
Now I want to retrieve that Information by code from the feature in the designfile?
The feature geometry is a microstation typ 106.
Fillcolor an GetPattern function only work on closed element.
How can I get this Info?
The shape elements are stored as sub-features in the XFM type 106 polygon collection. The following bold Bentley Map VBA code should give you an idea of how you can traverse the polygon collection and obtain information from each sub-feature shape elements.
Private Sub processPolygons()
Jeff Bielefeld [Bentley]
Thanks for your answer. I'am attaching an example DGN und my Code to get the FillColor and the Pattern Info from the feature.
Public ee As ElementEnumerator
Public eeCount As Long
Public fe As FeatureEnumerator
Public feCount As Long
Private Sub ILocateOpEvents_OnCleanup()
Private Sub ILocateOpEvents_OnFinished(ByVal locateOp As xft.ILocateOp)
eeCount = locateOp.LocatedElementsCount
Set ee = locateOp.GetLocatedElements()
feCount = locateOp.LocatedFeaturesCount
Set fe = locateOp.GetLocatedFeatures()
Private Sub ILocateOpEvents_OnRejected(ByVal RejectedReasonType As xft.LocateOpRejectedReasonType, RejectedReason As String)
Private Sub ILocateOpEvents_OnTerminate()
Private Sub ILocateOpEvents_OnValidate(ByVal RootFeature As xft.IFeature, ByVal Element As Element, Point As Point3d, ByVal View As View, Accepted As Boolean, RejectReason As String)
Private Sub CheckPatternInfo(ele As ClosedElement)
Dim pat As Pattern
On Error GoTo errHandler
Debug.Print "HasPattern=" = ele.HasPattern()
If ele.HasPattern Then
Set pat = ele.GetPattern()
Public Sub CopyFeatureToNewFile()
Dim fea As feature
Dim feaNumer As Integer
Dim selFeatures As SelectFeatures
Dim oLocateOp As New locateOp
oLocateOp.IncludeOnlyFeatures = True
oLocateOp.Mode = LocateOpMode.locateOpModeScan
oLocateOp.AutoAcceptScanFile = True
Set selFeatures = New SelectFeatures
CmdMgr.StartLocateOperation oLocateOp, selFeatures
feaNumer = 1
Do While (selFeatures.fe.MoveNext)
'On Error Resume Next
Set fea = selFeatures.fe.Current
If Not fea Is Nothing Then
If fea.GetFeatureDefinition.IsCollection Then
Dim index As Long
For index = 0 To (fea.SubFeatureCount - 1)
Dim oSubFeature As feature
Set oSubFeature = fea.GetSubFeature(index)
Debug.Print "Number:" & CStr(feaNumer) & " Geometry Type=" & .Geometry.Type
If .GeometryType = GEOMETRYTYPE_Polygon Then
If .FillMode = msdFillModeNotFilled Then
Debug.Print "FillColor=" & .FillColor
feaNumer = feaNumer + 1
The output at my cumputer is:
Number:1 Geometry Type=14FillMode=NotFilledFillColor=74HasPattern=FalseNumber:2 Geometry Type=14FillMode=NotFilledFillColor=74HasPattern=FalseNumber:3 Geometry Type=14FillMode=NotFilledFillColor=74HasPattern=FalseNumber:3 Geometry Type=6FillMode=NotFilledFillColor=74HasPattern=FalseNumber:4 Geometry Type=6FillMode=NotFilledFillColor=74HasPattern=FalseNumber:4 Geometry Type=14FillMode=NotFilledFillColor=74HasPattern=False
I'am not able to get the correct fill and pattern informations.
Is there anything wrong in my code?
Using your data and code have been able to replicate what you are reporting. I'm working now to determine if this is a previously unreported defect. I will update you my findings once complete.
I would be interested to know more about what you are attempting to do in case this turns out to be a confirmed defect. I could then possibly help you find a temporary workaround.
I want to create a design file, where the collection feature will be placed as a groupt hole.
There is an app for printing designfiles, which is not able to print the collection elements correctly.
Now when I want to create the groupt hole, I must attach the fill and pattern info from the original elements.
Please be aware that you can use "File > Save As..." with "Options > XFM > Convert from 08.11.09.xx to 08.11.07.xx" selected to create a design file with the type 106 polygon collection elements converted to associative regions.
how can I get the assiciated region from the feature?
Has the feature a function to get that element?
Is the printing app to which you refer unable to process the XFM V1 08.11.07.xx formatted file? I suggested that to potentially eliminate the need to process the XFM V2 08.11.09.xx formatted file.
Attempting to read the fill and pattern information from the type 106 may not be possible using VBA so I was wondering if you have MDL or C/C++ development experience?
the VBA app is for a customer of me. He want's to edit/manupulate the code and he has only experience in VBA.
I ask him to try the plot with the 08.11.07.xx format.
What are the functions to get the fillcolor and patter info from a type 106 element in MDL/C++