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

VBA and Context ACS Coordinates

$
0
0

Hi Members,

We want to automate the creation of multiple Descartes sections along a rail alignment.

I put together the following code which makes use of the point tools keyin to create a quick section. It creates the section ok but the contents are positioned outside the visible extents of the model.

Observing the way the create quick section tool works , it requires only two data points, I supply the first with correct  XYZ and a second point both global XYZ and also with relative coordinates.

Code below shows version with global coordinates for both points.

The Create Quick Section Command changes the ACS to Type - Context after the first point is selected, I think this is my problem.

After trying various methods and searching web and Bentley Forums I cannot progress this.

Here is the VBA Code I am using, It is part of a workflow I produced for V8i, but we are upgrading to Connect so would like it to work in that land as well.

Any feedback would be most appreciated.

Kind Regards

CJM

Sub Create_Sections()
Debug.Print "FileSpec: " & MdlFileOpenDialog_Create_Sections("Select a File with Profile Points", "*.*", "X:\ASSET_DATA_ESN-PCN\02_POINT OUTPUT")
End Sub
Function MdlFileOpenDialog_Create_Sections(sCaption As String, sFileFilter As String, sDefaultDir As String) As String
Const MDLNULL = 0
Const MAXFILELENGTH = 255
Dim rtc As Long, sFileSpec As String
sFileSpec = Space(MAXFILELENGTH)
rtc = mdlDialog_fileOpen(sFileSpec, MDLNULL, MDLNULL, " ", sFileFilter, sDefaultDir, sCaption)
MdlFileOpenDialog_Create_Sections = sFileSpec
If Left(LTrim(sFileSpec), 1) = "X" Then
    mypoints = mySplit(sFileSpec)
    For i = 0 To UBound(mypoints)
        On Error GoTo handler_dimerror
            Dim startPoint As Point3d
            Dim point As Point3d, point2 As Point3d
            Dim lngTemp As Long' mypoints iS array taken from inputing offsets from rail points, whaich are contained in selected file
            If mypoints(i)(0) = "Red" Then'Send a keyin for command string
            CadInputQueue.SendKeyin "pointcloudadv section createquick oriblockbyaxis"
            point.X = Round(mypoints(i)(2), 3)
            point.Y = Round(mypoints(i)(3), 3)
            point.Z = Round(mypoints(i)(4), 3)
            CadInputQueue.SendAdjustedDataPoint point, 5
            point2.X = Round(mypoints(i)(7), 3)
            point2.Y = Round(mypoints(i)(8), 3)
            point2.Z = Round(mypoints(i)(9), 3)
            CadInputQueue.SendAdjustedDataPoint point, 5'Use following to test that points are correct location for sections'            CadInputQueue.SendCommand "PLACE LINE CONSTRAINED"''            point.X = Round(mypoints(i)(2), 3)'            point.Y = Round(mypoints(i)(3), 3)'            point.Z = Round(mypoints(i)(4), 3)'            CadInputQueue.SendDataPoint point, 5''            point2.X = Round(mypoints(i)(7), 3)'            point2.Y = Round(mypoints(i)(8), 3)'            point2.Z = Round(mypoints(i)(9), 3)'            CadInputQueue.SendDataPoint point2, 5'            CadInputQueue.SendReset
            End If
handler_dimerror:
            CadInputQueue.SendReset
    Next i


Else
    Exit Function
End If

CommandState.StartDefaultCommand
End Function

Viewing all articles
Browse latest Browse all 4331


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