Jalen Weir Posted November 10, 2015 Posted November 10, 2015 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. Quote
BIGAL Posted November 11, 2015 Posted November 11, 2015 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 Quote
Jalen Weir Posted November 11, 2015 Author Posted November 11, 2015 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 Quote
Jalen Weir Posted November 11, 2015 Author Posted November 11, 2015 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? Quote
BIGAL Posted November 12, 2015 Posted November 12, 2015 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 Quote
Jalen Weir Posted November 13, 2015 Author Posted November 13, 2015 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!! Quote
Recommended Posts
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.