i'am trying to convert my Programms from MSTN 8i to MSTN Connect. Below is my Code for just Marking of Elements with overlapped LineFence.
A LineFence is a FenceShapeElement but it looks like a Line.
It worked really good in MSTN 8i and we need it in MSTN-Connect. My Accudraw is Enabled. I have no locks. View Depth is frm -1000 to 1000.
My Elements have a Z-Koordinate=0. My Problem is, that no Elements will be found and marked.
I will be grateful for your the help. Thanks.
Hier is DGN with Elements
communities.bentley.com/.../Neu6.dgn
Hier is a MVBA-File
communities.bentley.com/.../ElementBeschrifTest.mvba
Public Function BeschriftungStarten() On Error GoTo err If Matrix3dIsXYRotation(CommandState.LastView.Rotation, dblRadians) Then FormatBeschriftungVariablen CommandState.StartDefaultCommand With ActiveSettings 'Zaunmodus auf Block Überlappung setzen .FenceClip = False .FenceOverlap = True .FenceVoid = False End With CommandState.StartPrimitive New clsFlaecheZaun Else MsgBox MsgAnsVerdreht, vbInformation, "Programmabbruch - BoeKonstruieren" End If Exit Function err: Select Case err Case Else MsgBox "Error in [mod1Haupt]\\BeschriftungStarten\\ " & _ vbCrLf & err.Description, vbCritical, err.Number' Resume End Select End Function'HIER is the Code for "clsFlaecheZaun" Option Explicit Implements IPrimitiveCommandEvents Dim Origin As Point3d, Shp(3) As Point3d Dim Rot As Matrix3d, Plane As Plane3d, Sh As ShapeElement Dim nPnts As Long, ElNum As ElementEnumerator Private Sub IPrimitiveCommandEvents_Cleanup() 'not used End Sub Private Sub IPrimitiveCommandEvents_DataPoint(Point As Point3d, ByVal View As View) If nPnts = 0 Then Origin = Point nPnts = 1 Plane.Origin = Point ShowPrompt " 2-Punkt setzen" CommandState.StartDynamics ElseIf nPnts = 1 Then CommandState.StopDynamics' Set ElNum = Nothing Set ElNum = getElementsFromFenceOrSelectionSet() blnItemsHaveBeenSelected = SelectFromEnumerator(ElNum)' CommandState.StartLocate New clsBeschrSchnPkte End If End Sub Private Sub IPrimitiveCommandEvents_Dynamics(Point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode) If DrawMode = msdDrawingModeTemporary Then If CommandState.AccuDrawHints.IsEnabled Then Rot = Matrix3dInverse(CommandState.AccuDrawHints.GetRotation(View)) Else Rot = Matrix3dInverse(View.Rotation) End If Plane.Normal = Point3dFromMatrix3dColumn(Rot, 2) Point = Point3dProjectToPlane3d(Point, Plane) Shp(0) = Origin Shp(1) = Point3dInterpolate(Shp(0), 1, Point) Shp(2) = Point Shp(3) = Point3dInterpolate(Shp(0), 1, Shp(2)) If (1 = nPnts) Then Set oFenceLine = CreateLineElement2(Nothing, Origin, Point) End If Set Sh = CreateShapeElement1(Nothing, Shp) Set oFence = ActiveDesignFile.Fence oFence.DefineFromElement View, Sh End If Sh.Color = 70: Sh.LineWeight = 1 Sh.Redraw DrawMode oFence.Draw End Sub Private Sub IPrimitiveCommandEvents_Keyin(ByVal Keyin As String) 'not used End Sub Private Sub IPrimitiveCommandEvents_Reset() CommandState.StopDynamics If Not oFence Is Nothing Then oFence.Undefine CommandState.StartDefaultCommand End Sub Private Sub IPrimitiveCommandEvents_Start() Set oFence = Nothing: Set oFenceLine = Nothing: Set Sh = Nothing: Erase Shp ShowCommand "Strich zur Elementauswahl " ShowPrompt " 1-Punkt setzen" CommandState.EnableAccuSnap End Sub Public Function getElementsFromFenceOrSelectionSet() As ElementEnumerator 'Returns the ElementEnumerator of the selected elements'from either a fence or a selection set Dim tmpFence As Fence Dim oElEnum As ElementEnumerator Dim element As element Set tmpFence = ActiveDesignFile.Fence If tmpFence.IsDefined = True Then Set oElEnum = tmpFence.GetContents(False, True) Else Set oElEnum = ActiveModelReference.GetSelectedElements End If Set getElementsFromFenceOrSelectionSet = oElEnum End Function Public Function SelectFromEnumerator(oElEnum As ElementEnumerator) As Boolean 'Selected the element(s) in the ElementEnumerator variable'Returns True if items selected False if items not selected Dim oElement As element 'element currently being processed SelectFromEnumerator = False If ActiveModelReference.AnyElementsSelected Then Set oElEnum = ActiveModelReference.GetSelectedElements End If oElEnum.Reset Do While oElEnum.MoveNext Set oElement = oElEnum.Current ActiveModelReference.SelectElement oElement, True SelectFromEnumerator = True Loop End Function