Active Member
Posts: 6
Registered: ‎08-29-2008
Message 11 of 11 (254 Views)

Re: convert entity name to objectID

10-26-2012 04:29 PM in reply to: jmaeding

Even if you send the results of entget, you have a list that includes approx. two objects (enames) that will be converted to ObjectId's, as gile pointed out (ex. assoc -1 & 330)

Parsing the lisp data in .net, you will have a group of mostly dotted pairs (LispDataType.DottedPair) and  these conses in the list will be the likes of...


(-1 . <Entity name: 7ffff605b90>) -> LispDataType.ObjectId

 (0 . "LINE") -> LispDataType.Text

(330 . <Entity name: 7ffff6039f0>) -> LispDataType.ObjectId

(5 . "1B1") -> LispDataType.Text

(100 . "AcDbEntity") LispDataType.Text

(67 . 0) LispDataType.Int16??

(410 . "Model") LispDataType.Text

(8 . "0") LispDataType.Text

(100 . "AcDbLine") LispDataType.Text

(10 9.36013 9.3543 0.0) LispDataType.Point3d

(11 15.5982 8.93509 0.0) -> LispDataType.Point3d

(210 0.0 0.0 1.0) -> LispDataType.Point3d


As mentioned before, if you happen to get plain text ename in .net, then you can convert it

If your ename is the string hex ename we see in autolisp, then...

ObjectId newObjId = new ObjectId(new IntPtr(Convert.ToInt64(strHexEname, 16)));

If your ename is the string form of decimal for of the ename, then it's pretty much the same...

ObjectId newObjId = new ObjectId(new IntPtr(Convert.ToInt64(strDecEname)));

Reform the list above using the ObjectId's in place of enames nested in dotted pairs nested in a lisp...

ResultBuffer res = new Resultbuffer();
res.Add(new TypedValue((int)LispDataType.ListBegin));
res.add(new TypedValue((int)LispDataType.Int16, -1));
res.Add(new TypedValue((int)LispDataType.ObjectId, myPassingObjId));  //is received in lisp as an ename
res.Add(new TypedValue((int)LispDataType.DottedPair));

res.Add(new TypedValue((int)LispDataType.Int16, 0));
res.Add(new TypedValue((int)LispDataType.Text, strObjectTypeName));
res.Add(new TypedValue((int)LispDataType.DottedPair));


res.Add(new TypedValue((int)LispDataType.ListEnd));


 - And you can entmod with what is returned.


All that to say, that you could just receive the ename, and use the ObjectId to get all the stuff off the .net object to rebuild your data to send back.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.