Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all 4331 articles
Browse latest View live

Accusnap strangeness in iPrimitiveCommandEvents

$
0
0

I've encountered an issue where, in certain drawings and at certain times (it seems to be related to the complexity and size of the drawing) the accusnap settings will seem to stop working wrt data passed to the code.

The code, which I've included below, uses an iPrimitiveCommandEvents interface to interactively place and rotate a cell, while incrementing a number stored as a tag in that cell. What happens is that the user will move the cell to where it is to be place, and accusnap will appear to work. It will show the yellow snap icon, but when the user clicks, the placement of the cell will be off by a small amount, depending on the zoom level of the view. When I enabled the snapping sounds, I noticed that it clicked rapidly whenever I clicked to provide a data point: 3-4 or more clicks in half a second or so.This occurs even when I set the mouse sensitivity to very low, or even lift up the mouse so that it's not sending any movement data.

I've already checked my lock settings to ensure I don't have any locks turned on, and I've tried setting the snaps in different ways. I've tried restarting MS and my computer, all with no avail. I've found that closing the current drawing and opening a new one causes the problem to go away, until I return to the old drawing. But I had previously used the same command in this drawing without encountering this issue, and AFAIK, the only difference is the amount of geometry in it.

Is anyone else familiar with this bug, or have any advice on dealing with it?

Code I'm using:

Option Explicit
Implements IPrimitiveCommandEvents

Dim strCellName As String
Dim intNum As Integer
Dim longScale As Long

Dim firstClick As Boolean
Dim oCell As CellElement
Dim oPoint As Point3d
Dim cellNameList(0 To 4) As String
Dim cellIndex As Integer
Dim baseRotation As Matrix3d
Dim baseAngle As Double
Dim twoVPCell As Boolean
Dim secondVPcell As Boolean

Public Property Let cellName(ByRef val As String)
    strCellName = val
End Property
Public Property Get cellName() As String
    cellName = strCellName
End Property

Public Property Let SheetNum(ByRef val As Integer)
    intNum = val
End Property
Public Property Get SheetNum() As Integer
    SheetNum = intNum
End Property

Public Property Let cellScale(ByRef val As Long)
    longScale = val
End Property
Public Property Get cellScale() As Long
    cellScale = longScale
End Property

Private Sub IPrimitiveCommandEvents_Cleanup()
    
End Sub

Private Sub IPrimitiveCommandEvents_DataPoint(point As Point3d, ByVal vw As View)
    EventTrigger point, msdDrawingModeNormal
End Sub

Private Sub IPrimitiveCommandEvents_Dynamics(point As Point3d, ByVal vw As View, ByVal drawMode As MsdDrawingMode)
    EventTrigger point, drawMode
End Sub

Private Sub IPrimitiveCommandEvents_Keyin(ByVal Keyin As String)
    If IsNumeric(Keyin) Then
        If Keyin = "0" Then
            CommandState.AccuDrawHints.SetOrientationByRotation baseRotation
        Else
            intNum = CInt(Keyin)
            If twoVPCell And secondVPcell Then
                ShowPrompt "Click to place and rotate viewport " & CStr(intNum) & "B"
            ElseIf twoVPCell Then
                ShowPrompt "Click to place and rotate viewport " & CStr(intNum) & "A"
            Else
                ShowPrompt "Click to place and rotate viewport " & CStr(intNum)
            End If
        End If
    Else
        Select Case Keyin
            Case "-"
                If cellIndex = 0 Then
                    cellIndex = 4
                Else
                    cellIndex = cellIndex - 1
                End If
            Case "-"
                If cellIndex = 0 Then
                    cellIndex = 4
                Else
                    cellIndex = cellIndex - 1
                End If
            Case "="
                If cellIndex = 4 Then
                    cellIndex = 0
                Else
                    cellIndex = cellIndex + 1
                End If
            Case "+"
                If cellIndex = 4 Then
                    cellIndex = 0
                Else
                    cellIndex = cellIndex + 1
                End If
        End Select
        strCellName = cellNameList(cellIndex)
    End If
End Sub

Private Sub IPrimitiveCommandEvents_Reset()
    If Main.cellLib <> "" Then
        AttachCellLibrary (Main.cellLib)
    End If
    Main.cellLib = ""
    CommandState.StartDefaultCommand
End Sub

Private Sub IPrimitiveCommandEvents_Start()
    firstClick = False
    
    If Right(strCellName, 3) = "2VP" Then
        twoVPCell = True
        secondVPcell = False
    Else
        twoVPCell = False
    End If
    CommandState.CommandName = "Place Viewports"
    ShowCommand CommandState.CommandName
    ShowPrompt "Click to place and rotate the first viewport"
    CommandState.StartDynamics
    CommandState.EnableAccuSnap
    cellNameList(0) = strCellName & "_MC"
    cellNameList(1) = strCellName & "_LL"
    cellNameList(2) = strCellName & "_LR"
    cellNameList(3) = strCellName & "_UR"
    cellNameList(4) = strCellName & "_UL"
    strCellName = strCellName & "_MC"
    cellIndex = 0
    Dim var As Variant
    Dim vw As View
    For Each var In ActiveDesignFile.Views
        Set vw = var
        If vw.IsSelected Then baseRotation = vw.Rotation
    Next var
    CommandState.AccuDrawHints.SetOrientationByRotation baseRotation
End Sub

Private Sub EventTrigger(ByRef point As Point3d, ByVal drawMode As MsdDrawingMode)
    'Put code here to create item
    Dim rotMatrix As Matrix3d
    Dim oTags() As TagElement
    Dim i As Integer
    Dim scaler As Point3d
    Dim ang As Double
    Dim eTag As TagElement
    If longScale <= 1 Then
        scaler.x = PCS_Tools.LocalDGNData.DGNScale
        scaler.y = PCS_Tools.LocalDGNData.DGNScale
        scaler.z = PCS_Tools.LocalDGNData.DGNScale
    Else
        scaler.x = longScale
        scaler.y = longScale
        scaler.z = longScale
    End If
    If drawMode = msdDrawingModeNormal Then
        If Not firstClick Then
            oPoint = point
            firstClick = True
        Else
            ang = GetAngle(oPoint, point)
            rotMatrix = Matrix3dFromAxisAndRotationAngle(2, ang - baseAngle)
            Set oCell = CreateCellElement2(strCellName, oPoint, scaler, True, rotMatrix)
            oCell.Redraw drawMode
            ActiveModelReference.AddElement oCell
            If twoVPCell Then
                If secondVPcell Then
                    oTags = oCell.GetTags
                    For i = LBound(oTags) To UBound(oTags)
                        Set eTag = oTags(i)
                        eTag.Redraw msdDrawingModeErase
                        eTag.Value = CStr(intNum) & "B"
                        eTag.Redraw
                        eTag.Rewrite
                    Next i
                    intNum = intNum + 1
                    secondVPcell = False
                Else
                    oTags = oCell.GetTags
                    For i = LBound(oTags) To UBound(oTags)
                        Set eTag = oTags(i)
                        eTag.Redraw msdDrawingModeErase
                        eTag.Value = CStr(intNum) & "A"
                        eTag.Redraw
                        eTag.Rewrite
                    Next i
                    secondVPcell = True
                End If
            Else
                oTags = oCell.GetTags
                For i = LBound(oTags) To UBound(oTags)
                    Set eTag = oTags(i)
                    eTag.Redraw msdDrawingModeErase
                    eTag.Value = CStr(intNum)
                    eTag.Redraw
                    eTag.Rewrite
                Next i
                intNum = intNum + 1
            End If
            firstClick = False
            rotMatrix = Matrix3dFromAxisAndRotationAngle(2, Abs((2 * Pi) - ang + baseAngle))
            CommandState.AccuDrawHints.SetOrientationByRotation rotMatrix
            If twoVPCell And secondVPcell Then
                ShowPrompt "Click to place and rotate viewport " & CStr(intNum) & "B"
            ElseIf twoVPCell Then
                ShowPrompt "Click to place and rotate viewport " & CStr(intNum) & "A"
            Else
                ShowPrompt "Click to place and rotate viewport " & CStr(intNum)
            End If
        End If
    Else
        If Not firstClick Then
            rotMatrix = Matrix3dFromAxisAndRotationAngle(2, Abs((2 * Pi) - baseAngle))
            Set oCell = CreateCellElement2(strCellName, point, scaler, True, rotMatrix)
            oCell.Redraw drawMode
        Else
            ang = GetAngle(oPoint, point)
            rotMatrix = Matrix3dFromAxisAndRotationAngle(2, ang - baseAngle)
            Set oCell = CreateCellElement2(strCellName, oPoint, scaler, True, rotMatrix)
            oCell.Redraw drawMode
        End If
    End If
End Sub

This is Microstation V8i SS3, version 08.11.09.714


[CONNECT C++] DgnElementSetTool auto-process multiple elements

$
0
0

I'm using a class derived from DgnElementSetTool to process multiple elements. My hope is to have a uniform way of processing selection sets and fences automatically.  The tool is not used to pick single elements.

When I call the class, I'd like to process multiple elements automatically without further user interaction. I override several virtual functions to attempt a solution:

virtual bool _NeedAcceptPoint () override { return false;    }
virtual bool _NeedPointForSelection () override { return false; }

When the agenda has been processed, I call this to terminate the tool:

virtual bool _OnModifyComplete (DgnButtonEventCR ev ) override { return true; }

The above works fine when the element source is a selection set: the tool starts, processes its agenda and terminates without further ado. What I can't figure out is how to process a fence without a confirming data point from the user. That is, something like _NeedPointForFence() but I don't see that method.

oMessage.point.x to word processor

$
0
0

MicroStation V8i SS4

Hey all, I have create some code to place a cell, record that placement point (oMessage.Point) and then start the "place note" tool and populate the word processor with the value of that point. My issue is that is only giving me the value after the decimal of that point. It is ignoring the data that I need. For instance, if the value is 66927.1878173258 (from the expression watch), it is only pasting 1878173258. I need the full value and only 2 decimal places. I am currently only calling a single variable but eventually it will be all 3.

How do I resolve this issue? Here is the code:

Sub PlaceCoordNoteDEV()
    Dim startPoint As Point3d
    Dim oView As View
    Dim pt1 As Point3d, pt2 As String
    Dim point As Point3d
    Dim lngTemp As Long
    Dim oMessage As CadInputMessage
    Dim pt1X As Double
       
On Error GoTo cleanup

Do While True

' Set element template and place cell
    CadInputQueue.SendKeyin "template active general\annotation\text\Text wLeader T10"
    CadInputQueue.SendKeyin "ac=Location Marker"

'Show messages
    ShowPrompt "Place ID Point"
    ShowMessage "Select ID Point in screen"
    'CadInputQueue.SendKeyin "set item toolsettings celltruescaletoggle=1"

' Commands below will use the placement point above be recorded and use
    Set oMessage = CadInputQueue.GetInput(msdCadInputTypeDataPoint, msdCadInputTypeReset)
    If oMessage.InputType = msdCadInputTypeDataPoint Then
        CadInputQueue.SendDataPoint oMessage.point
        pt1 = oMessage.point
        pt1X = oMessage.point.X

        pt2 = CDbl(pt1X)
  
    'Get View
        Set oView = oMessage.View
   
    With CadInputQueue

        .SendDataPoint pt1, oView
        .SendKeyin "choose none"
        .SendKeyin "place note"

        .SendMessageToApplication "WORDPROC", "1 PasteTextInEditor 23" + pt2
        .SendDataPoint pt1, oView

        'Show Messages
            ShowPrompt "Select next point for Note placement"
            ShowMessage "Select next point for Note placement"

        Set oMessage = CadInputQueue.GetInput(msdCadInputTypeDataPoint, msdCadInputTypeReset)
        If oMessage.InputType = msdCadInputTypeDataPoint Then
            CadInputQueue.SendDataPoint oMessage.point

        End If
       
    End With

ElseIf oMessage.InputType = msdCadInputTypeReset Then
    GoTo cleanup
End If

Loop

cleanup:

CadInputQueue.SendKeyin "choose none"
CadInputQueue.SendKeyin "reset"
ShowPrompt ""
ShowMessage "Macro Exited"


End Sub

[CONNECT C++] ModelInfo.GetSolidExtent ()

$
0
0

ModelInfo.GetSolidExtent () returns a double, described as an upper bound that limits the extents of any single solid such that it can be modeled to a fixed precision.

While that's pretty clear, how is it applied relative to the origin of a DGN model?  Can we simply imagine a cube, whose sides measure extent, centred on the DGN model's origin?  Is it affected by global origin?

[CONNECT C#] How to toggle AccuSnap programmatically?

$
0
0

I have tried to set Bentley.DgnPlatformNET.AccuSnap.SnapEnabled as true/false but it doesn't work.

Here is the code sample:

        public static void SetNearestSnap()
        {
            Bentley.MstnPlatformNET.Settings.SnapMode = Bentley.DgnPlatformNET.SnapMode.Nearest;
            Bentley.DgnPlatformNET.AccuSnap.SnapEnabled = true;
            //MessageBox.Show("AccuSnap = " + Bentley.Internal.MstnPlatformNET.SessionSymbols.IsAccuSnapEnabled());
        }

Microstation drawing in different views

$
0
0

So I am drawing in 3d with 4 different views, top, front, iso, right. I am trying to draw an arc on my right view which is view 4.... using two cadinputqueue.senddatapoint point, 4

I am not getting consistent result. Half of the time my arc is showing as a straight line on my right view when i want it to be an arced line in that view. Any tips for drawing in multiple views?

I am using MIcrostation V8i and have a decent amount of vba experience especially with microstation.

'turning all of the views except for view i want off

CadInputQueue.SendCommand "VIEW OFF 1"
CadInputQueue.SendCommand "VIEW OFF 2"
CadInputQueue.SendCommand "VIEW OFF 3"
CadInputQueue.SendCommand "VIEW ON 4"

'select view 4 as active window

ActiveDesignFile.Views(4).Select

'draw point with viewfinder as 4

cadinputqueue.senddatapoint point, 4

Help with code

$
0
0

I have the following code assigned to a function key in order to open and close various windows:

VI ON=2;VI ON=3;VI ON=4 (opens windows 1-4)

VI OF=2;VI OF=3;VI OF=4;VI OF=5;VI OF=6;VI OF=7;VI OF=8 (closes all but window 1)

How can I add a command to the first code to ARRANGE the windows when they all open and consequently MAXIMIZE window 1 when they all close in code 2?

[CONNECT C#] How to get currrent cursor position?

$
0
0

I need to dynamically "highlight" part of some element depending on cursor position (without click). How can I get cursor position while my tool is active?


Do I need a way to directly open .cel and add it to the model without attaching CellLibrary?

$
0
0

Dear teachers, I know one way to add the existing .cel to the current model, using the following methods:


1 call AttachCellLibrary method to connect to the unit library where your unit is;
2 call CreateCellElement2 create unit;
3 Call the ActiveModelReference.AddElement method to add the created cell to the model


Do I need a way to directly open .cel and add it to the model without attaching CellLibrary?

[CONNECT]: ProviderID

$
0
0

How can I determine the ProjectWise Provider ID (in V8i refFile->file_id.providerID)?

Tom

[CONNECT C++] ISelectionEvents::_OnSelectionEvent

$
0
0

ISelectionEvents::_OnSelectionEvent has a boolean return value.  The MicroStationAPI help says: returns true to stop.  True to stop what?

VBA - Saved Views from attachment

$
0
0

Hi,

I am helping a colleague to create a VBA  where he can choose a view name from a attachment in a ComboBox (VBA scans and finds the view names from attachment).

It also turn ON/OFF attachments with the same name as the view name = save time during coordination meetings. This part work fine for me, but I have trouble with activating the view from the attachment.

When I have the name from the combobox I would like to use that string to activate the view that is is included in the attachment.

I found this part below and got it to work correctly with the views in the active designfile. But how do I activate views from an attachment (or lower nesting attachments?)

Dim oViewName As String

Dim eleSV As SavedViewElement            

oViewName = UserForm1.ComboBox1.Value

Set eleSV = ActiveDesignFile.FindSavedView(oViewName)          'Works for names in ActiveDesignfile, but not attachments
ActiveDesignFile.Views(1).ApplySavedViewElement eleSV             'How do I fins and apply saved view from attachments instead?

I want to find "FindSavedView" & ApplySavedViewElement" for attachment objects.

Thanks for help!

VB.NET for Microstation CONNECT Ediction

$
0
0

Hello everybody
I'm trying to convert a VBA application into a VB.Net .exe.

I'm using "Visual studio 2017" to create an .exe file to operate with Microstation Connect ediction 10.05.00.40.

In visula studio I have create a Windows Userform with, at the moment, one button.

I would like that, by clicking the button, I can select an element in the microstation file that I have already open.

Than I would like to use this element as a reference to positioning same cells.

this is the code that I have use in the Useform

Option Explicit On
Imports Bentley.Interop.MicroStationDGN
Imports BCOM = Bentley.Interop.MicroStationDGN
Imports MicroStationDGN

Public Class frmSelectLine
    Public Tradians As Double
    ' ---------------------------------------------------------------------
    Private Const MODULE_NAME As String = "frmSelectLine"' ---------------------------------------------------------------------
    Private m_oLine As Element
    Private m_dblData()
    Private m_strPointCell As String' ---------------------------------------------------------------------
    Public Property line As Element
        Get
            Return m_oLine
        End Get
        Set(ByVal oLine As Element)
            m_oLine = oLine
        End Set
    End Property' ---------------------------------------------------------------------
    Private Sub cmdPickLine_Click(sender As Object, e As EventArgs) Handles cmdPickLine.Click
        Dim MApp As MicroStationDGN.Application
        MApp = New MicroStationDGN.Application
        txtLength.Text = "0.0"'EraseMarker
        Dim oLineLocator As ClsLineFinder
        oLineLocator = New ClsLineFinder
        oLineLocator.Parent = Me
        MApp.CommandState.StartLocate(oLineLocator)
    End Sub
End Class

this is the code in the MainModule:

Option Explicit On

Imports Bentley.Interop.MicroStationDGN
Imports BCOM = Bentley.Interop.MicroStationDGN
Imports MicroStationDGN

Module modMain

    Public lastrow As Double
    Public warningrow As Long
    ' ---------------------------------------------------------------------
    Private Const MODULE_NAME As String = "modMain"' ---------------------------------------------------------------------
    Public Function ElementSupportsPointAtDistance(ByVal oElement As MicroStationDGN.Element) As Boolean
        Select Case oElement.Type
            Case MicroStationDGN.MsdElementType.msdElementTypeLine, MicroStationDGN.MsdElementType.msdElementTypeLineString
                ElementSupportsPointAtDistance = True
            Case MicroStationDGN.MsdElementType.msdElementTypeComplexString
                ElementSupportsPointAtDistance = True
            Case MicroStationDGN.MsdElementType.msdElementTypeArc
                ElementSupportsPointAtDistance = True
            Case MicroStationDGN.MsdElementType.msdElementTypeBsplineCurve
                ElementSupportsPointAtDistance = True
            Case Else
                ElementSupportsPointAtDistance = False
        End Select
    End Function' ---------------------------------------------------------------------'   MarkElementStart' ---------------------------------------------------------------------
    Public Sub MarkElementStart(ByVal oElement As Element, ByVal radius As Double) ', ByVal oTransients As TransientElementContainer
        Dim MApp As New MicroStationDGN.Application()
        Dim valid As Boolean
        valid = True
        Dim StartPoint As Point3d
        Select Case oElement.Type
            Case MicroStationDGN.MsdElementType.msdElementTypeLine, MicroStationDGN.MsdElementType.msdElementTypeLineString
                StartPoint = oElement.AsLineElement.StartPoint
            Case MicroStationDGN.MsdElementType.msdElementTypeComplexString
                StartPoint = oElement.AsComplexStringElement.StartPoint
            Case MicroStationDGN.MsdElementType.msdElementTypeArc
                StartPoint = oElement.AsArcElement.StartPoint
            Case MicroStationDGN.MsdElementType.msdElementTypeBsplineCurve
                StartPoint = oElement.AsBsplineCurveElement.StartPoint
            Case Else
                valid = False
        End Select

        If valid Then

            If ID_oCircle.Low > 0 Then
                oCircle = MApp.ActiveModelReference.GetElementByID(ID_oCircle)
                MApp.ActiveModelReference.RemoveElement(oCircle)
            End If

            oCircle = MApp.CreateEllipseElement2(oElement, StartPoint, radius, radius, MApp.Matrix3dIdentity, MicroStationDGN.MsdFillMode.msdFillModeUseActive)
            MApp.ActiveModelReference.AddElement(oCircle)
            ID_oCircle = oCircle.ID

        End If
    End Sub

End Module

this is the code in the class that I crate to select the line:

Option Explicit On
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports Bentley.MicroStation.Winforms
Imports Bentley.MicroStation.InteropServices
Imports Bentley.Interop.MicroStationDGN'Imports MSForms
Imports BCOM = Bentley.Interop.MicroStationDGN
Imports MicroStationDGN'Public Interface ILocateCommandEvents'Property Parent'Sub Class_Initialize()'Sub GetElementParams()'Sub ILocateCommandEvents_Accept()'Sub GetElementParams()'Sub ILocateCommandEvents_Cleanup()'End Interface

Public Class ClsLineFinder

    Implements ILocateCommandEvents
    Public MApp = New MicroStationDGN.Application()
    ' ---------------------------------------------------------------------
    Private Const MODULE_NAME As String = "ClsLineFinder"' ---------------------------------------------------------------------
    Private m_oParent As frmSelectLine' ---------------------------------------------------------------------
    Public Property Parent As frmSelectLine
        Get
            Return m_oParent
        End Get
        Set(ByVal oParent As frmSelectLine)
            m_oParent = oParent
        End Set
    End Property' ---------------------------------------------------------------------
    Private Sub Class_Initialize()
    End Sub' ---------------------------------------------------------------------
    Public Sub _Accept(ByVal oElement As MicroStationDGN._Element, ByRef Point As Point3d, ByVal View As MicroStationDGN.View) Implements MicroStationDGN.ILocateCommandEvents.Accept
        Debug.Print("Accepted element type" & CStr(oElement.Type))
        Dim StartPoint As Point3d
        Dim length As Double
        length = 0#
        GetElementParams(length, StartPoint, oElement)
        Debug.Assert(Not m_oParent Is Nothing)
        m_oParent.txtLength.Text = Format(length, "0.00")
        m_oParent.line = oElement
    End Sub' ---------------------------------------------------------------------
    Private Sub GetElementParams(ByRef length As Double, ByRef StartPoint As Point3d, ByVal oElement As Element)
        Select Case oElement.Type
            Case MsdElementType.msdElementTypeArc
                length = oElement.AsArcElement.Length
                StartPoint = oElement.AsArcElement.StartPoint
            Case MsdElementType.msdElementTypeLine, MsdElementType.msdElementTypeLineString
                length = oElement.AsLineElement.Length
                StartPoint = oElement.AsLineElement.StartPoint
            Case MsdElementType.msdElementTypeBsplineCurve
                length = oElement.AsBsplineCurveElement.Length
                StartPoint = oElement.AsBsplineCurveElement.StartPoint
            Case MsdElementType.msdElementTypeComplexString
                length = oElement.AsComplexStringElement.Length
                StartPoint = oElement.AsComplexStringElement.StartPoint
        End Select
    End Sub' ---------------------------------------------------------------------
    Private Sub _Cleanup() Implements MicroStationDGN.ILocateCommandEvents.Cleanup

    End Sub
    ' ---------------------------------------------------------------------
    Private Sub _Dynamics(point As Point3d, ByVal oView As MicroStationDGN.View, ByVal drawMode As MsdDrawingMode) 'Implements MicroStationDGN.ILocateCommandEvents.Dynamics

    End Sub
    ' ---------------------------------------------------------------------
    Private Sub _LocateFailed() Implements MicroStationDGN.ILocateCommandEvents.LocateFailed
        MApp.ShowStatus("Element not Suitable")
    End Sub' ---------------------------------------------------------------------
    Private Sub _LocateFilter(ByVal oElement As Element, point As Point3d, accepted As Boolean) 'Implements ILocateCommandEvents._LocateFilter
        accepted = ElementSupportsPointAtDistance(oElement)
    End Sub' ---------------------------------------------------------------------
    Private Sub _LocateReset() Implements ILocateCommandEvents.LocateReset
    End Sub' ---------------------------------------------------------------------
    Private Sub _Start() Implements MicroStationDGN.ILocateCommandEvents.Start
        MApp.CommandState.CommandName = "Place Points at Distance along Line"
        MApp.ShowCommand(MApp.CommandState.CommandName)
        MApp.ShowPrompt("Pick a line")
        Dim oLocateCriteria As LocateCriteria
        oLocateCriteria = MApp.CommandState.CreateLocateCriteria(False)
        MApp.CommandState.SetLocateCriteria(oLocateCriteria)
    End Sub

    Public Sub LocateFilter(Element As _Element, ByRef Point As Point3d, ByRef Accepted As Boolean) Implements ILocateCommandEvents.LocateFilter

    End Sub

    Public Sub Dynamics(ByRef Point As Point3d, View As MicroStationDGN.View, DrawMode As MsdDrawingMode) Implements ILocateCommandEvents.Dynamics

    End Sub
End Class

this is the error message:

Any help will be very appreciated.
Thank You in advance.

ClipVectorPtr to ClipVectorCP in Connect API 10.07.00.39

$
0
0
Hello together,
I have the problem again with ClipVectorPtr and ClipVectorCP! In the API (10.07.00.37 ) I use, there is no "get()" method on ClipVectorPtr.
Old example:
void foo(void)
{
ClipVectorPtr clip;
if (mdlClip_fromElement(clip, elDescr, false, view) == SUCCESS)
{
if (mdlClip_isElemInside(&bOver, edP, clip.get(), view, true)){…}
}
}

Thank you very much!

Kind regards
Sigi

[V8i or CONNECT] Generate List of Icons in .dgnlib

$
0
0

Is it possible to generate a list of icon resources that are in a .dgnlib? I wish to merge the icons from multiple .dgnlib's into a single file, and I would like to extract out the names of the icons in each .dgnlib prior to merging so I can ensure no duplicate entries.

Bruce


Access Violation with SetLineStyle and trying to retrieve Element by native ref

$
0
0

Hi,  I am getting to grips with programming in CONNECT (Update 9), using a mixture of c++ and c#.

Where possible my preference is to using the DgnPlatformNET and MstnPlatformNET interfaces but for the time being there will be quite a bit of code using the c++ calls.

I am currently having a problem setting LineStyle via the ElementPropertiesSetterPtr.  Setting other properties that way works fine, but setting the lineStyle causes an access violation every time.

To elaborate, the following works fine.
It creates a small diagonal line, initially green solid, through the .NET API.
Then turns it blue dashed, using the c++ calls.

// Use the .NET API to get the model and dgn
DgnPlatformNET.DgnFile activeDgnFile = MstnPlatformNET.Session.Instance.GetActiveDgnFile();
DgnPlatformNET.DgnModel activeModel = MstnPlatformNET.Session.Instance.GetActiveDgnModel();

// Create a short line
GeometryNET.DSegment3d segment = new GeometryNET.DSegment3d(0, 0, 100, 100);
DgnPlatformNET.Elements.Element elem1 = new DgnPlatformNET.Elements.LineElement(activeModel, null, segment);

// Make the line green(2), solid(0) with weight 1, on level 1
SetSymbology(elem1, 2, 1, 0, 1);
DgnPlatformNET.StatusInt status = elem1.AddToModel();

// Grab the native handle so we can use it in c++ calls (inc mdl)
IntPtr elem1HandlePtr = elem1.GetNativeElementRef();
Int64 elem1Handle = elem1HandlePtr.ToInt64();

// Use the c++ calls to make it blue(1) and dashed(3)
MsedSetSymbology(&elem1Handle, 1, 1, 3, 1);



The SetSymbology() method is a c# one, shown below.
The MsedSetSymbology() method is a c++ one 

// c# method
public static void SetSymbology(DgnPlatformNET.Elements.Element elem, uint colour, uint weight, int lineStyleIndex, int level)
{
    using (ElementPropertiesSetter propSetter = new ElementPropertiesSetter())
    {
        propSetter.SetLinestyle(lineStyleIndex, null);
        propSetter.SetColor(colour);
        propSetter.SetLevel(level);
        propSetter.SetWeight(weight);
        propSetter.Apply(elem);
    }
}

// c++ method
void msedSetSymbology (Int64& iHandle, int iColour, int iWeight, int iStyle, int iLevel)
{	
	MSElementDescrP pMsed = (MSElementDescrP)iHandle;

	EditElementHandle eeh(pMsed, false, true);
	
	ElementPropertiesSetterPtr remapper = ElementPropertiesSetter::Create();
		
	remapper->SetLevel((LevelId)iLevel);
    remapper->SetColor(iColour %256);	
    remapper->SetLinestyle(iStyle, NULL);
    remapper->SetWeight(iWeight %32);  
	remapper->Apply(eeh);
	iHandle = (Int64)pMsed;
}

Great.   However, the line has already been created (and is correctly visible) using c++ calls, and we already have its native handle, in the variable iHandle.

So I would expect the following to work:

// Use the c++ calls to make it blue(1) and dashed(3)
MsedSetSymbology(&iHandle, 1, 1, 3, 1);

but unfortunately it causes CONNECT to give an access violation when it tries to Apply().

With a little trial an error, it is the SetLineStyle() that is causing the problem.  If I comment it out, all works as expected, but with it in, it always results in a crash.

Instead, I tried to use the .NET call by retrieving the Element using the iHandle:

// Convert the native pointer to an IntPtr and use it to retrieve the Element
IntPtr elem1HandlePtr = (IntPtr)iHandle;
DgnPlatformNET.Elements.Element elem = DgnPlatformNET.Elements.Element.GetFromElementRef (elem1HandlePtr);

// Make the line green(2), dashed(3) with weight 1, on level 1
SetSymbology(elem1, 2, 1, 3, 1);

but that also causes CONNECT to throw an access violation when attempting to retrieve the element!

So why do neither of these work ?  In particular:

(a) why can I not set the LineStyle through the PropertiesSetter?

(b) why can I not retrieve the Element using its valid native handle?

Any help would be much appreciated.

what apis is used to get the item list and properties on the Item?

$
0
0

Hi,

  I have an i.dgn model and open with Microstations, there are some items in the item explorer,

which apis can i use to get iterate all those items, and what api is used to access the properties on that item?

I am run an MDL application, and need to access those items and properties.

thanks,

Rick

[CONNECT C++] CurveVector and CurveCurve::IntersectionXY()

$
0
0

Not sure I'm doing the properly. I am finding intersections, and want to extract out the intersection point and tangent at that point:

	CurveVectorPtr			curve = CurveVector::Create(segments);	//
	CurveVectorPtr			feature = ICurvePathQuery::ElementToCurveVector(ehFeature);
	CurveVectorPtr			intersectionsA = CurveVector::Create(CurveVector::BOUNDARY_TYPE_None);
	CurveVectorPtr			intersectionsB = CurveVector::Create(CurveVector::BOUNDARY_TYPE_None);
	if (curve.IsValid() && feature.IsValid())
	{
		CurveCurve::IntersectionsXY(*intersectionsA, *intersectionsB, *curve, *feature, nullptr);
		if (intersectionsA.IsValid())
		{
			for each ( ICurvePrimitivePtr	curvePtr in *intersectionsA )
			{
			    CurveLocationDetail			location1;
			    DVec3d						tangentAtPoint;
			    DPoint3d					pnt{ 0 };
			    curvePtr->GetStartPoint(pnt);
			    curvePtr->ClosestPointBounded(pnt, location1);
			    location1.curve->FractionToPoint(location1.fraction, pnt, tangentAtPoint);	// tangent NOT NORMALIZED
			    // now we have the intersect point and tangent at that point
			}
        }
    }

Bruce

[CONNECT C#] Get DgnWorkSet information

$
0
0

Using C# in CONNECT, how do I determine if DgnWorkSet information is applied to a dgnfile and if so, retrieve the data?

VBA TextElement Origin

$
0
0

I have a VBA app that runs perfectly in MicroStation V8i, and now testing it in MicroStation CE Update 9 (v10.9.1.1). I am finding the property Origin of a TextElement is giving strange results. I can assign the same value to origin as it currently has, and the text element moves 700K drawing units away. Here is some example code I wrote to demonstrate this.


Sub TextMove()
    Dim ee As ElementEnumerator
    Dim esc As ElementScanCriteria
    Dim oElement As Element
    Dim oTextElement As TextElement
    Dim pt As Point3d
   
    Set esc = New ElementScanCriteria
    esc.ExcludeNonGraphical
    Set ee = ActiveModelReference.Scan(esc)
    Do While ee.MoveNext
      Set oElement = ee.Current
      If oElement.Type = msdElementTypeText Then
        Set oTextElement = oElement
        pt = oTextElement.Origin
        'here is where I would make changes to pt, removed for clarity
        oTextElement.Origin = pt
        oTextElement.Rewrite
        Set oTextElement = Nothing
      End If
      Set oElement = Nothing
    Loop
    Set ee = Nothing
    Set esc = Nothing
End Sub

The net result, is the text element moves from coordinates of 7,10  to something like -520628,240123
Can anyone explain why?  Looking forward to some enlightening comments.

FWIW, here is the code I am resorting to. Needless to say, I am unhappy to have to change from oTextElement.origin = pt    which works fine in every preceding version of MicroStation.

        vec = Point3dFromXYZ(20, 0, 0)
        Eltrans = Transform3dFromPoint3d(vec)
        oTextElement.Transform Eltrans
        oTextElement.Rewrite

Viewing all 4331 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>