Cancel
Showing results for 
Search instead for 
Did you mean: 

Modelling Time Calculation

Builder
Builder

Hello Everyone,

How to calculate  time from compiling a code in Visual Studio upto the generation of model in NX?

How to achieve achieve this?

Any method for this.

8 REPLIES 8

Re: Modelling Time Calculation

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

language?

Compile time I am unsure of (e.g. compiling source to get a .dll or .exe)

Run time is easier.

 

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


Re: Modelling Time Calculation

Builder
Builder
Hello sir,The code is in C# language.As we know we write code in Visual studio then after compiling .dll forms.We run this .dll in NX and we get  the model generate in NX.So I would like to calculate the time,1. From it compilation in VS upto the generation of model in NXIf not possible above then2. Calculate the time for generation of model within NX itself.



Sent from my Samsung Galaxy smartphone.
Highlighted

Re: Modelling Time Calculation

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Well, the code below is VB...(usable in any journal)

[edited for better syntax correctness]

 

Imports System
Imports System.IO
Imports NXOpen ' not sure ALL of these are required, but I don't have time to figure out the minimal set
Imports NXOpen.CAM
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.UI

Module NXJournal Sub Main Dim theSession As Session = Session.GetSession() Dim theUFSession As UFSession = UFSession.GetUFSession() Dim workPart As Part = theSession.Parts.Work Dim StartTime, EndTime, ElapsedTime As TimeSpan StartTime = DateTime.Now.TimeOfDay ' your code that does whatever here ... EndTime = DateTime.Now.TimeOfDay ElapsedTime = EndTime.Subtract(StartTime) theSession.ListingWindow.Open() theSession.ListingWindow.WriteLine("All Done, total time = " & FormatTime(ElapsedTime))
End Sub
End Module

Should be easy enough to convert.

Note the above does NOT include any time required for Windows to load the .Net libraries, etc.

 

If you have a .BAT file that does the whole process, you can use %TIME% variable to echo the current time at the start / end (make sure to "pause" after the end so you can read it ;-)

 

If you search on-line there may be some way in Visual Studio to capture the compile/link time - Google (or Bing or ...) to see if there is a generic way to do that

 

 

 

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


Re: Modelling Time Calculation

Builder
Builder
Hello Sir,
Getting error at FormatTime
Error is the name 'FormatTime' does not exist in the current context.
How to resolve this?

Re: Modelling Time Calculation

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Probably should have included:

Imports System
Imports System.IO

in the code above, plus the appropriate "end"s

 

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


Re: Modelling Time Calculation

Builder
Builder
Hello Sir,
Even though we include that it does not matter much.
I got one solution.
Solution is I have directly removed that word 'FormatTime'.
Then the code works very fine.
Thanks for sharing

Re: Modelling Time Calculation

Builder
Builder
Hello Sir,
how to use that .BAT file and %TIME% variable?

Re: Modelling Time Calculation

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

RE: %TIME% in .bat:

 

Something like:

@Echo off
Rem   Your comments
Echo Starting at %DATE% %TIME%

Rem do whatever

Echo Ending at %DATE% %TIME%
Pause

 

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