AutoCAD Map 3D Developer

Reply
Active Contributor
Tammy G
Posts: 39
Registered: ‎06-14-2004
Message 1 of 3 (214 Views)

VBA Selection Sets with Filter

214 Views, 2 Replies
11-03-2004 08:57 AM
I am attempting to write code to add my new topology centroids into a selection set. This will allow me to run through the Object Data that is attached to them and output it into Oracle. I have my oracle connection up and running in VBA, but I cant seem to make my selection set work. I am using some set points as a selection boundary.

Sub points()

Dim amap As AcadMap
Dim acadObj As Object
Dim ODtb As ODTables
Dim Prj As Project
Dim ODrcs As ODRecords
Dim boolVal As Boolean
Dim ssetObj As AcadSelectionSet
Dim i As Integer
Dim returnObj As AcadObject
Dim basePnt As Variant
Dim fType(1) As Integer
Dim fData(1) As Variant
'Dim Lst(1, 1) As Variant
Dim pntLst(7) As Variant

'first attempt at point list
'Lst(0, 0) = Array(474000, 5450000)
'Lst(1, 1) = Array(495000, 5480000)

'x coord then y coord for lower left, upper left, upper right and lower right.
pntLst(0) = 474000
pntLst(1) = 5450000
pntLst(2) = 474000
pntLst(3) = 5480000
pntLst(4) = 495000
pntLst(5) = 5480000
pntLst(6) = 495000
pntLst(7) = 5450000

'sets up the map
Set amap = ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application")

'sets the table collection
Set Prj = amap.Projects.Item(ThisDrawing)
Prj.ProjectOptions.DontAddObjectsToSaveSet = True
Set ODtb = Prj.ODTables

'sets the records collection
Set ODrcs = ODtb.Item("Identity_data").GetODRecords

'adds new objects to the selection set
fType(0) = 0
fType(1) = 8
fData(0) = "Point"
fData(1) = "0"

Set ssetObj = ThisDrawing.SelectionSets.Add("SS01")

'attempting to add all centriods on layer "0" to selection
ssetObj.SelectByPolygon acSelectionSetWindowPolygon, pntLst, fType, fData

MsgBox ssetObj.COUNT

For Each acadObj In ssetObj
boolVal = ODrcs.Init(ssetObj, True, False)
MsgBox ODrcs.Record.tableName
MsgBox ODrcs.Record.ObjectID

For i = 0 To ODrcs.Record.COUNT - 1
MsgBox ODrcs.Record.Item(i).Value
Next i

Next
End Sub

Does anyone know what Im doing wrong. Sorry if I am posting too much, I am very behind schedule.

Thanks,

Tammy
*LochDhu
Message 2 of 3 (214 Views)

Re: VBA Selection Sets with Filter

11-03-2004 11:54 AM in reply to: Tammy G
Tammy, If memory recalls, the point list is 3D, not 2D - so add a Z point to each vertex = 0. Scott "Tammy G" wrote in message news:29214609.1099501077947.JavaMail.jive@jiveforum2.autodesk.com... > I am attempting to write code to add my new topology centroids into a selection set. This will allow me to run through the Object Data that is attached to them and output it into Oracle. I have my oracle connection up and running in VBA, but I cant seem to make my selection set work. I am using some set points as a selection boundary. > > Sub points() > > Dim amap As AcadMap > Dim acadObj As Object > Dim ODtb As ODTables > Dim Prj As Project > Dim ODrcs As ODRecords > Dim boolVal As Boolean > Dim ssetObj As AcadSelectionSet > Dim i As Integer > Dim returnObj As AcadObject > Dim basePnt As Variant > Dim fType(1) As Integer > Dim fData(1) As Variant > 'Dim Lst(1, 1) As Variant > Dim pntLst(7) As Variant > > 'first attempt at point list > 'Lst(0, 0) = Array(474000, 5450000) > 'Lst(1, 1) = Array(495000, 5480000) > > 'x coord then y coord for lower left, upper left, upper right and lower right. > pntLst(0) = 474000 > pntLst(1) = 5450000 > pntLst(2) = 474000 > pntLst(3) = 5480000 > pntLst(4) = 495000 > pntLst(5) = 5480000 > pntLst(6) = 495000 > pntLst(7) = 5450000 > > 'sets up the map > Set amap = ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application") > > 'sets the table collection > Set Prj = amap.Projects.Item(ThisDrawing) > Prj.ProjectOptions.DontAddObjectsToSaveSet = True > Set ODtb = Prj.ODTables > > 'sets the records collection > Set ODrcs = ODtb.Item("Identity_data").GetODRecords > > 'adds new objects to the selection set > fType(0) = 0 > fType(1) = 8 > fData(0) = "Point" > fData(1) = "0" > > Set ssetObj = ThisDrawing.SelectionSets.Add("SS01") > > 'attempting to add all centriods on layer "0" to selection > ssetObj.SelectByPolygon acSelectionSetWindowPolygon, pntLst, fType, fData > > MsgBox ssetObj.COUNT > > For Each acadObj In ssetObj > boolVal = ODrcs.Init(ssetObj, True, False) > MsgBox ODrcs.Record.tableName > MsgBox ODrcs.Record.ObjectID > > For i = 0 To ODrcs.Record.COUNT - 1 > MsgBox ODrcs.Record.Item(i).Value > Next i > > Next > End Sub > > Does anyone know what Im doing wrong. Sorry if I am posting too much, I am very behind schedule. > > Thanks, > > Tammy
Active Contributor
Tammy G
Posts: 39
Registered: ‎06-14-2004
Message 3 of 3 (214 Views)

Re: VBA Selection Sets with Filter

11-03-2004 12:37 PM in reply to: Tammy G
Thanks, it works great!

Tammy

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community