.NET

Reply
Distinguished Contributor
jbooth
Posts: 223
Registered: ‎02-17-2006
Message 1 of 3 (366 Views)

AcDb.TypedValue and Selection Sets

366 Views, 2 Replies
09-28-2009 03:31 PM
This all started when I needed to pass a collection of ObjectIDs to acedCmd

{code}Declare Auto Function acedCmd Lib "acad.exe" Alias "acedCmd" (ByVal resbuf As IntPtr) As Integer{code}

The approach I used was to create a selection set out of the ObjectIds, and pass it as part of the result buffer required by acedCmd. I've tried using Autodesk.AutoCAD.Runtime.LispDataType.SelectionSet (5007) for the data type.

{code}Dim ss As Autodesk.AutoCAD.EditorInput.SelectionSet = Autodesk.AutoCAD.EditorInput.SelectionSet.FromObjectIds(SourceIds.ToArray())
ExecuteCommand("_.pedit", "m", ss, "", "", "j", "", "")
{code}

As you can see, it should simply make an attempt to join all of the objects into a polyline.
The code appears to work fine, but I've noticed two things:

1. Using reflection on the SelectionSet returns "SelectionSetFullyMarshalled" instead of the expected "SelectionSet" Type Name.
2. Running my application works, but if run multiple times I eventually I get a TargetInvocationException from the Add() method of AcDb.ResultBuffer

I guess what I am asking here is if I have created my ResultBuffer correctly by using LispDataType.SelectionSet or if it's more likely that I am just not disposing my objects correctly elsewhere in my application.

{code}Return New AcDb2.TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.SelectionSet, DirectCast(source, Autodesk.AutoCAD.EditorInput.SelectionSet)){code}

Regards,
JB
*Tony Tanzillo
Message 2 of 3 (366 Views)

Re: AcDb.TypedValue and Selection Sets

09-29-2009 06:48 AM in reply to: jbooth
I really can't tell you much from the snippets you posted.

The only thing I can tell you is that you might be better off
passing the entire array of ObjectIds to acedCmd() because
of the amount of work that SelectionSet.FromObjectIds()
must do.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6262296@discussion.autodesk.com...
This all started when I needed to pass a collection of ObjectIDs to acedCmd

{code}Declare Auto Function acedCmd Lib "acad.exe" Alias "acedCmd" (ByVal
resbuf As IntPtr) As Integer{code}

The approach I used was to create a selection set out of the ObjectIds, and
pass it as part of the result buffer required by acedCmd. I've tried using
Autodesk.AutoCAD.Runtime.LispDataType.SelectionSet (5007) for the data type.

{code}Dim ss As Autodesk.AutoCAD.EditorInput.SelectionSet =
Autodesk.AutoCAD.EditorInput.SelectionSet.FromObjectIds(SourceIds.ToArray())
ExecuteCommand("_.pedit", "m", ss, "", "", "j", "", "")
{code}

As you can see, it should simply make an attempt to join all of the objects
into a polyline.
The code appears to work fine, but I've noticed two things:

1. Using reflection on the SelectionSet returns
"SelectionSetFullyMarshalled" instead of the expected "SelectionSet" Type
Name.
2. Running my application works, but if run multiple times I eventually I
get a TargetInvocationException from the Add() method of AcDb.ResultBuffer

I guess what I am asking here is if I have created my ResultBuffer correctly
by using LispDataType.SelectionSet or if it's more likely that I am just not
disposing my objects correctly elsewhere in my application.

{code}Return New
AcDb2.TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.SelectionSet,
DirectCast(source, Autodesk.AutoCAD.EditorInput.SelectionSet)){code}

Regards,
JB
Distinguished Contributor
jbooth
Posts: 223
Registered: ‎02-17-2006
Message 3 of 3 (366 Views)

Re: AcDb.TypedValue and Selection Sets

09-29-2009 07:46 AM in reply to: jbooth
I would love to do that. The only reason I chose a selection set was because I did not know which data type to use on an array of ObjectId.


Thanks very much for the suggestion. After passing each ObjectId to acedcmd() individually my problem has appeared to vanish.

Regards,
JB.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!