Hello,
It's again question about creating own form instead build-in to place a polygon with feature.
I create a shape using Bentley example for VBA:
Private Sub IPrimitiveCommandEvents_DataPoint(point As Point3d, _ ByVal View As View) m_nPoints = m_nPoints + 1 CommandState.AccuDrawHints.SetOrigin point ReDim Preserve m_arrayPoints(0 To m_nPoints - 1) m_arrayPoints(m_nPoints - 1) = point If (2 < m_nPoints) Then ShowPrompt "Place next point, reset to close the shape" Else ShowPrompt "Place next point" End If CommandState.StartDynamicsEnd SubPrivate Sub IPrimitiveCommandEvents_Dynamics(point As Point3d, _ ByVal oView As View, ByVal drawMode As MsdDrawingMode) If (1 = m_nPoints) Then ' Draw line from first point to current cursor location Dim oLine As LineElement Set oLine = CreateLineElement2(Nothing, m_arrayPoints(0), point) oLine.Redraw drawMode Else Dim i As Integer Dim points() As Point3d ReDim points(m_nPoints) For i = 0 To m_nPoints - 1 points(i) = m_arrayPoints(i) Next i points(m_nPoints) = point ' current cursor location Dim oShape As ShapeElement Set oShape = CreateShapeElement1(Nothing, points, msdFillModeUseActive) oShape.Redraw drawMode End IfEnd Sub' -------------------------------------------------------Private Sub IPrimitiveCommandEvents_Keyin(ByVal Keyin As String)End SubPrivate Sub IPrimitiveCommandEvents_Reset() Dim nPoints As Integer If (2 < m_nPoints) Then '' Dim oShapes As ShapeElement Set oShapes = CreateShapeElement1(Nothing, m_arrayPoints(), msdFillModeUseActive) ActiveModelReference.AddElement oShapes oShapes.Redraw ''oShapes.IsHighlighted = True End If CommandState.StartPrimitive MeEnd SubPrivate Sub IPrimitiveCommandEvents_Start() ShowCommand "VBA Place Shape Example" ShowPrompt "Place first point for shape" Erase m_arrayPoints m_nPoints = 0End Sub
How I could add feature information to my created shape?
Sincerely Yours,
Julia
Hi Julia,
in VBA, the code can look like this:
' Create a shape here' Set oShape = CreateShapeElement1(Nothing, vertices, msdFillModeUseActive)' It's what you have already.Dim oFeature As New xft.featureoFeature.Name = <feature name> 'e.g. oFeature.Name = "PowerLine"oFeature.InitializeProperties "placing"oFeature.Geometry = oShape' You can also modify default values of the featureoFeature.SetProperty <propety name>, <value> 'e.g. oFeature.SetProperty "Voltage", "12kV"oFeature.Write False
I suppose you will be able to transform it to C# code easily. Openly, I don't know if it's the best and/or recommended way, but it works fine so far for me ;-)
In general, what you have to do to create a feature in own way:
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hello, Jan
Thanks a lot!! Your help is great!!!!
one note (I am a bit busy now): There is no reason to use Set oShapes.Level = ActiveDesignFile.Levels.Find(frmComboPlace.txtNewPType.Value) in your code. Level has to be defined in feature definition, so you can create the shape using default level and ApplyAttributeChanges will move the shape geometry to the level as defined in XFM project.
I will try to find some time to check the definition, but not able to promise it for sure now.
Dear Jan,
finally I found whats was wrong! :-) All of 34 incorrect features FillType is AreaPattern.
<FillType useCriteria="ekspluatacijas aizsargjoslas teritorija ap radioteleskopu">AreaPattern<Angle>315</Angle><AngleFromElement>false</AngleFromElement><CellName>simbols3</CellName><ColumnSpacing>12</ColumnSpacing><GenAssocRegions>false</GenAssocRegions><RowSpacing>12</RowSpacing><Scale></Scale><Snappable>false</Snappable><Tolerance></Tolerance><TrueScale>false</TrueScale><RGBColor red="50" green="0" blue="100" /><Color></Color><Weight>0</Weight><Style>stils0</Style></FillType>
But, if is this FillType with mistakes how build-in form can create shapes with correct features?
it's good to know you solve the problem.
Unknown said:But, if is this FillType with mistakes how build-in form can create shapes with correct features?
Well, I think XFM engine doesn't know what the correct feature is, it simply follows XFM project definition and a bit accidentally the result is the correct one.
If you will examine xfmStdOpsLib.mvba (mine is in C:\Program Files (x86)\Bentley\MapStandalone V8i\MapStandalone\vba\) and will start with PlacePolygon method, you will see the code behind is more complex and use different concept than yours. It's general and Command Manager is used, so probably the code behind some method is more robust and is able to resist against XFM project definitions errors better.
In my humble opinion, an imperfection exist in your XFM project (but I am aware I have seen only a part of it and it doesn't relate to the discussed level/fill problem directly): If you use Criteria to define any Feature Symbology parameter, you should always define default value of the setting. Because criterias for a particular parameter are evaluated in an order as are defined in GSA, the default parameter is the last row and it should be defined as fixed value without any criteria. As you probably know, this row cannot be deleted.
I usually use values not used anywhere in the project (default level, "strange" color, weight and style etc.), so any any error exist in the definition, so criteria are not evaluated, the value is still exactly defined and model can be searched for it as a kind of data quality test. Otherwise, what is result value if no criteria passed evaluation and there is no default value?
the problem was very easy - symbols, which used in this AreaPattern just not created and saved yet :-)) And build-in form also draw only line, but not fill. For me, it's good news that my code is less or more correct.
One more time want to tell that Your help was amazing. Thanks a lot.
You're welcome :-)