Author Topic: how to make typedvalue out of objectID?  (Read 1677 times)

0 Members and 1 Guest are viewing this topic.

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
how to make typedvalue out of objectID?
« on: October 03, 2011, 07:55:38 PM »
I am making a set of functions that makes an arraylist from a resultbuffer, then later converts back to a resultbuffer.
I test it by converting the results of an entget.
One of those items is the -1 group, which is the entity name.
I can convert the ename to a string no problem for the first part of the prog, but when trying to make the typedvalue object and resbuff with:
outRB.Add(new TypedValue(-1, "-2069760"));

it crashes acad.  I can only guess an entity name cannot be added using a string.
I know the ename val is valid, its not an erased entity or something.
Anyone have ideas on how to do it correctly?
thanks
James Maeding

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: how to make typedvalue out of objectID?
« Reply #1 on: October 03, 2011, 08:12:40 PM »
hmm, seems making an objectID out of the number like this works:

AcDb.ObjectId id = new ObjectId(Convert.ToInt32("-2056784"));
retTV = new TypedValue(-1, id);

I get a message saying to use the intPtr constructor of objectID, not sure how to do that but only tried a couple things like (intPtr)"-2056784"...
James Maeding

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: how to make typedvalue out of objectID?
« Reply #2 on: October 03, 2011, 08:26:34 PM »
worked well.  I had to check for the -1 and 330 groups which are enames form an entget.
I might have to do something different though, as I would prefer to not rely on the typecode number when reconstructing the typecode. I make lists of enames all the time in lisp for things that create groups and so on...
James Maeding

Jeff H

  • Needs a day job
  • Posts: 6150
Re: how to make typedvalue out of objectID?
« Reply #3 on: October 05, 2011, 08:14:03 PM »
Have you tried something like?
Code: [Select]
outRB.Add(new TypedValue((int)LispDataType.ObjectId, objId));