You have an 'On Error Resume Next' which may be masking an unexpected error. Add 'On Error GoTo 0' after this line 'AcadApp = GetObject(, "AutoCAD.Application")'.
Regards - Nathan
Hi
Thank you all for replying.
With regards to the opening of the file, it is in fact working. "C:\test" was only to show that a path is required. I did not include any dwg files, with the project.
To try it out, make a AutoCAD 2007 dwg file and replace C:\test with the path of the file.
The memory heap comment I'm afraid I don't understand, but using "Set" in Visual Studio 2005, causes it to reply with:
"Let and Set assignment statements are no longer supported".
The "On Error Goto 0" did help.
ssetObj = acadDoc.SelectionSet.Add("SS01") has to be modified into:
ssetObj = acadDoc.SelectionSets.Add("SS01").
Doing this, allows TextBox1.AppendText(ssetObj.Count.ToString) to work.
It reports 0 objects, in the selectionset.
However, the following code line returns an error:
ssetObj.Select(mode, , , grpCode, dataVal)
(grpCode is the FilterType and dataVal is the FilterData)
The error is:
"Invalid argument FilterType in Select"
I tried replacing the arrays with direct insertion of the values, but that didn't work either.
Changing the name of the selectionset, to avoid reuse did not change anything.
The example, from Autodesk, mentioned in my last post is in VBA, so I tried out a similar code, in VBA, which did work (after I removed the ssetObj.Erase() part which deletes the objects!):
I changed the code to use multiline text instead of text, if someone should wish to try out the code (just create a file containing a couple of multiline text fields and use it with the code):
Private Sub CommandButton1_Click()
Dim entObj As AcadEntity
Dim ssetObj As AcadSelectionSet
Dim grpCode(0) As Integer
Dim dataVal(0) As Variant
Dim i As Integer
Dim mode As Integer
UserForm1.Hide
grpCode(0) = 0
dataVal(0) = "MTEXT"
mode = acSelectionSetAll
Set ssetObj = ThisDrawing.SelectionSets.Add("SS01")
ssetObj.Select mode, , , grpCode, dataVal
TextBox1.Text = ssetObj.Count
ssetObj.Delete
UserForm1.Show
End Sub
I tried it out on my file which contains text fields (MTEXT -> TEXT) and it works as well.
Does anyone have any ideas as to why the Filtertype which works in VBA does not in VB.NET?
Could it be that I'm not referencing the AutoCAD document correctly or something like that?
Regards Martin