+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Newbie
    Using
    AutoCAD 2006
    Join Date
    Nov 2008
    Posts
    5

    Default How to retrive 3D coordinate information of any object from AutoCAD VBA

    Registered forum members do not see this ad.

    Hi,

    Does any one knows how to retrive 3D coordinate information of any object from AutoCAD VBA.

    Please watch following program in AutoCAD VBA
    ----------------------------------------------------------------

    Dim entity As AcadEntity,my3Dobj As Acad3DSolid

    For Each entity In ThisDrawing.ModelSpace
    MsgBox "entity.ObjectName = " & entity.ObjectName
    If LCase(entity.ObjectName) = "acdb3dsolid" Then
    MsgBox "found solid"
    Set my3Dobj = entity

    'my3Dobj.( I don't understand which method will show XYZ 'coordinates of my3Dobj object. Please help me

    my3Dobj = Nothing
    End If
    Next


    -----------------------------------------------------------------

  2. #2
    Super Member SEANT's Avatar
    Using
    Mechanical 2009
    Join Date
    Aug 2005
    Location
    Rhode Island
    Posts
    1,442

    Default

    As you may have already determined, VBA has limited access to the information stored within an Acad3dSolid. There are a few methods traditionally employed to deal with this situation but they generally require quite a bit of custom code.

    What exactly are you trying to find out about the Solid?

  3. #3
    Forum Newbie
    Using
    AutoCAD 2006
    Join Date
    Nov 2008
    Posts
    5

    Default

    Thanks SEANT for comment,

    Can you pass information about custom code which can retrive coordinates of 3D lines and save it in an array. I had search it in google but can not found any help.

  4. #4
    Super Member SEANT's Avatar
    Using
    Mechanical 2009
    Join Date
    Aug 2005
    Location
    Rhode Island
    Posts
    1,442

    Default

    Here’s a fairly basic routine to select some lines and store the endpoints into an array. The routine will print the endpoints to a Message Box.

    Code:
    Option Explicit
    
    Sub Lines2Points()
    Dim intCode(0) As Integer
    Dim varData(0) As Variant
    Dim entLine As AcadLine
    Dim intLineQuantity As Integer
    Dim arrLineCoords() As Variant
    Dim i As Integer
    Dim strMsg As String
    
    intCode(0) = 0
    varData(0) = "LINE"
    intLineQuantity = (SoSSS(intCode, varData) * 2) - 1
    If intLineQuantity > -1 Then
       ReDim arrLineCoords(intLineQuantity)
       For Each entLine In ThisDrawing.SelectionSets.Item("TempSSet")
          arrLineCoords(i) = entLine.StartPoint
          arrLineCoords(i + 1) = entLine.EndPoint
          i = i + 2
       Next
       For i = 0 To intLineQuantity Step 2
             strMsg = strMsg & "Start: " & PointToString(arrLineCoords(i)) _
                & "  --  End: " & PointToString(arrLineCoords(i + 1)) & vbCr
       Next
       MsgBox strMsg
       
    End If
    End Sub
    
    
    Function SoSSS(Optional grpCode As Variant, Optional dataVal As Variant) As Integer
    Dim objSSs As AcadSelectionSets
    Dim objTempSS As AcadSelectionSet
    Set objSSs = ThisDrawing.SelectionSets
    For Each objTempSS In objSSs
       If objTempSS.Name = "TempSSet" Then
          objTempSS.Delete
          Exit For
       End If
    Next
       Set objTempSS = ThisDrawing.SelectionSets.Add("TempSSet")
             'pick selection set
       If IsMissing(grpCode) Then
          objTempSS.SelectOnScreen
       Else
          objTempSS.SelectOnScreen grpCode, dataVal
       End If
       SoSSS = objTempSS.Count
    End Function
    
    Public Function PointToString(varPt As Variant) As String
    Dim retVal As String, i As Long
       For i = LBound(varPt) To UBound(varPt)
           varPt(i) = Round(varPt(i), 2)
           retVal = retVal & CStr(varPt(i)) & ","
       Next
       PointToString = Left(retVal, Len(retVal) - 1)
    End Function

Similar Threads

  1. Coordinate Systems and AutoCAD
    By JayT in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 29th Feb 2008, 05:25 pm
  2. Coordinate from excel to autocad
    By rick_belial in forum AutoCAD Drawing Management & Output
    Replies: 7
    Last Post: 15th Nov 2007, 02:19 pm
  3. retrive object names by VBA
    By amilapradeep in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 7th Jun 2007, 09:18 pm
  4. How can i get information from a polyline object?
    By tsimaros in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 18th Oct 2005, 10:35 pm
  5. Object Information
    By richsullivan in forum AutoCAD General
    Replies: 0
    Last Post: 13th Jul 2005, 02:59 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts