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

[V8i] Rotating a reference file

$
0
0

I'm trying to reference a revision block into some old existing drawings that were originally created rotated 90 degrees.

I know I can change the reference rotation in the reference dialogue box, but that is not acceptable with thousands of files.

I thought this would be an easy keyin for a basic macro but I am unable to find a parameter to set the rotation angle when attaching a reference file.

the command I though I could use is:

RF= [configuration_variable:] [,model_name] [,logical_name] [,description] [,view_name] [,scale] [,nesting] [,ON|OFF]

If there is no parameter in the RF= command maybe someone could tell me how to set parameters for the 

Reference Rotate command?

Thanks in advance!


Specify RGB colour when setting Region fill via SetCExpressionValue?

$
0
0

Hi,

I would like to specify the colour of a region fill using RGB rather then a number from the table?

SetCExpressionValue "tcb->symbology.color", 4, "MGDSHOOK"

OpenRoads Designer V10.07.03.18

Inserting a left click through VBA

$
0
0

Hi you all,

I'm trying to learn a bit of programming in microstation, but I can't seem to figure this out:

I'm reworking a class I use to place cells in a drawing. Basicly the class gets a cell number from a userform, and looks up the cell, and it's "hanging" on the mousepointer. Then after a click the cell is placed in the spot in the drawing.

But now I'm rewriting the code to place multiple cells next to each other, and I have the code working to the point that when I provide the clicks manualy, a cell gets placed, the next one moves a to the left, and when I click again at the right time in the vba the next one gets placed. I've been searching the web for days now but I can't get a working solution. The code is inserted below, the sub "LeftMouseClick()" just isn't working . the out commented  lines are all thing I already tried

.

Option Explicit

Dim CellName As String
Public Breedte As Integer


Implements IPrimitiveCommandEvents
Public Sub SetCellName(Cell As String)
    
    CellName = Cell
    
End Sub
Private Sub IPrimitiveCommandEvents_Cleanup()

End Sub

Private Sub IPrimitiveCommandEvents_DataPoint(point As Point3d, ByVal View As View)

    Dim atPoint As Point3d

    atPoint.x = point.x + Breedte
    atPoint.y = point.y

    'draw the cell
    Dim oCellEl As CellElement
    Set oCellEl = CreateCellElement3(CellName, atPoint, True)
    ActiveModelReference.AddElement oCellEl
    oCellEl.Redraw

End Sub

Private Sub IPrimitiveCommandEvents_Dynamics(point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)
    'method called to show dynamics
    Dim atPoint As Point3d
    atPoint.x = point.x + Breedte
    atPoint.y = point.y' display a temporary cell
    Dim oCellEl As CellElement
    Set oCellEl = CreateCellElement3(CellName, atPoint, True)
    oCellEl.Redraw DrawMode

End Sub

Private Sub IPrimitiveCommandEvents_Keyin(ByVal KeyIn As String)
End Sub

Private Sub IPrimitiveCommandEvents_Reset()
    ' method called when the reset event occurs
    CommandState.StartDefaultCommand
    frmEltakoComp.Show
End Sub

Private Sub IPrimitiveCommandEvents_Start()
    'method called at the start of the command'Dim point As Point3d
    Dim c As Integer
    c = 0
    ShowCommand "Place Cell"
    CommandState.EnableAccuSnap
    CommandState.StartDynamics
    frmEltakoComp.Hide
    LeftMouseClick
End Sub

Private Sub LeftMouseClick()

'Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)'Dim inputQueue As CadInputQueue'Dim pointx As Point3d' Set inputQueue = CadInputQueue'  Set inputMessage = inputQueue.GetInput(msdCadInputTypeDataPoint, msdCadInputTypeAny)'    Do'        Select Case inputMessage.InputType'            Case msdCadInputTypeDataPoint'            Case msdCadInputTypeReset'                Exit Sub'        End Select'   Loop'CadInputQueue.SendCommand LeftMouseClick True

CadInputQueue.SendDataPoint Point3dZero
'   End Sub'Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)''    Public Const MOUSEEVENTF_LEFTDOWN = &H2'    Public Const MOUSEEVENTF_LEFTUP = &H4'    End Sub'''Public Sub LeftClick()''''    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0'   mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

And to be complete a piece of the sub that send the cellnumbers to the class:

Option Explicit


Dim Component(50) As String
Dim f
Dim Bestand As String
Dim i As Integer
Dim Cell As String
Dim AantalComp As String
Dim Widht As Integer

  
Sub CellNameProcess()
    
    Dim j As Integer
    Dim CellName As String
    Dim PlaceCell As clsPlaceCell
    Set PlaceCell = New clsPlaceCell
    Dim WidhtCalc As Integer
    
    WidhtCalc = 0
    
    For j = 0 To AantalBox1.Value
        PlaceCell.SetCellName (Cell)
        PlaceCell.Breedte = WidhtCalc
        WidhtCalc = WidhtCalc + Widht
    
        CommandState.StartPrimitive PlaceCell
    Next j
    
    AantalBox1.Value = 1

End Sub

Private Sub lblComponenten_Click()

End Sub

Private Sub Label6076_Click() 'used
Cell = "92.7000.230"
Widht = 18
Call CellNameProcess
End Sub
Any help would be greatley appreciated

Is it possible to obtain the sheet size (height and width of a sheet model) in order to use these in a constraint variable?

$
0
0

I'd like to develop a parametric drawing border cell that automatically changes size using 2D constraints and dimension constraints. I just started working with constraints and parametric cells. Is it perhaps necessary to first define item types that may use an EC Expression (perhaps something like "this.sheetDef() ??? ). Any suggestion is welcome including a perhaps totally different approach.

Help me about filtering level scan element issue in mdl v8!

$
0
0
I'm programming c on mdl microstation v8.5. I don't understand issue about scanning element with filtering level: scanList.levmask [0], scanList.levmask [1], scanList.levmask [2], scanList.levmask [3]. I want to filter level 10,23,32,can you explain it for me. Thanks

New embedded Python for microstation v8i product

$
0
0

Is anyone interested in participating as an alpha test site for a new embedded python product for microstation v8i?

just reply to this and we will contact you with more information

Allan

[Connect CPP] Replacement for mdlPattern_linear

$
0
0

Hi all

I would like to know if there is a replacement for mdlPattern_linear in the CPP API. 

When working with shapes you can do something like:

ShapeHandler::GetInstance().AddPattern(

but I would like to add some linear pattern to a line / linestring.

Any ideas ?

TIA

Regards Evan

[CONNECT C++] Using a WhereCriterion to filter out schemas

$
0
0

I'm looking at elements that have XAttributes on them. I can create a ECQuery to find instances on an element. When I look at what is found, it is not uncommon to find multiple Classes on an element. For example:

[DgnElementSchema:LineElement]
[DgnCustomItemTypes_SRSFeature:Air__x0020__Tunnel]

I'm interested in the 'SRSFeature' XAttributes. Is it possible to (and how would you) set up a WhereCriterion to restrict the ECQuery to return only ones from the 'DgnCustomItemTypes_SRSFeature' schema? USe CreateStringFilter()?

Bruce


[CONNECT C# .NET] Change "Sheet Index Name"

$
0
0

Is there a way via the API to change the Sheet Index Name?

[CONNECT .NET] How do I redraw a view?

$
0
0

With CONNECT SDK v10.13, I've adjusted a view's geometry like this using the DgnPlatformNet API...

viewInfo.SetGeometry(origin, elementDelta, rotation);
viewGroup.SetViewInformation(viewInfo, nView);
viewGroup.SynchViewDisplay (nView, false, true, false);

That appears to work OK. However, I have manually to redraw the view to see the change.   That is, I have to click the paintbrush icon in the UI to redraw the view.

What should I do programmatically to refresh a view after ViewGroup.SynchViewDisplay?

How to run basic macro batch process

$
0
0

I have just know a feature basic macro i have recorded a macro for dropping cells and i tried to use that macro thorugh batch process but its not working anyone know how to use basic marco with batch process any answer would be appreciated thanks in advance

Finding Activevbproject.filename

$
0
0

I read the post between Caddcop andJohn, and followed the link, but it failed ? 

Not sure of how old the link is but I did want to read the information. I checked to see if I could just message Caddcop, but name did not show up.

I was hoping someone could furnish a link that might still be good

[CONNECT VBA] DatabaseExamples project missing References

$
0
0

I was browsing the delivered VBA examples in CONNECT.  I opened the DatabaseExamples project and looked at the VBA references to other COM DLLs...

ADO missing ref

The project references a missing Microsoft ADO DLL.

Read dgn information from vindows app using C#

$
0
0

Hi,

I need read data from dgn file, for example list of levels, from windows application.

The simple workflow, user start windows app, browse to dgn and get list of levels.

The microstation is installed in the user computer, but this function will be started not in microstation.

I need start process, read file and get information.

Thank you.

Best regards

Darius

I need help with my VBA macro

$
0
0

I am trying to fix a leader line macro that was built 5 years ago in microstation, I put the code below and some images, can someone please help me?


'*************************************************************************
'**
'** LEADER.UCM
'**
'** Procedure to draw both detail and index leader lines
'** with either index numbers or detail letter boxes.
'** also made graphic group.
'**
'** AUTHOR:  L.G. YEATES
'** -------
'**
'** MODIFIED:
'** ---------
'** july 1989 position the index number in line
'**       with the arrow head and leader line
'** sept 1989 corrected problem with the index number
'**       for 2 digit numbers and larger with the
'**       starting position of the line
'** sept 1989 corrected to allow upper and lower
'**       case inputs by users
'** dec 1989  corrected to allow leader line to be
'**       put in at active angle
'** jan 1990  corrected problem with detail letter,
'**       so it is put in font 42
'**
'**
'** oct 1990  modified for MicroStation use. (LGY)
'** 02-21-91  Changed color. (LGY)
'** 03-20-91  Made Graphic Group (LGY)
'** 10-03-91  Made "I"ndex the default.
'** 05-08-92  Fixed bugs with default selection "I".
'** 07-17-92  Changed cell library attachment from
'**      "tut1" to "tut5".
'** 05-28-93  added saving active symbology.
'** 07-22-93  added turning off axis lock during execution
'**       of this UCM if turned on.
'** 01-13-94  changed "detail" option for selection
'**       of either Clear/Filled Letter.
'**
'*************************************************************************
Option Explicit
Dim saveActiveTextJustification As Integer
Dim saveActiveTextNodeJustification As Integer
Dim saveActiveAngle As Double
Dim saveActiveLevel As Level
Dim saveActiveFont As Font
Dim saveActiveCharHeight As Integer
Dim SaveActiveCharWidth As Integer
Dim saveActiveLineStyle As LineStyle
Dim saveActiveColor As Long
Dim saveActiveWeight As Integer

Dim myCIQ As CadInputQueue
Dim myCIM As CadInputMessage
Dim response As String


Sub Main()
   SetUp
   LeaderType
End Sub

Sub SetUp()


    CadInputQueue.SendCommand "null"
    CadInputQueue.SendKeyin "noecho"
   
    CommandState.ErrorMessagesEnabled = False
 
    'SET OUTFLG = OUTFLG ! 8     ;allow menu selection

  ' Save Active Settings
 
    saveActiveTextJustification = ActiveSettings.TextStyle.Justification
    saveActiveTextNodeJustification = ActiveSettings.TextStyle.NodeJustification
    saveActiveAngle = ActiveSettings.Angle
    Set saveActiveLevel = ActiveSettings.Level
    Set saveActiveFont = ActiveSettings.Font
    saveActiveCharHeight = ActiveSettings.TextStyle.Height
    SaveActiveCharWidth = ActiveSettings.TextStyle.Width
    Set saveActiveLineStyle = ActiveSettings.LineStyle  ' save active symbology
    saveActiveColor = ActiveSettings.Color              ' save active symbology
    saveActiveWeight = ActiveSettings.LineWeight        ' save active symbology

'   Turn off fast font (bit 1)
'   Turn on slow font (bit 2)

    'Does not work.

'   Turn off text node lock (bit 2)

    ActiveSettings.TextNodeLockEnabled = False
  
   ' Not recommended by Microststation, but this was in original UCM
   ' and it allows illustrator to ignore the prompt to enter data
   ' and place a datapoint instead.
    CadInputQueue.SendKeyin "set parse off"
 
    ' Turn off axis lock  SET FBFDCN = FBFDCN & 65531

    CadInputQueue.SendKeyin "lock axis off"
   
  
'   Setup parameters for user command

    CadInputQueue.SendKeyin "TS=1"          'active terminator scale
    CadInputQueue.SendKeyin "AA=0"          'active angle"
    CadInputQueue.SendKeyin "AS=1"          'active scale"

'   Start user command prompting

   ' LEADER:
   '
  
  
End Sub

Sub LeaderType()

Dim index As Boolean
Dim response As String

response = ""
index = True

  Do
   
   
 
    ShowStatus ""
    ShowError ""
    ShowCommand "LEADER LINE User Command (Graphic Group)"
  
'   TOP:
    ShowPrompt "Select Type I)ndex or D)etail:  [I]"
   
    'GET K,INPUT,R,EXITUC,M,SLI,P,AGAIN
   
    Set myCIQ = CadInputQueue
    
    Set myCIM = myCIQ.GetInput(msdCadInputTypeKeyin, msdCadInputTypeReset, _
                              msdCadInputTypeCommand, msdCadInputTypeDataPoint)
                        
    Select Case myCIM.InputType
   
        Case msdCadInputTypeReset
            ResetVals
            Exit Sub
    
        Case msdCadInputTypeDataPoint
           
             If (response = "D") Or (response = "d") Then
               index = False
             Else
               index = True
             End If
           
            CreateLineWithTerminator (index)
       
        Case msdCadInputTypeCommand
            ResetVals
            Exit Sub
           
        Case msdCadInputTypeKeyin
       
           response = myCIM.Keyin
   
           'Set n10 = 3
           'tst c10 eq 'UC=',SLI
  
         
            If (response = "D") Or (response = "d") Then
               index = False
            ElseIf (response = "I") Or (response = "i") Then
               index = True
            Else
               MsgBox "Invalid Entry, Please try again."
               Exit Do
            End If
           
            CreateLineWithTerminator (index)
           
             
    End Select 'I)ndex or D)etail
             
        
 Loop
 

 
 End Sub
 
 
 Sub CreateLineWithTerminator(index As Boolean)
 
 Do
 
 SetUp
 

 Dim myCIQ As CadInputQueue
 Dim myCIM As CadInputMessage
 
 Dim clearOrFilled As String
 Dim detailLetter As String
 
 Dim arrowPoint As Point3d
 Dim termPoint As Point3d
 Dim myLine As LineElement
 
 
CadInputQueue.SendKeyin "TS=1"          'active terminator scale
 
 ShowStatus ""
 ShowError ""
 ShowPrompt ""
 
 CadInputQueue.SendKeyin "WT=0"          'set active weight
 CadInputQueue.SendKeyin "CO=1"          'set active color
 
 If index = False Then
     CadInputQueue.SendKeyin "LT=BARRO" 'line terminator assignment
     ShowCommand "DETAIL ARROW User Command (Graphic Group)"
 Else
     CadInputQueue.SendKeyin "LT=LARRO"
     ShowCommand "INDEX ARROW User Command (Graphic Group)"
 End If
 
 
 CadInputQueue.SendKeyin "rc=tut5.cel"

 CadInputQueue.SendCommand "Place Line"

 ShowPrompt "Enter Arrowhead Point"


 Set myCIQ = CadInputQueue

 Set myCIM = myCIQ.GetInput(msdCadInputTypeDataPoint, msdCadInputTypeReset, _
                            msdCadInputTypeKeyin, msdCadInputTypeCommand)
                 
    'GET P,FIRST,R,LEADER,M,SLI,K,SLI
             
    Select Case myCIM.InputType
           
        Case msdCadInputTypeReset 'Re-enter "D" or "I"
            Exit Sub
           
        Case msdCadInputTypeKeyin
            ResetVals
            Exit Sub
       
        Case msdCadInputTypeCommand
            ResetVals
            Exit Sub
   
        Case msdCadInputTypeDataPoint
              
            CadInputQueue.SendCommand "Place Line"
       
            arrowPoint = myCIM.point
        
            CadInputQueue.SendDataPoint arrowPoint

            ShowPrompt "Enter Terminator Point"
            ShowError ""
           
       
           
     End Select 'Enter Terminator Point
       
        'GET P,PLACE,R,LEADER,M,SLI,K,SLI
               
     Set myCIM = myCIQ.GetInput(msdCadInputTypeDataPoint, _
                            msdCadInputTypeReset, msdCadInputTypeKeyin, msdCadInputTypeCommand)
                           
     Select Case myCIM.InputType
                           
         Case msdCadInputTypeReset
             CadInputQueue.SendCommand "null"
             ShowPrompt ""
             Exit Sub 'Re-enter "D" or "I"
  
         Case msdCadInputTypeKeyin
             CadInputQueue.SendCommand "null"
             ShowPrompt ""
             ResetVals
    
         Case msdCadInputTypeCommand
             CadInputQueue.SendCommand "null"
             ShowPrompt ""
             ResetVals
 
         Case msdCadInputTypeDataPoint
           
             ShowError ""
             termPoint = myCIM.point
   
             CadInputQueue.SendKeyin "lv=10"
             CadInputQueue.SendKeyin "CO=1"
         
             Set myLine = CreateLineElement2(Nothing, arrowPoint, termPoint)
             ActiveModelReference.AddElement myLine

             CadInputQueue.SendCommand "Place Terminator"
             CadInputQueue.SendDataPoint arrowPoint
             CadInputQueue.SendDataPoint arrowPoint
            
   
             CadInputQueue.SendCommand "null"
      
          
             
     End Select 'Enter Arrowhead Point
    
      Dim ang As Double
      ang = GetAngleOfLineBetweenTwoPoints(termPoint, arrowPoint)
 
  
      If index = False Then 'Detail
         ProcessDetail termPoint, arrowPoint, ang
      Else
         ProcessIndex termPoint, arrowPoint, ang
      End If
     
     
Loop
     
   End Sub
       
   Sub ProcessIndex(termPoint As Point3d, arrowPoint As Point3d, ang As Double)
  
   Dim indexNumber As String
   
          ShowPrompt "Enter Index Nunber"
               'GET K,LLETTER,R,INDEX,M,SLI
           
                Set myCIM = myCIQ.GetInput(msdCadInputTypeDataPoint, _
                                   msdCadInputTypeReset, msdCadInputTypeKeyin, msdCadInputTypeCommand)
                                
                Select Case myCIM.InputType
                  Case msdCadInputTypeKeyin
                    indexNumber = myCIM.Keyin
                
                
                 End Select 'Enter Index Number
   
 
    '  Calculate the position for placement
    '   of the index number
   
     Dim newLocation As Point3d
    
     newLocation = GetNewLocation(termPoint, arrowPoint, ang)
    

         
    'PTEXT:
   
    '  define font and character height for index number
   
        'CadInputQueue.SendKeyin "active txj cc"    'center-center text justification
        'CadInputQueue.SendKeyin "active tnj cc"     'active text node justification
        CadInputQueue.SendKeyin "ft=2"
        CadInputQueue.SendKeyin "tx=.10"
        CadInputQueue.SendKeyin "lv=48"
      
       
        Dim oEL As TextElement
        Dim textOrigin As Point3d
        Dim textNote As String
        textNote = indexNumber
        'Set oEL = CreateTextElement1(Nothing, textNote, textOrigin, Matrix3dIdentity)
        Set oEL = CreateTextElement1(Nothing, textNote, newLocation, Matrix3dIdentity)
        oEL.TextStyle.Justification = msdTextJustificationCenterCenter
        oEL.TextStyle.Color = 5
      
        ActiveModelReference.AddElement oEL

        CadInputQueue.SendCommand "ADD TO GRAPHIC GROUP"
        CadInputQueue.SendDataPoint arrowPoint
        CadInputQueue.SendDataPoint newLocation
        CadInputQueue.SendDataPoint newLocation
       
      
        CadInputQueue.SendCommand "null"
      
        'do another
End Sub
               
Sub ProcessDetail(termPoint As Point3d, arrowPoint As Point3d, ang As Double)

    Const halfDeltaX = 0.12
    Const halfDeltaY = 0.16
    Const deltaX = 0.24
    Const deltaY = 0.32

    Dim detailType As String
    Dim clear As Boolean
    Dim detailLetter As String
   
    clear = True

    ShowPrompt "Select type C)lear or F)illed:  [C]"
        
    'GET K,TYPED,R,DETAIL,M,SLI,P,AGAIN1
   
    Set myCIQ = CadInputQueue
   
    Set myCIM = myCIQ.GetInput(msdCadInputTypeDataPoint, _
                           msdCadInputTypeReset, msdCadInputTypeKeyin, msdCadInputTypeCommand)
                  
    Select Case myCIM.InputType
        
        Case msdCadInputTypeReset 'ProcessDetail
           
     
   
        Case msdCadInputTypeDataPoint ' Test for C)lear or F)illed.
            
    
        Case msdCadInputTypeCommand 'Exit Program
            
            ResetVals
            Exit Sub
              
        Case msdCadInputTypeKeyin
                  
            'msg 'er'
                 
            detailType = myCIM.Keyin

            'tst c10 eq 'UC=',SLI
                            
            If (detailType = "F") Or (detailType = "f") Then
                clear = False
            ElseIf (detailType = "C") Or (detailType = "c") Then
                clear = True
            Else
               MsgBox ("Invalid Entry, Please try again")
               Exit Sub
            End If
            
    End Select 'C)lear or F)illed
 
     
    ShowPrompt "Enter Detail Letter"
    'GET K,DLETTER,R,TYPED,M,SLI
                  
    Set myCIM = myCIQ.GetInput(msdCadInputTypeDataPoint, _
                               msdCadInputTypeReset, msdCadInputTypeKeyin, msdCadInputTypeCommand)
                                       
        Select Case myCIM.InputType
       
            Case msdCadInputTypeReset
           
            Case msdCadInputTypeCommand
           
            Case msdCadInputTypeDataPoint
            
            Case msdCadInputTypeKeyin
                
                detailLetter = myCIM.Keyin
                       
                       
        End Select 'Enter Detail Letter
        
        
       'Assign the deltas and half deltas for placement
       ' of the detail box

   
'   DETAIL LETTER TEST
'   Test for angle of the arrow line
'   then add the appropriate deltas
'   for the CELL placement.

    'TST A8 GT 360,EXITUC
   
    Dim LTDegrees As Double
    Dim halfDelta As Double
    Dim completeLetter As String
   
   
    If (ang > 360) Then
      Exit Sub
    ElseIf (ang <= 45) Then                 'Left
      LTDegrees = termPoint.X
      halfDelta = termPoint.Y - halfDeltaY
    ElseIf (ang <= 135) Then                'Bottom
     LTDegrees = termPoint.X - halfDeltaX
      halfDelta = termPoint.Y
    ElseIf (ang <= 225) Then                'Right
      LTDegrees = termPoint.X - deltaX
      halfDelta = termPoint.Y - halfDeltaY
    ElseIf (ang <= 315) Then                'Topp
      LTDegrees = termPoint.X - halfDeltaX
      halfDelta = termPoint.Y - deltaY
    End If
    
    CadInputQueue.SendKeyin "RC=tut10.cel"  'attach cell library
    'CadInputQueue.SendKeyin "co = 1"
 
     If clear = True Then
       completeLetter = "det"
     Else 'filled
       completeLetter = "dltr"
     End If
    
    
     completeLetter = completeLetter + detailLetter
     completeLetter = "ac=" + completeLetter
     CadInputQueue.SendKeyin completeLetter
     Dim letterPoint As Point3d
     letterPoint.X = LTDegrees
     letterPoint.Y = halfDelta
     CadInputQueue.SendDataPoint letterPoint

    ' CadInputQueue.SendCommand "GROUP ADD"
     'CadInputQueue.SendDataPoint arrowPoint
     'CadInputQueue.SendDataPoint letterPoint
    ' CadInputQueue.SendDataPoint letterPoint
   
     CadInputQueue.SendCommand "null"
    
    
End Sub


   
' Determines the angle of a straight line drawn between point one and two.
' The number returned, which is a float in degrees, tells us how much we have
'  to rotate a horizontal line clockwise for it to match the line between the
'  two points.
Function GetAngleOfLineBetweenTwoPoints(point1 As Point3d, point2 As Point3d) As Double

   Dim xDiff As Double
   Dim yDiff As Double
    
   xDiff = point2.X - point1.X
   yDiff = point2.Y - point1.Y
  
   If xDiff <> 0 Then
  
       GetAngleOfLineBetweenTwoPoints = Atn(yDiff / xDiff) * (180 / Pi())
       'GetAngleOfLineBetweenTwoPoints = Atn2(yDiff, xDiff) * (180 / Pi())
   Else
       GetAngleOfLineBetweenTwoPoints = 0
   End If
  
      
  
  
  


       
End Function

Function GetNewLocation(termPoint As Point3d, arrowPoint As Point3d, ang)

     Dim distEndLineToCtr As Double
     Dim sinByDist As Double
     Dim cosByDist As Double
     Dim xLoc As Double
     Dim yLoc As Double
     Dim newLoc As Point3d
     Dim deltaOfXPoints As Double
     Dim deltaOfYPoints As Double
     Dim sumSquares As Double
     Dim sinAngle As Double
     Dim cosAngle As Double
     Dim hypotenuse As Double
     Dim cosByDistTest As Double
     Dim sinByDistTest As Double
     Dim newLocation As Point3d
    
        
   
     distEndLineToCtr = 0.1   'distance from the end of the line
                             'to the center of the index number
                                
          
    ' Test number of characters to determine if extra space is needed
    ' in the positioning of the leader line for index numbers
    ' along the x-axis
       
     deltaOfXPoints = termPoint.X - arrowPoint.X      'deltaOfXPoints = delta x
     deltaOfYPoints = termPoint.Y - arrowPoint.Y      'deltaOfYPoints = delta y
     sumSquares = (deltaOfXPoints * deltaOfXPoints) + (deltaOfYPoints * deltaOfYPoints) 'Calculate length of hypotenuse
     hypotenuse = Sqr(sumSquares)
     sinAngle = deltaOfYPoints / hypotenuse
     cosAngle = deltaOfXPoints / hypotenuse
           
    'If "distEndLineToCtr" is >= 2, skip the Fudge Factor.
   
     If ((ang <= 45) Or (ang > 135 And ang <= 225)) And (distEndLineToCtr < 2) Then
         distEndLineToCtr = distEndLineToCtr * 1
         distEndLineToCtr = distEndLineToCtr * 0.7  'FUDGE FACTOR
     End If
    
     'Multiply sin by the distance
 
     sinByDist = sinAngle * distEndLineToCtr
 
     'Calculate the new Y location
   
     newLocation.Y = sinByDist + termPoint.Y
       
     'Multiply cos by the distance
   
     cosByDist = cosAngle * distEndLineToCtr
   
     'Now calculate the new X location
   
     newLocation.X = cosByDist + termPoint.X
     
     GetNewLocation = newLocation
        
End Function

  
Sub ResetVals()


CadInputQueue.SendCommand "echo"

   ActiveSettings.TextStyle.Justification = saveActiveTextJustification
   ActiveSettings.TextStyle.NodeJustification = saveActiveTextNodeJustification
   ActiveSettings.Angle = saveActiveAngle
  
   'Set ActiveSettings.Level = saveActiveLevel
    Set saveActiveFont = ActiveSettings.Font
   ActiveSettings.TextStyle.Height = saveActiveCharHeight
   ActiveSettings.TextStyle.Width = SaveActiveCharWidth
   'ActiveSettings.LineStyle = saveActiveLineStyle  ' reset active symbology
   ActiveSettings.Color = saveActiveColor              ' reset active symbology
   ActiveSettings.LineWeight = saveActiveWeight        ' reset active symbology

   CadInputQueue.SendKeyin "lock axis on"
    CadInputQueue.SendCommand "null"
  
   
    ShowCommand "LEADER LINE User Command Exited"
  


End Sub
   


How to get a list of Viewports C#

$
0
0

Hi Everyone!

I am using verson of MicroStation  Connection. For example I have a model (aka sheet) and it has several (4) attaches. In the sheet I see them as Viewports.

Is there a way to get each viewport and iterate through them?

If there is no such method, is it possible to get the boundaries of each viewport in the drawing (as a 2D point) and then for each of them get a 3D point in the model space?

Thank you!

[CE U13.1 C#] How to work with Type 19 Solid in LocateSubEntityTool?

$
0
0

Hi,

I am working on a tool designed for 3D operations with solid, where one from possible inputs can be old solid (element type 19).

I am aware of a fact that not ISolidKernelEntity (which I guess is also type 19) has limited support, but I was not able to implement any working code that would allow me to access the solid geometry.

The tools is "read only / query tool", so IsModifyOriginal returns true. I am not sure what is a right value returned from OnPreElementModify.

I am able to select the solid and its face(s), but I failed to do anything in OnElementModify:

public override StatusInt OnElementModify(Element element)
{
    SubEntity[] subEntities = new SubEntity[0];
    this.GetAcceptedSubEntities(ref subEntities);
    // Ok, I receive accepted faces

    for (int i = 0; i < subEntities.Length; i++)
    {
        SubEntity face = subEntities[i];

        IntPtr geom = default(IntPtr);
        BentleyStatus getGeometryStatus = this.GetSubEntityGeometry(geom, face);
        // getGeometryStatus is SUCCESS, but the pointer is always zero ... no data

        SubEntity[] vertices;
        BentleyStatus getFaceVerticesStatus = SolidUtil.GetFaceVertices(out vertices, face);
        // getFaceVerticesStatus is always ERROR
    }

    // Element is not modifed
    // From C++ documentation: ERROR to reject change or if change completely handled by tool.
    return StatusInt.Error;
}

I also tried to overwrite

protected override BentleyStatus OnProcessSolidPrimitive(ref SolidPrimitive geomPtr, DisplayPath path)
{
    return BentleyStatus.Error;
}

but the results are always the same regardless Error or Success is returned. It seems the method is never called, I was not able to reach a break point in Debug or to print a message from the method :-(

I would like to know whether I do anything wrong (e.g. to override some other method?) or there is a bug in the code (maybe two bugs? ... OnProcessSolidPrimitve not called and GetSubEntityGeometry returns success but not pointer?).

Ultimately, I need to obtain:

  • geometry (and vertices), when a user selects face
  • curve (and end points), when a user selects edge
  • point, when a user selects vertex

With regards,

  Jan

如何获取构建所有属性信息

$
0
0

老师们好,我想得到图片里面所有的属性信息。我看了很多帖子都没有实现,只是获得了一点点“通用”属性,比如name color weight之类的。但是其他的属性都没有获取到。

我通过element去便利然后获取IDgnECInstance 再用IECProperty去尝试都无法成功。能告诉我的错误在哪里吗?真的非常感谢。

下面是我的部分代码:

DgnModel dgnModel = Session.Instance.GetActiveDgnModel();
IEnumerator<Element> iEe = dgnModel.GetGraphicElements().GetEnumerator();
iEe.Reset();
while (iEe.MoveNext())
{
Element elTmp = iEe.Current;
LogLine = string.Format("ElementId : {0} ClassType : {1} ElemenType : {2} ElemenTypeName : {3}", elTmp.ElementId.ToString(), elTmp.GetType().ToString(), elTmp.ElementType, elTmp.TypeName);
WriteLogLine(LogLine);

DgnECManager aa = DgnECManager.Manager;
DgnECInstanceCollection ss = aa.GetElementProperties(elTmp, ECQueryProcessFlags.SearchAllClasses);
//DgnECInstanceCollection ss = aa.GetElementProperties(elTmp, ECQueryProcessFlags.);
IEnumerator<IDgnECInstance> ie = ss.GetEnumerator();


ElementPropertiesGetter pgetter = new ElementPropertiesGetter(elTmp);
var color = pgetter.Color;
var ww = pgetter.Weight;

try
{

var clas1s = pgetter.ElementClass.ToString();
var LineStyle = pgetter.LineStyle.ToString();

Bentley.MstnPlatformNET.Session org = Bentley.MstnPlatformNET.Session.Instance;
FileLevelCache lc = org.GetActiveDgnFile().GetLevelCache();
LevelHandle lh = lc.GetLevel(pgetter.Level, false);
string levelname = lh.Name;
//ElementPropertiesGetter v3 = new ElementPropertiesGetter();
//DVector3d v3 = pgetter.Thickness();

LogLine = string.Format("color : {0} ww : {1} name : {2} class : {3} LineStyle : {4}", color, ww, levelname, clas1s, LineStyle);
WriteLogLine(LogLine);

}
catch(ArgumentNullException)
{
LogLine = string.Format("color111 : {0} ww : {1} ", color, ww);
WriteLogLine(LogLine);
}
ie.Reset();
while (ie.MoveNext())
{
IDgnECInstance idec = ie.Current;
IEnumerator<IECPropertyValue> iem = idec.GetEnumerator(false);
if (iem != null)
{
iem.Reset();
while (iem.MoveNext())
{
IECPropertyValue tmpProperty = iem.Current;
tmpProperty.Property.ToString();

foreach (IECProperty prop in idec.ClassDefinition.Properties(true))
{
var nn = prop.Name;
}

}

}
}

How to get properties by category

$
0
0

hi~

I want to get properties by category. Just like the title in the picture below to classify and export. But only the customized ones that I export can not be exported by clicking here. The circles in the picture are uniformly assigned to "BREP cells". How to classify each class?

Here is my code. Thank you very much.

code:

            IEnumerator<Element> iEe = dgnModel.GetGraphicElements().GetEnumerator();
            iEe.Reset();
            while (iEe.MoveNext())
            {
                Element elTmp = iEe.Current;
                LogLine = string.Format("ElementId : {0}  ClassType : {1}  ElemenType : {2}  ElemenTypeName : {3}", elTmp.ElementId.ToString(), elTmp.GetType().ToString(), elTmp.ElementType, elTmp.TypeName);
                WriteLogLine(LogLine);
                Element myElem = dgnModel.FindElementById((ElementId)elTmp.ElementId);
                if(myElem ==null)
                {
                }
                DgnECManager ecManager = DgnECManager.Manager;
                int count = 0;
                DgnECInstanceCollection instCol = ecManager.GetElementProperties(myElem, ECQueryProcessFlags.SearchAllClasses);
                foreach (IDgnECInstance inst in instCol)
                {
                    count++;
                    LogLine = "----ECInstance" + count.ToString() + "[" + inst.ClassDefinition.DisplayLabel + "]";
                    WriteLogLine(LogLine);
                    IEnumerator<IECProperty> propertyEnum = inst.ClassDefinition.GetEnumerator();
                    while (propertyEnum.MoveNext())
                    {
                        IECPropertyValue propertyValue = inst.GetPropertyValue(propertyEnum.Current.Name);
                        if (propertyValue.IsArray)
                        {
                            IECArrayValue arrayVal = propertyValue as IECArrayValue;
                            if (arrayVal.Count >= 1)
                                propertyValue = arrayVal[0];
                        }
                        string strVal;
                        double dblVal;
                        int intVal;
                        var a = propertyValue.Type;
                        if (propertyValue.TryGetStringValue(out strVal))
                        {
                            LogLine = "\tProperty=" + propertyEnum.Current.DisplayLabel + ", stringValue=" + strVal;
                            WriteLogLine(LogLine);
                            //LogLine = UnicodeToString("u53c2");
                            //WriteLogLine(LogLine);
                        }
                        else if (propertyValue.TryGetDoubleValue(out dblVal))
                        {
                            LogLine = "\tProperty=" + propertyEnum.Current.DisplayLabel + ", doubleValue=" + dblVal.ToString();
                            WriteLogLine(LogLine);
                        }

                        else if (propertyValue.TryGetIntValue(out intVal))
                        {
                            LogLine = "\tProperty=" + propertyEnum.Current.DisplayLabel + ", intValue=" + intVal.ToString();
                            WriteLogLine(LogLine);
                        }
                    }
                }

MicroStation CE U13 SDK. Cannot find the Bentley C# Project addins. Visual Studio 2017 Professional.

$
0
0

I suppose the Bentley Projects are missing here?

Anyone knows why?

Viewing all 7260 articles
Browse latest View live


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