Cancel
Showing results for 
Search instead for 
Did you mean: 

How to access sealed class TxActivateCollisionSetsEvent and TxDeactivateCollisionSetsEvent?

Creator
Creator

Hello,

 

I am confused about the TxDeactivateCollisionSetsEvent and TxActivateCollisionSetsEvent.

When I GoToDefinition in C#, I find that both of them do not have the constructor and are sealed classes.

 

Get the Tipp form here

 

https://social.msdn.microsoft.com/Forums/en-US/613f243f-abe9-4489-bdba-eb52b6e4c97b/how-to-access-se...

 

I just try to create a new Class extenting the Method AddCollisionSetToActivate(TxCollisionPair)

 

namespace TxCenseInterface
{
    public static class ExtentedTxActivateCollisionSetsEvent
    {
         public static void ExtentedAddCollisionsetToActivate1CollisionSet(this Tecnomatix.Engineering.TxActivateCollisionSetsEvent txActivateCollisionSetsEventIn1)
        {
             TxCollisionPairCreationData data = new TxCollisionPairCreationData();
            
             data.Name = "hopeItWorks";
             data.FirstList = xxList;
             data.SecondList = xxList;

             txActivateCollisionSetsEventIn1.AddCollisionSetToActivate(TxApplication.ActiveDocument.CollisionRoot.CreateCollisionPair(collisionPairDataCheckedPart));
        }
    }
}

And in API i wirte

//Here get the eroor again it says 'TxActivateCollisionSetsEvent' does not contain a constructor that takes 0 arguments
TxActivateCollisionSetsEvent txActivateCollisionSetsEvent = new TxActivateCollisionSetsEvent();
txActivateCollisionSetsEvent.ExtentedAddCollisionsetToActivate1CollisionSet();

But from the Tipp New-> Project -> Application Console -> follow the guys Tipp to write

public sealed class MyClass
{
    public void Test()
    {
        Console.WriteLine("Test");
    }
}

public static class MyClassExtender
{
    public static void ExtendedTest(this MyClass instance)
    {
        Console.WriteLine("Starting to test...");
        instance.Test();
        Console.WriteLine("Test finished");
    }
}

public static void Main()
{
    MyClass test = new MyClass();
    test.ExtendedTest();
}

This works fine to print out:

Starting to test...
Test
Test finished

So can somebody help me to solve the problem?

 

Best Regards,

 

Mei

1 REPLY

Re: How to access sealed class TxActivateCollisionSetsEvent and TxDeactivateCollisionSetsEvent?

Pioneer
Pioneer

Hello,

 

1. You cannot inherite any sealed class. The modificator sealed added exacly to avoid the inheritance.

2. I don't know why do you need to create a new instance of the event. Please refer to https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/events/ to learn how to work with events in c#.