Create a square using C#

I generated Add-In using C#.

but I couldn't success to place the square to GC.

Would  you please let me know what I have missing?https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/360/MySquareNode_2E00_cs

Parents
  • Thanks! Edward,

    I could upload the addin but I couldn't place the shape using the Node(I can't see the shape).

    Thanks.

  • No worries,

    What version / Application are you using? It looks like you have the inheritance set to "Feature" instead of a geometric type... for example in the latest release you would want to use:

    MySquareNode : PolyLineNode

    OR

    MySquareNode : GeometricNode (for something generic)



    Actually I just noticed that you haven't added the element into the model. You need to do the following after line 55 before SetElement:

    myShape.AddToModel();

    But you should still inherit the correct base class as a geometric type if you want to use it for anything downstream in the GC Graph

  • Hello YuJin, 

    Ed is right. It would be best to use to use GeometricNode to inherited the properties for Geometry creation. I have updated the tweaked the code a bit. Please try to use the updated one to check whether its working fine or not. 

    Regards,
    Alifur
    https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/360/UpdateMySquareNode_2E00_cs

  • Thanks! Edward and Alfur,

    I create it to OpenBridge 10.09. And Frankly I really hard to find out proper class and functions to develop custom node using C#.

    Attached file is the updated according to your comments.

    Thanks.https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/360/4810_2E00_MySquareNode_2E00_cs

  • Yes unfortunately the documentation and examples provided are not very detailed... I found out a lot of these things out the hard way through a lot of trial and error. Apparently the documentation will be much improved in future releases though so hopefully we will see more people experimenting with the GC API in the near future.

    I notice in your code above that you haven't used the "AddToModel" function, so I would have thought that the element still doesn't show in the model space yet? Whenever you are creating elements via DgnPlatformNET (not using GC API) you will need to first add them into the model for them to be visible, otherwise they are only defined in the file database. Add to model makes the geometry available within the model space, whilst SetElement (GC API function) assigns that geometry to your GC Node, so that it is linked into the GC graph. If you use SetElement only you are assigning invisible geometry. Hope that makes sense!


    Ed

Reply
  • Yes unfortunately the documentation and examples provided are not very detailed... I found out a lot of these things out the hard way through a lot of trial and error. Apparently the documentation will be much improved in future releases though so hopefully we will see more people experimenting with the GC API in the near future.

    I notice in your code above that you haven't used the "AddToModel" function, so I would have thought that the element still doesn't show in the model space yet? Whenever you are creating elements via DgnPlatformNET (not using GC API) you will need to first add them into the model for them to be visible, otherwise they are only defined in the file database. Add to model makes the geometry available within the model space, whilst SetElement (GC API function) assigns that geometry to your GC Node, so that it is linked into the GC graph. If you use SetElement only you are assigning invisible geometry. Hope that makes sense!


    Ed

Children
No Data