Extracting Coords from Points


We get a dxf. with a series of points from a survey. I am looking to extract the coordinates from those points so I can sort them into groups for manipulation, but I cant seem to get the coordinates out if 'Point' or 'PointEntity'.

Code: Select all

Dim objENT As IntelliCAD.PointEntity
Dim ssetObj As SelectionSet
Set ssetObj = ActiveDocument.SelectionSets.Add("MySS54")
Dim xCoord() As Double
Dim yCoord() As Double
Dim zCoord() As Double

ssetObj.Select vicSelectionSetAll
count = ssetObj.count

ReDim xCoord(count) As Double
ReDim yCoord(count) As Double
ReDim zCoord(count) As Double

index = 0                                               'Extract Coordinates from existing Points
    For Each objENT In ssetObj
        If objENT.EntityName = "Point" Then
            xCoord(index) = objENT.Coordinates(0)
            yCoord(index) = objENT.Coordinates(1)
            zCoord(index) = objENT.Coordinates(2)
            index = index + 1
'            Debug.Print CSng(xCoord(index))
'            Debug.Print CSng(yCoord(index))
'            Debug.Print CSng(zCoord(index))
        End If
    Next objENT
Any help would be appreciated. Ive tried that same syntax with:

Code: Select all

I get the same result.

I'm using objENT as a PointEntity because using Point gives me issues with the selection set.


Re: Extracting Coords from Points

Try filter selection by point object first.
Refer this:

Code: Select all

Public Sub ExtractPoints()
    Dim ss As SelectionSet
    Dim gpCode(0) As Integer
    Dim typeVal(0) As Variant
    gpCode(0) = 0
    typeVal(0) = "Point"
    Set ss = ActiveDocument.SelectionSets.Add("MySS")
    ss.SelectOnScreen gpCode, typeVal
    If ss.Count <> 0 Then
        Dim arrPoints() As Variant
        Dim iDim As Integer
        iDim = 0
        ReDim Preserve arrPoints(ss.Count - 1, 2)
        Dim point As IntelliCAD.PointEntity
        For Each point In ss
            arrPoints(iDim, 0) = point.Coordinates.Item(0).x
            arrPoints(iDim, 1) = point.Coordinates.Item(0).y
            arrPoints(iDim, 2) = point.Coordinates.Item(0).z
            iDim = iDim + 1
        Next point
        ' do some thing here (sort them into groups for manipulation ...)
    End If
End Sub