Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Is it possible to create properties in an existing class?

  1. #1
    Login to Give a bone
    0

    Default Is it possible to create properties in an existing class?

    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

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,421
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    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.
    C:> ED WORKING....


    LinkedIn

  3. #3
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    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?

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    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

  5. #5
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    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...

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    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

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,421
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    Quote Originally Posted by ruipfbarreiros370525 View Post
    Does this mean I can't access that parameter through .NET?
    I don't have C3D so I can't tell you what api's are available, but it could just be that snoopdb just didn't implement what you're looking for.
    C:> ED WORKING....


    LinkedIn

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    Quote Originally Posted by Ed Jobe View Post
    I don't have C3D so I can't tell you what api's are available, but it could just be that snoopdb just didn't implement what you're looking for.
    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

  9. #9
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    Quote Originally Posted by BlackBox View Post
    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...
    you are quite right...custom user entries in the xml files do not translate into properties in vb.net...would be really nice though

  10. #10
    Login to Give a bone
    0

    Default Re: Is it possible to create properties in an existing class?

    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!

Page 1 of 2 12 LastLast

Similar Threads

  1. Changing Dimension Properties in an Existing Drawing
    By scoot in forum AutoCAD General
    Replies: 6
    Last Post: 2015-03-17, 04:25 PM
  2. Change Attribute Properties within an existing block...?
    By Brian.Shick123216 in forum AutoLISP
    Replies: 6
    Last Post: 2014-09-10, 11:11 AM
  3. Replies: 1
    Last Post: 2012-06-12, 09:36 PM
  4. Create Template from Existing Project
    By gvluisi in forum Revit MEP - General
    Replies: 6
    Last Post: 2010-06-09, 03:46 PM
  5. i have an existing model that I can't create worksets from
    By dxarhoulakos in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 2
    Last Post: 2008-11-07, 11:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •