Cancel
Showing results for 
Search instead for 
Did you mean: 

Switch Part tool debug

Phenom
Phenom

Hi,

an Eng-Tips user in this theread http://www.eng-tips.com/viewthread.cfm?qid=351988 has developped and shared an useful tool.

To create a tool that works indipendetly by where it's placed, I've add a string like Joe has suggested, but now it doesn't work, because I'm not a programmer Smiley Happy

Attached the txt (.vb) edited by me.

Can someone help me to debug ?

Thank you...

Using NX 11 / RuleDesigner PDM

8 REPLIES

Re: Switch Part tool debug

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

replace Public Shared JournalDirectory = "path where journal file is saved" & "\"

Re: Switch Part tool debug

Phenom
Phenom

pv3wqm wrote:

replace Public Shared JournalDirectory = "path where journal file is saved" & "\"


This is the original text, but I want to use the :

JournalDirectory = Path.GetDirectoryName(theSession.ExecutingJournal) & "\"

as a Siemens PLM employee has wrote to render the Journal independent.
Thank you...

Using NX 11 / RuleDesigner PDM

Re: Switch Part tool debug

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

I see the problem is "theSession.ExecutingJournal" is being used without intializing the session. Please move  "Public Shared theSession As Session" befor  "Public Shared JournalDirectory = Path.GetDirectoryName(theSession.ExecutingJournal) & "\" " and intialize the session as   Public Shared theSession As Session=Session.GetSession().

 

your code should look like:

 

    Public Shared theSession As Session=Session.GetSession()
    'REPLACE THIS PATH WITH THE LOCATION OF THE JOURNAL FILE AND IMAGES:
    '--------------------------------------------------------
    Public Shared JournalDirectory = Path.GetDirectoryName(theSession.ExecutingJournal) & "\"
   '--------------------------------------------------------

  Public Shared workPart As Part
  Public Shared displayPart As Part

 

 

Re: Switch Part tool debug

Esteemed Contributor
Esteemed Contributor

Another problem is that this only works if run as a journal, if run as a DLL the ExecutingJournal property is empty.

Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX12.0

How to Get the Most from Your Signature in the Community

Re: Switch Part tool debug

Phenom
Phenom
Thank you for the solution that works fine.
I've a question, in this journal attributes can be visualized, but are case sensitive.
For example, if I add 'DESCRIPTION' in the setting as attribute to be visualized, some parts visualize the attribute others no, because we have old parts that have the attribute written so 'Description'. Can the journal be modified in the manner that the attribute capitalized or not is visualized ?
Thank you...

Using NX 11 / RuleDesigner PDM

Re: Switch Part tool debug

Esteemed Contributor
Esteemed Contributor

It seems you can do a search case insensitive, see

SearchOptions.CaseSensitive
Stefan Pendl, Systemmanager CAx, HAIDLMAIR GmbH
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk    Testing: NX12.0

How to Get the Most from Your Signature in the Community

Re: Switch Part tool debug

Phenom
Phenom
Thanks Stefan.
Thank you...

Using NX 11 / RuleDesigner PDM

Re: Switch Part tool debug

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Stefan_Pendl wrote:

Another problem is that this only works if run as a journal, if run as a DLL the ExecutingJournal property is empty.


 

Hello Stefan,

 

Thanks for pointing that out.

 

I have now found that using following (one line) will return the full journal name in all cases.

 

Dim journal_fspec As String = System.Reflection.Assembly.GetExecutingAssembly().Location

This actually solved another similar issue where ExecutingJournal also did not return anything if the journal was run from the journal editor with uncomitted changes.

 

Now it is possible to examine the returned value and determine if the executing code is from VB or dll, and if it is running from %temp%\... (unsaved code from the journal editor) or from another location on disk.

 

HTH,

Joe