0 Members and 1 Guest are viewing this topic.
ObjectId id = per.ObjectId;string sid = id.ToString();//string value: (2123218520)
Convert.ToInt32(sid.Trim(new char[] { '(', ')' }))
Int32.Parse(sid.Trim(new char[] { '(', ')' }))
Code: [Select]Convert.ToInt32(sid.Trim(new char[] { '(', ')' }))orCode: [Select]Int32.Parse(sid.Trim(new char[] { '(', ')' }))
I need get ObjectId from string. I dont need get Int32 from string.
let str = "(2123218520)" let (res, long) = str.Trim[|'('; ')'|] |> System.Int64.TryParse if res then new ObjectId(nativeint long) else failwith "Boom"
public string GetFullPath(Transaction t, DBObject obj) { string path = string.Format("{0}|{1}", obj.ObjectId.ObjectClass.Name, obj.ObjectId.Handle.Value); if (obj.OwnerId != ObjectId.Null && obj.OwnerId.IsValid) path = string.Format("{0}\\{1}", GetFullPath(t, t.GetObject(obj.OwnerId, OpenMode.ForRead)), path); return path;}
Full path: AcDbBlockTable|1\AcDbBlockTableRecord|31\AcDbArc|1148147
AcDbBlockTable|1AcDbBlockTableRecord|31AcDbArc|1148147
Here's from another forum:http://forums.autodesk.com/t5/NET/Convert-string-to-ObjectId/m-p/1630045#M3324
You're welcome but don't thank me, thank Tony T.