Showing results for 
Search instead for 
Do you mean 

Generate RuntimeBehavior by NXOpen

Hi there,


is it possible to generate and insert a RuntimeBehavior in NX by NXOpen?


using System;
using NXOpen;

public class UserBehavior : BehaviorDef

    string myString;

    public string ADDITIONALPROPERTY
       set { myString = value; }
       get { return myString;   }

    public override void Define (IDefinitionContext access)
        // Insert definition code here
    public override void Start (IRuntimeContext context)
        // Insert start up code here
    public override void Stop (IRuntimeContext context)
        // Insert stopping code here
    public override void Step (IRuntimeContext context, double dt)
        // Insert simulation step code here
    public override void Refresh (IRuntimeContext context)
        // Insert simulation refreshing code here. This is called when it is safe
        // to read and change runtime variables outside of the main control loop.
    public override void Repaint ()
        // Insert simulation repainting code here. This is where you use the data
        // taken from the runtime to update the display.

I wanted to write a NXOpen Programm. Which is able to install a UserBehavior with additional Features.

One good reason to do this, would be, that object could be selected by picking them.


UserBehavior myBehavior = new UserBehavior();

myBehavior.ADDITIONALPROPERTY = "The Extension";

RuntimeBehaviorBuilder myRTBehaviorBuilder = workPart.PhysicsManager.RuntimeBehaviors.CreateRuntimeBehaviorBuilder(null); myRTBehaviorBuilder.Name = "RTBehaviorBuilder"; myRTBehaviorBuilder.SetPhysicsObject("Hello", -1, signal); myRTBehaviorBuilder.Source = ?!? /* Can i only insert plain Sourcecode? Why is it not Possible to insert the Userbehavior here? Like new UserBehavior();
myRTBehaviorBuilder.CreateUserBehavior(myUserBehavior());? */ if (myRTBehaviorBuilder.Validate()) { myRTBehaviorBuilder.Commit(); myRTBehaviorBuilder.Destroy(); }


If i am totally wrong please tell me ;-)


I hope someone could give me some hints or additional info how to create UserBehaviors by code.


Kind Regards,



Re: Generate RuntimeBehavior by NXOpen

Depending on what you are trying to achive, you could investigate:

- UDOs (user defined objects)

- Knowledge Fusion


You can also use [Menuscript or manual methods or RTBs/TBRs] to add items to menus / ribbons / toolbars that then call your own API or journal code


And perhaps other ways...

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled