Hi,
Is it possible to create a custom property to an existing class in the .NET API? For instance, add a new custom property to the pipe class in civil3D ?
Thanks
|
Hi,
Is it possible to create a custom property to an existing class in the .NET API? For instance, add a new custom property to the pipe class in civil3D ?
Thanks
Not a "property" but you can create an extension method like class.GetCount(). The method would calculate and return the value.
Code:{ public stat int GetCount (this MyClass mc) { /code that counts return count; } }
Last edited by Ed Jobe; 2014-02-03 at 03:24 PM.
That's great!
So, suppose i'd like to determine if a given pipe is the first pipe of its network and then pass that "property" to other functions or procedures. How would I do that?
Then code yourself a pseudo-named IsFirstPipeInNetwork() Extension Method, and implement any applicable CommandMethod, or LispFunction Methods you desire. The resultant compiled assembly need only be NETLOADed into AutoCAD once at session start, or be assembly referenced into other .NET solutions, etc.
Here's another quick example of adding an Extension Method to a native AutoCAD Type (Class).
HTH
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Thanks for your input! I'll try that...
By the way, I managed to create custom parts which have custom parameters (I added those in the .xml files in the pipe catalog). I can see in civil3D that when I select that custom part, I can see and edit the custom parameter that I previously created. However, using the snoopcivil3dDB, that new parameter isn't listed in the database for that part. Does this mean I can't access that parameter through .NET? This would really be of valuable use to me...
You might consider using the built-in tools for creating custom parts... Editing XML behind the scenes is not the same as implementing a custom Typed-Object (a new Class), which is typically derived from BlockReference Type (at some level), and implements custom Properties, Methods, Events, etc.
You might also want to dig through Autodesk University courses on adding custom Parts.
HTH
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
No way to know for sure how Civil 3D works in the back-end regarding the custom parts & XML, but if I had to bet a dollar, the dependent framework that serializes the XML into the appropriate Part Types is not setup to 'read' all custom user entries, etc. into their Property counterpart, but it is possible. It be pleasantly surprised if they went to this level of completeness, knowing what other shortcomings Civil 3D still has in the shipping product.
Separately, there are several things that the MgdDbg plug-ins have not implemented, both MgdDbg, and SnoopC3D (why not MgdDbgC3D, or something of the like, I'll never know?)... See comments here (scroll down).
Cheers
"How we think determines what we do, and what we do determines what we get."
Sincpac C3D ~ Autodesk Exchange Apps
Computer Specs:
Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000
Actually, it is in fact possible to access the custom parameter created in XML!
As it turns out, oStruct.PartData.GetDataFieldBy(customParameter) gets the value set to the customParameter created through XML, even though the parameter doesn't get listed...
This is great!