Jump to content

Get Coords from AcadPoint and pass to array


Jalen Weir

Recommended Posts

Working in VBA for AutoCAD 2016 and I cant seem to figure out how to extract coordinates from a point in an open, active drawing. Any help would be much appreciated.

 

Thank you.

Link to comment
Share on other sites

Dont have much time but are you talking about a "Autocad POINT"

 

Secondly can you use lisp instead as VBA is gradually being dropped.

 

A sample for getting a selection set

DDim objENT As AcadEntity
Dim ssetObj As AcadSelectionSet
Set ssetObj = ThisDrawing.SelectionSets.Add("MYSS6")
ssetObj.Select acSelectionSetAll
For Each objENT In ssetObj
objENT.color = acByLayer
objENT.Linetype = "ByLayer"
Next objENT

 

a couple more maybe been a while in VBA

 

Dim pt1(0 To 2) As Double
pt1=ThisDrawing.Utility.Getpoint
'pt1(0) is X pt1(1) is Y 
If objENT.Name = "acpoint" Then

Link to comment
Share on other sites

Dont have much time but are you talking about a "Autocad POINT"

 

pt1=ThisDrawing.Utility.Getpoint

 

That's close. It gives me a few more ideas. The line above wont pass into the array.

The "ssetObj.Select acSelectionSetAll" was one of the things that i was looking for.

 

Thank you

Jalen

Link to comment
Share on other sites

I need to pass this into a collection but here it is:

 

Dim objENT As AcadPoint
Dim ssetObj As AcadSelectionSet
Set ssetObj = ThisDrawing.SelectionSets.Add("MySS25")
Dim pt1(0 To 2) As Variant

ssetObj.Select acSelectionSetAll

   For Each objENT In ssetObj
       If objENT.ObjectName = "AcDbPoint" Then
           pt1(0) = objENT.Coordinates(0)
           pt1(1) = objENT.Coordinates(1)
           pt1(2) = objENT.Coordinates(2)
           'Debug.Print objENT.Coordinates(0)
           'Debug.Print objENT.Coordinates(1)
           'Debug.Print objENT.Coordinates(2)
       End If
   Next objENT

How often to people answer their own posts? :?:shock::D

Link to comment
Share on other sites

Me personally I would use X Y Z, pt1(1) means ? or HOR VER LEVEL

should have posted this just search for a POINT example is for block

Dim FilterDXFCode(0) As Integer
Dim FilterDXFVal(0) As Variant
FilterDXFCode(0) = 0
FilterDXFVal(0) = "INSERT"
'FilterDXFCode(1) = 2
'FilterDXFVal(1) = "SCHEDTEXT"
Set SS = ThisDrawing.SelectionSets.Add("pit1sel")
SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal

Link to comment
Share on other sites

Well I need the coordinates, not the point itself. Basically I will be getting point data from a survey as a .dxf and I will be generating polylines between the points to show elevation and span of a crane rail. I wont know how many data points i will receive so I have to iterate between each one. I have a ways to go but you gave me the couple of hints I needed to get through that first hurdle.

 

Thanks again!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...