.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AcDb.TypedValue and Selection Sets

2 REPLIES 2
Reply
Message 1 of 3
jbooth
663 Views, 2 Replies

AcDb.TypedValue and Selection Sets

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
2 REPLIES 2
Message 2 of 3
Anonymous
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
Message 3 of 3
jbooth
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.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost