Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get the Wall thickness of a Pipe - .NET, C3D2013+

3 REPLIES 3
Reply
Message 1 of 4
Jeff_M
342 Views, 3 Replies

Get the Wall thickness of a Pipe - .NET, C3D2013+

The 2013 .NET API exposes just 10 of the 22 PartDataFields for Pipe objects. WTh (Wall thickness) is not one of them so I'm attempting to get it via Late Binding. This lisp code works, where (vl-sel) is just a helper function to select an object and convert it to a vla-object:

(setq pdr (vlax-get (vl-sel) 'partdatarecord))
(setq itm (vlax-invoke pdr 'find "WTh"))

 to get the PartDataField. However, putting this into my C# code, it fails on the Find portion with an exception

 

//ps is a valid PartSize object
PartDataRecord pdr = ps.SizeDataRecord;
PartDataField diafld = pdr.GetDataFieldBy(PartContextType.PipeInnerDiameter);
object[] args = new object[1]; 
object acadobj = ps.AcadObject;
object pdrobj = acadobj.GetType().InvokeMember("PartDataRecord", System.Reflection.BindingFlags.GetProperty, null, acadobj, null);
args[0] = "WTh";
object wth = pdrobj.GetType().InvokeMember("Find", System.Reflection.BindingFlags.InvokeMethod, null, pdrobj, args); //<<<Fails here
object tag = wth.GetType().InvokeMember("TAG", System.Reflection.BindingFlags.GetProperty, null, wth, null);
string units = (string)wth.GetType().InvokeMember("Units", System.Reflection.BindingFlags.GetProperty, null, wth, null);

 Any ideas as to what I'm missing?

 

Jeff_M, also a frequent Swamper
EESignature
3 REPLIES 3
Message 2 of 4
Jeff_M
in reply to: Jeff_M

OK, it's late and I just realized I'm mixing two object types. My quickie lisp code is using an aeccpipe object, whereas the .NET code is accessing the Part definition in the PartsList. Off to rethink this.
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 4
Anonymous
in reply to: Jeff_M

And for some reason COM is out of the question?:

 

AeccPipe comPipe = p.AcadObject as AeccPipe; //p is of type Autodesk.Civil.DatabaseServices.Pipe
if (comPipe != null)
{
      double dWT = comPipe.WallThickness;
}

Message 4 of 4
Jeff_M
in reply to: Anonymous


@Anonymous wrote:

And for some reason COM is out of the question?:

 


Yes, this is a COM-less application, so I was trying to get it via late binding. However, since I am creating a pipe, not getting one, I need the data from the PartsList, not a Pipe object.

Jeff_M, also a frequent Swamper
EESignature

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report