AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA Selection Sets with Filter

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
506 Views, 2 Replies

VBA Selection Sets with Filter

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
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

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
Message 3 of 3
Anonymous
in reply to: Anonymous

Thanks, it works great!

Tammy

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost