AutoCAD Civil 3D Customization

Reply
Distinguished Contributor
ruipfbarreiros
Posts: 138
Registered: ‎09-19-2011
Message 1 of 9 (344 Views)
Accepted Solution

Is it possible to add properties to pipes and structures through .NET ?

344 Views, 8 Replies
02-02-2014 03:43 AM

Hi,

 

I wonder if it's possible to add custom made properties to pipes and structures in civil3D through the .NET API?

 

How would I do that?

 

Thanks 

---------------------------------------

Using Building Design Suite Ultimate 2014
Mentor
tyronebk
Posts: 164
Registered: ‎08-17-2007
Message 2 of 9 (326 Views)

Re: Is it possible to add properties to pipes and structures through .NET ?

02-02-2014 05:18 PM in reply to: ruipfbarreiros

I really hope I'm wrong, but I don't think it's possible to create new custom pipe and structure properties through the .Net API. However, once the custom properties are available in the part you can change their values with the API (look into the PartDataRecord and PartDataField classes).

ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 3 of 9 (316 Views)

Re: Is it possible to add properties to pipes and structures through .NET ?

02-02-2014 10:19 PM in reply to: tyronebk

Hi,

 

Does Civil 3D UI tools allows us to add custom properties to Pipes and Structures ?

I am asking this to confirm that I am not missing anything obvious here.

 

How about using Xdata / Xrecord (though I haven't tried them on Civil 3D Pipes and Structures) ?

 

Thanks,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Mentor
tyronebk
Posts: 164
Registered: ‎08-17-2007
Message 4 of 9 (288 Views)

Re: Is it possible to add properties to pipes and structures through .NET ?

02-03-2014 08:05 PM in reply to: Partha.Sarkar

Xdata/Xrecord may work for some cases but misses out on the ability to be called out in Civil 3D labels. After a bit more searching it looks like .net cannot yet add custom properties (there is a bit of .net code on this page for retrieving properties). I haven't yet tested it but you may be able to invoke the PartDataRecord.append COM method to add custom properties. See the relevant COM code here.

 

In the past I added custom properties by editing the XML files as shown on Being Civil. Unlike parcels or points, it doesn't seem to be possible to add custom properties through the UI.

ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 5 of 9 (277 Views)

Re: Is it possible to add properties to pipes and structures through .NET ?

02-03-2014 10:47 PM in reply to: tyronebk

Thanks for the update.

 

You could check one of my earlier post in IM DevBlog :

 

http://adndevblog.typepad.com/infrastructure/2012/09/how-to-set-pipe-network-parts-data-fields-partd...

 

 

This link says : Dynamic properties created with the NetworkCatalogDef class are not yet supported by the .NET API.

 

Let me know if you succedd in using the COM API or you need any further help from me.

 

Thanks,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
ruipfbarreiros
Posts: 138
Registered: ‎09-19-2011
Message 6 of 9 (270 Views)

Re: Is it possible to add properties to pipes and structures through .NET ?

02-04-2014 01:29 AM in reply to: Partha.Sarkar

Thanks for your inputs!

 

Actually tyronebk, I managed to add custom parameters to custom parts just as Being Civil suggests. The problem is that adding those parameters via XML doesn't mean I can access them through .NET, right?

 

After some further research, I wonder: can't I use an extension method to the pipe class in order to create a sub or a function with the pipe object?

 

I'm still trying to find out what's the best way to go...

---------------------------------------

Using Building Design Suite Ultimate 2014
Mentor
tyronebk
Posts: 164
Registered: ‎08-17-2007
Message 7 of 9 (246 Views)

Re: Is it possible to add properties to pipes and structures through .NET ?

02-05-2014 03:42 PM in reply to: ruipfbarreiros

No, you can actually access and change those custom properties, you just can't create them in .net. Here are a couple of methods I've used to get or set the custom property values.

 

private string GetPartOtherProperty( Part part, string propertyName )
{
	return part.PartData.GetDataFieldBy( propertyName ).Value.ToString();
}

private bool SetPartOtherProperty( Part part, string propertyName, string val )
{
	PartDataField pdf = part.PartData.GetDataFieldBy( propertyName );
	if ( !pdf.IsReadOnly )
	{
		pdf.Value = val;
		return true;
	}
else return false; }

 

Distinguished Contributor
ruipfbarreiros
Posts: 138
Registered: ‎09-19-2011
Message 8 of 9 (236 Views)

Re: Is it possible to add properties to pipes and structures through .NET ?

02-06-2014 01:24 AM in reply to: tyronebk

Thanks for your input!

 

So how do you create the properties? Is it through XML files?

 

My problem is that even though I created the parameter and the parameter now appears in the Part Data Structure Properties in civil3D, I can't access it through part.PartData.GetDataFieldBy. When I try this, my new parameter doesn't appear listed...

---------------------------------------

Using Building Design Suite Ultimate 2014
Distinguished Contributor
ruipfbarreiros
Posts: 138
Registered: ‎09-19-2011
Message 9 of 9 (228 Views)

Re: Is it possible to add properties to pipes and structures through .NET ?

02-06-2014 04:38 AM in reply to: ruipfbarreiros

WOW! This is great!

 

I tried your method and it works. Even though it's not listed, if I type the property name in getdatafieldby function I get the value of the custom parameter created!

 

Thanks a lot! That made my day!

---------------------------------------

Using Building Design Suite Ultimate 2014

You are not logged in.

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

Announcements
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


Civil 3D Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for AutoCAD Civil 3D helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Civil 3D

Twitter

Facebook

Blogs