Active Member
Posts: 6
Registered: ‎08-29-2008
Message 11 of 11 (212 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community