Journal vs Macro - Journal is much slower

I created a macro to change the transparency of a part to 60%, and I assigned the macro to a button. I did the exact same task using journal.

When I click on the macro button, it immediately changes the transparency. However, when I click on the journal button, it takes around 2 second to run the task. They both successfully changes the transparency. But, I am wondering why journal is much slower.

I tried and compiled the journal to a dll, but it shows exactly same slowness.

I appreciate any comment in this regard.

If you run your code as a "journal" file, the code needs to be compiled and loaded into memory before it is run. The compiling and loading step can take a moment or two. Since you have compiled your code to a dll file, it no longer needs to be compiled, but it still needs to be loaded into memory. To speed your code even more, you can change the "unload option" to "at termination", recompile your code and place the resulting dll file into the NX "startup" folder. Doing so will load your code into memory when NX loads and it will stay in memory until the NX session is terminated.

Many thanks for your response. I tried your solution and it works perfectly. However, it seems putting the dll in the startup folder (where I have .tbr files) does not work. No matter if I copy the dll in the startup folder or not, the first run is much slower that the next. Do you have any comment on this? I checked the log and here is what I found about my dll:


ManagedLoader.Load: my-dll-full-pth Name:my-dll-full-name
There are no context policies.

AppBase: my-startup-folder-full-path
Loaded assembly: mNX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null from my-dll-full-pth
*** NOTE:: in line 1481 of o:\ugnx100\ip24\src\syss\shar\ind\sys.c at Mon Feb 08 12:25:51 2016 Eastern Standard Time
+++ Cannot find method ufsta in image

Thanks in advance.

When you execute your code, are you calling the dll in the startup folder or a copy of the dll in a different location?

I actually tried both. I didn't realize any difference between them. In both cases, the first run is slower than next runs. I am just using slightly modified version of a journal as below. Shouldn't I have some sort of startup method as well as the main action?


using System;
using NXOpen;

public class mTest
{
public static void Main()
{
NXOpen.Session theSession = NXOpen.Session.GetSession();
NXOpen.Part workPart = theSession.Parts.Work;
NXOpen.Part displayPart = theSession.Parts.Display;
// ----------------------------------------------
// Menu: Edit->Object Display...
// ----------------------------------------------
NXOpen.Session.UndoMarkId markId1;
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit Object Display");

NXOpen.DisplayModification displayModification1;
displayModification1 = theSession.DisplayManager.NewDisplayModification();

displayModification1.ApplyToAllFaces = true;

displayModification1.ApplyToOwningParts = false;

displayModification1.NewTranslucency = 80;

NXOpen.DisplayableObject[] objects1 = new NXOpen.DisplayableObject[1];
UI theUI = UI.GetUI();

objects1[0] = (NXOpen.Assemblies.Component)theUI.SelectionManager.GetSelectedTaggedObject(0);
displayModification1.Apply(objects1);

displayModification1.Dispose();

}
public static int GetUnloadOption(string dummy) { return (int)NXOpen.Session.LibraryUnloadOption.AtTermination; }
}