Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

SpaceClaim Api C#

TAGGED: ,

    • user deleted
      Subscriber

      Hello, I need help with the spaceclaim api v21 C#. I'm migrating python scripts to .net and I'm having problems:

      1) How to get a body transformation matrix to find out its position;

      2) How to get a body ID;

      3)I can't find in SpaceClaim.Api.V21.dll analogs of methods from phyton MeasureHelper class, such as GetCenterOfMass(), DistanceBetweenObjects() and others. I have connected SpaceClaim.Api.V21.Scripting.dll and I tried to use these methods, but some kind of exception related to serialization is thrown.

      To solve 3 issues, I use Application.RunScript(path, args, out res) from c#, but it is very inconvenient and slow to work

    • Atharv Joshi
      Forum Moderator
      Hi Alex, 
       
      Can you please share the screenshot or the error message that comes up in 3rd question?
      Let me check the other parts of the question and get back to you.  
       
      Thanks and Regards
      Atharv
    • user deleted
      Subscriber

      Hi Atharv.

       

      This python code works:

      This python code works

       

      This same c# code throws an exception on the last line:

      invalid code

      Exception text: "System.Runtime.Serialization.SerializationException: 'Type 'SpaceClaim.NominalBody' in Assembly 'Nom, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7210645d4d5e3a39' is not marked as serializable.'"

    • Atharv Joshi
      Forum Moderator

      Hi Alex,

      If the add-in uses the same AppDomain (this is set in the manifest.xml file):

      image

      Then you can add a reference to the scripting dll (should be located here: "C:\Program Files\ANSYS Inc\v241\scdm\SpaceClaim.Api.V242.Scripting.dll") and then they can make the same calls as scripting. 

      Please check if that helps accessing the call for GetCenterOfMass().

      Thanks and Regards
      Atharv

    • user deleted
      Subscriber

      Hi Atharv. It works, Thanks!!! 

      Now the second question is no longer relevant, but the first one is still interesting to me.

    • Atharv Joshi
      Forum Moderator

      Hi Alex, 

      Thanks for the update! Glad that's it working.

      Will update you on the first part of the question.

      Regards
      Atharv

Viewing 5 reply threads
  • The topic ‘SpaceClaim Api C#’ is closed to new replies.
[bingo_chatbox]