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

RE: Macro help

$
0
0

[quote user="kamil"]My English is very poor[/quote]

We all speak MicroStation and VBA.  This is a world-wide community, and we use English as a common language.  There are many successful contributors to these Forums whose first language is not English.

[quote user="kamil"]needs help in improving macra[/quote]

First, as Jan suggests, forget MicroStation BASIC and move to MicroStation VBA. 

[quote user="kamil"]MbeGetInput MBE_DataPointInput, MBE_CommandInput, MBE_ResetInput[/quote]

BASIC's way to get user input is clumsy.  VBA makes it much easier with the IPrimitiveCommandEvents and ILocateCommandEvents interfaces.

What is the Purpose of your BASIC macro?

Rather than attempt to translate BASIC to VBA, I suggest that you write down the functionality of your macro (in a human language).  Then see how to implement that functional specification using VBA.


RE: Macro help

RE: Macro help

$
0
0

Hi Kamil,

[quote user="kamil"]Macro I wrote a long time ago[/quote]

So it's time to change it (rewrite it) to work well with MicroStation V8i. Also be aware MicroStation V8i is "old product" now in fact, because MicroStation CONNECT Edition was released more than year ago. And in CONNECT Edition, MicroStation BASIC is not supported at all and macros cannot be run (VBA is still supported), so the migration to VBA is not only about better code, but also preparation for future.

[quote user="kamil"]eg. snap on point A to point B snap...[/quote]

In such case primitive command (IPrimitiveCommandEvent object) should be used.

[quote user="kamil"]...and puts in place the marker.[/quote]

Please be consistent and exact: In you original post you wrote about points, now you use a term "marker" and in screen capture you posted as an answer to Jon circles with texts are used. I am aware it probably looks like useless querying, but it's different code if you want to create point (zero length line), circle or text.

[quote user="kamil"]It can help you figure[/quote]

Yes, thanks, the picture is descriptive enough.

BTW How did you write the text that your posts are often in fixed sized gray backgroud font?

With regards,

  Jan

RE: Attributes of the activeSettings bylevel

$
0
0
Ok Jan , always so much apreciated your critery ... yes know I see that is wrong , thanks for the adjust.

Best regards !!

RE: Attributes of the activeSettings bylevel

$
0
0

Hi Xavi,

[quote user="Xavi García Maranges"]nybody knows , how can I get the value of the attributes of the active settings when are bylevel ??.[/quote]

It's a misapprehension how MicroStation works. If active attribute is -1, it's the attribute value, no other value exists. Correct question is "how an appropriate (active) level is defined".

[quote user="Xavi García Maranges"]if it could help somebody[/quote]

Sorry, but this code is wrong ... better to say extremely inefficient, because any query for level settings requires to iterate through all levels in active design file.This code should be enough:

Dim lvlColor As Long
lvlColor = ActiveSettings.Level.ElementColor

With regards,

  Jan

RE: Attributes of the activeSettings bylevel

$
0
0
I have deleted the code for no errors !!

Thanks again !!

Attributes of the activeSettings bylevel

$
0
0

Hi again to everybody ,

Anybody knows , how can I get the value of the attributes of the active settings when are bylevel ??.

With this code ,  I get the value , but if are bylevel it returns me -1 or bylevel ... any idea???

Thanks !!

With ActiveSettings
    Main.txtColor.Text = .color
    Main.txtNivell.Text = .Level.Name
    Main.txtGruix.Text = .LineWeight
    Main.txtEstil.Text = .LineStyle.Name
    Main.txtCella.Text = ""
    Main.chkCella.Value = False
    Main.txtTipus.Text = -1
    Main.txtClasse.Text = -1
End With



RE: How to handle the pipe ('|') character

$
0
0

Hi,

using the "|" pipe character shouldn´t make any problems here, I also used this as separator in strings with no problems.

But from your code I am missing the assignment to the variable tempCommand. The variable is used as string containing the keyin command, but it is not assigned using cmd directly or parts from it
From your example I would expect the variable cmd should be used?

If this doesn´t explain the issue, could you please upload a full working example to allow us reproducing the issue.

Best regards,

Artur  


RE: Procedure to search the value from the Excel in a Microstation files

$
0
0
Hi,

VBA should be enough. Depending where the process should be triggered (started), you can write MicroStation VBA macro that will call Excel through Application object (OLE Automation) or vice versa Excel macro that will call MicroStation.

With regards,

Jan

RE: Procedure to search the value from the Excel in a Microstation files

$
0
0

[quote user="M k"]Should I create a macro or procedure to search the value from the Excel file in a MicroStation file[/quote]

This article about MicroStation VBA and Excel may help.

Procedure to search the value from the Excel in a Microstation files

$
0
0

Hi all,

Should I create a macro or procedure to search the value from the Excel file in a Microstation files.

I have a value (text or number) written to Excel
I want to create a link that searches the value (text or numbers) on the dgn file.

Thank you soo much.

RE: CONNECT SDK : mdlRefFile_beginnAttachmentToModel/mdlRefFile_completeAttachment

$
0
0

Hi,

the builder object is returned from mdlRefFile_beginAttachment.
I have created a small code example to demonstrate use of the functions mdlRefFile_beginAttachment. and mdlRefFile_completeAttachment:

	DgnAttachmentBuilder  builder;
	WCharCP  fileName = L"D:/DGN/ref.dgn";
	WCharCP  modelName = L"Default";
	WCharCP  logical = L"Logical name";
	WCharCP  description = L"Description";
	DgnModelRefP  modelToAttachTo = ACTIVEMODEL;
	StatusInt stat = mdlRefFile_beginAttachmentToModel(builder, fileName, modelName, logical, description, modelToAttachTo);
	if (SUCCESS == stat)
	{
		builder->SetAttachDescription(L"New decsription");
		DgnAttachmentP attachment = 0;
		stat = mdlRefFile_completeAttachment(attachment, builder, RefAttachNestMode::None, 10, true);
	}

I hope this helps?

Best regards,
Artur

CONNECT SDK : mdlRefFile_beginnAttachmentToModel/mdlRefFile_completeAttachment

$
0
0

 who has already used mdlRefFile_beginnAttachmentToModel/mdlRefFile_completeAttachment ?

How to create/initialize the builder argument ?

RE: Macro help

$
0
0

Hi Kamil,

may be this helps you:

Start the Primitive Function

Public Sub start()

    CommandState.StartPrimitive New IdentPoint

End Sub

Class Code:

Option Explicit

Implements IPrimitiveCommandEvents

Private anzahlPoints As Integer
Private A As Point3d
Private B As Point3d
Private C As Point3d



Private Sub IPrimitiveCommandEvents_Cleanup()

End Sub

Private Function GetRotation(p1 As Point3d, p2 As Point3d) As Matrix3d
    
    Dim pDiff As Point3d
    Dim pX As Point3d
    Dim angle As Double
    
    pDiff = Point3dSubtract(p2, p1)
    pDiff.Z = 0
    pX = Point3dFromXYZ(1, 0, 0)
    angle = Vector3dAngleBetweenVectorsXY(Vector3dFromPoint3d(pX), Vector3dFromPoint3d(pDiff))
    angle = angle + Pi / 2
    GetRotation = Application.Matrix3dFromAxisAndRotationAngle(2, angle)
    
End Function

Private Sub IPrimitiveCommandEvents_DataPoint(Point As Point3d, ByVal View As View)
    
    Dim line As LineElement
    Dim text As TextElement
    Dim Ciecie As Double
    Dim Color As Integer
    Dim Dx As Double
    Dim Dy As Double
    Dim Pz As Double
    Dim Z As String
    Dim rot As Matrix3d
    Dim lv As Level
    Dim ft As Font
    Dim ts As TextStyle
    
    If anzahlPoints = 0 Then
        A = Point
        anzahlPoints = anzahlPoints + 1
        CommandState.StartDynamics
        
        ShowPrompt "Ident second Point"
    Else
        B = Point
        
        If A.Z > B.Z Then
            C = A
            A = B
            B = C
        End If
        
        
        If (B.Z - A.Z) < 50 Then
        
            Set lv = ActiveModelReference.Levels.FindByNumber(1)
            Set ft = ActiveDesignFile.Fonts.Find(msdFontTypeWindowsTrueType, "Arial")
        
            rot = Matrix3dIdentity()
            rot = GetRotation(A, B)
            Set line = CreateLineElement2(Nothing, A, B)
            If Not (lv Is Nothing) Then
                Set line.Level = lv
            End If
            ActiveModelReference.AddElement line
            
            Ciecie = 0.5
            Dx = (B.X - A.X) / (B.Z - A.Z) * Ciecie
            Dy = (B.Y - A.Y) / (B.Z - A.Z) * Ciecie
            
            Pz = Ciecie - (A.Z - Fix(A.Z))
            While Pz <= 0
                Pz = Pz + Ciecie
            Wend
            
            C.Z = A.Z + Pz
            C.X = A.X + Pz * Dx / Ciecie
            C.Y = A.Y + Pz * Dy / Ciecie
            While C.Z < B.Z
                Color = (C.Z / 10 - Int(C.Z / 10)) * 10 / Ciecie
                Z = Format$(C.Z, "0,0.0")
                Z = Mid$(Z, Len(Z) - 2, Len(Z))
                
                Set text = CreateTextElement1(Nothing, Z, C, rot)
                text.Color = Val(Format$(Color, "0,0"))
                If Not (lv Is Nothing) Then
                    Set text.Level = lv
                End If
                Set ts = text.TextStyle
                If Not (ft Is Nothing) Then
                    Set ts.Font = ft
                End If
                ts.Justification = msdTextJustificationLeftCenter
                ts.Width = 0.25
                ts.Height = 0.25
                Set text.TextStyle = ts
                ActiveModelReference.AddElement text

                C.Z = C.Z + Ciecie
                C.X = C.X + Dx
                C.Y = C.Y + Dy
            Wend
        End If
        
        CommandState.StopDynamics
        CommandState.StartPrimitive Me

    End If
    
End Sub

Private Sub IPrimitiveCommandEvents_Dynamics(Point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)
    
    Dim line As LineElement
    
    Set line = Application.CreateLineElement2(Nothing, A, Point)
    line.Redraw DrawMode
    
End Sub

Private Sub IPrimitiveCommandEvents_Keyin(ByVal Keyin As String)

End Sub

Private Sub IPrimitiveCommandEvents_Reset()
    CommandState.StartDefaultCommand
End Sub

Private Sub IPrimitiveCommandEvents_Start()
    anzahlPoints = 0
    ShowCommand "Place Marker"
    ShowPrompt "Ident first Point"
End Sub

Macro help

$
0
0




My English is very poor. needs help in improving macra. Action macra is that the 3D drawing when you click on
two adjacent points of known height (Z) are inserted at the point of full meters
(eg. Between points from the 200.48 m - 210.51 m insert points to 200.5 m, 201 m 201.5 m, etc)
everything works well only is one of the fundamental problems that can not help themselves. when you click in a place
where the mute point with a known height Z closes Microstation. Macro version of Microstation V7 SE modified to select V8i series 3 please help

Sub main ()
 dim A as mbepoint
 dim B as mbepoint
 dim C as mbepoint
 Dim view as Integer
 dim Cięcie as Double
 dim kom$ as String
 
 kol%=MbeSettings.color
 Początek:
 kom = "NULL"
  MbeSendCommand "active level 1 "
 MbeSendCommand "NULL"
 MbeSendCommand "Place Line"
 
 
 MbeGetInput MBE_DataPointInput, MBE_CommandInput, MBE_ResetInput
 Select Case  MbeState.inputType
 Case MBE_DataPointInput
    If MbeState.getInputDataPoint (A, view) = MBE_Success Then
    MbeSendDataPoint A
    End If
 Case MBE_CommandInput
    If MbeState.getInputCommand (kom$) = MBE_Success Then
        GoSub Koniec
    End If
 Case MBE_ResetInput
    GoSub Początek
 End Select
 
 
 
 MbeGetInput MBE_DataPointInput, MBE_CommandInput, MBE_ResetInput
 Select Case  MbeState.inputType
 Case MBE_DataPointInput
    If MbeState.getInputDataPoint (B, view) = MBE_Success Then
    End If
 Case MBE_CommandInput
    If MbeState.getInputCommand (kom$) = MBE_Success Then
        GoSub Koniec
    End If
 Case MBE_ResetInput
    GoSub Początek
 End Select


 
 Cięcie = 0.5
 
 
 If A.z > B.z Then
    C=A
    A=B
    B=C
 End If    
 
 MbeSendCommand "Active Angle Pt2"
 MbeSendDataPoint A
 MbeSendDataPoint B
 MbeSettings.Angle = MbeSettings.Angle - PI/2
 
If (B.z-A.z)< 50 then
 Dx# = (B.x-A.x)/(B.z-A.z)*Cięcie
 Dy# = (B.y-A.y)/(B.z-A.z)*Cięcie
 
 Pz# = Cięcie - (A.z - Fix(A.z))
 While Pz <= 0
  Pz = Pz + Cięcie
 Wend
 
 C.z = A.z + Pz
 C.x = A.x + Pz*Dx/Cięcie
 C.y = A.y + Pz*Dy/Cięcie
 While C.z < B.z
    color# = (C.z/10 - Int(C.z/10))*10/Cięcie
    MbeSettings.color = val(Format$(color,"0,0"))
   
   
    
    MbeSendCommand "PLACE TEXT"
    
    
    Z$ = Format$(C.z,"0,0.0")
    Z$ = Mid$(Z,Len(Z$)-2,Len(Z$))
   ' MbeSendKeyin Format$(C.z,"0,0.0")
     MbeSendKeyin Z$
   
   
   
   
    MbeSendDataPoint C
    C.z = C.z + Cięcie
    C.x = C.x + Dx
    C.y = C.y + Dy
 Wend
 
End If
 
 MbeSendCommand "NULL"
 Gosub Początek
 Koniec:
 MbeSettings.color = kol
 MbeSendCommand kom
'MbeMessageBox format$("Pz,"0,0.00"")
End Sub
 



RE: How to handle the pipe ('|') character

$
0
0
I did notice (after posting) about the unassigned variable, but thought it could be inferred that I meant to use the cmd variable in that for loop.

Regarding the issue I was having, I will go a little more into why I am doing this. Essentially, I was assigned a project from my company to reverse engineer a third-party menu software, which build's itself using xml configs. Within these xml files, there are string commands (built from a spreadsheet) which are sent to the ActiveDocument to be handled within MicroStation. Some of these commands contained the originally mentioned "append|". My job was to reproduce this command from the spreadsheets only, so my "check" to see if what I am producing is correct is exactly what was already contained within the third-party's xml file.

Come to find, the third-party add-in was just removing the "append|" and just putting everything after that as an additional command. So that is what I did, and everything is working fine.

How to handle the pipe ('|') character

$
0
0

Right now I am utilizing the CadInputQueue.SendCommand() method to send custom commands to the ActiveDocument. There are some commands which contain the pipe character ('|') within them.

[For example: "append|macro daoff"] 

The entire command is generated from a spreadsheet, where the columns are split into LayerName, Color, LineStyle, Weight, Font, Font Justification, as well as others, but the final column is the custom command, which is where the above line is located in. All other parts I have written working code to handle, but this type of custom command seems to not work due to the pipe character.

I am rather new to programming within MicroStation. I have read that this type of coding for drawing within MicroStation by utilizing the SendCommand() is a poor choice, but given what we have already set up, converting everything to a more "proper" way was not in the budget (time-wise), so this was what I had to do. That said, can I get assistance with how to make this work with what I have?

I believe the pipe is essentially telling me to split the command into two commands, but that doesn't seem to work, or perhaps I am splitting it incorrectly.

private static void SendCommand( MicroStationDGN.ApplicationClass ustn, string command )

{

var splitCommand = command.Split( '|' ).ToList();

foreach(var cmd in splitCommand)
{

ustn.CadInputQueue.SendCommand( tempCommand, true );

}

}

RE: VBA and Reading DMRS Linkages - Can it be done

$
0
0

Gentlemen, Thanks.

The magic bullet here was the 0 based Attribute. I had it stuck in my head that it was going to be some 6 digit mystery number. Also, more reading of the size and offset property of the datablock, allowed me just to grab the bytes I needed. It also didn't help that I got some bad information from the vendor; which I will share with them. To many rabbit holes.

Although, upon discovering my bad information lead me to a new mystery.

Looking at the data linkages tab in V8i I could see the DMRS and the last word contained the Support Modeler model reference. But, the record reference for the cell was in another hex string.

The question now is...is this also somewhere in the DataBlock? To I just need to find the ID for this?
See the image below, the 5th work has the record key. I though the Type might be the AttributeID, but it is not.




RE: VBA and Reading DMRS Linkages - Can it be done

$
0
0

Hi Mark,

as I wrote, it would be nice to have an example and to don't discuss using screen captures only.

There are two linkages:

  • 1st linkage (attribute data) is DMRS, 4 words long
  • 2nd linkage seems to be general attribute data, 8 words long.

[quote user="Mark Gosine"]is this also somewhere in the DataBlock?[/quote]

If you obtained Datablock using AttributeID = 0, the second linkage is not there. You have to use another ID to receive the data.

[quote user="Mark Gosine"]I though the Type might be the AttributeID, but it is not.[/quote]

I guess the right ID is not 0x57fa, but maybe the first word or first and second word together. You can try to iterate from 0 to "max UserID" (which is 16bit unsigned int) and to check for what ID you will receive some data.

What information are provided by old Element Information dialog (key-in "analyze element")? Sometimes it provides better insight to element structure.

With regards,

  Jan

[CONNECT C++] How to set version number of application

$
0
0

How do I set the version number of a MDL application in MicroStation CONNECT Edition? In v8i we used the mdlSystem_setMdlAppVersionNumber function. But this function do not have any effect in CONNECT. At least the MDL application dialog do not show the version number. 

I would also like to know if there is an easy way to set the version on the dll making it wisible on the properties of the DLL.

Regards

Frode Tørresdal 

Viewing all 7260 articles
Browse latest View live


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