Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with batch exporting in NX 9.0 1

Status
Not open for further replies.

tthayer

Automotive
Apr 11, 2016
5
Hi All,

I have been trying to automate moving and translating files. I basically have all the code done and I'm using the "ug_inspect.exe -extract_all". I'm trying to export a whole assembly into one parasolid, and it seems like the only thing that is exporting is a body feature that is in the assembly itself.

I was wondering if anyone knows if there is a way to change this? Perhaps somewhere in NX's options? OR maybe in my code?


Code:
@ECHO on

ECHO "%~1"


SET "trufolder=%~1"


SET "moddate=%DATE:~4,2%%DATE:~7,2%%DATE:~12,2%"


SET "filename=%~n1"

SET "shortname=%filename:~0,8%"


SET "datefolder=D:\Quotations\Customer Files Recd\%shortname%\files recd %moddate%"


MD "%datefolder%"


CD /D C:\Program Files\Siemens\NX 9.0\UGII

ug_inspect -extract_all "%trufolder%" "%trufolder%"

move /-y "%trufolder%*.x_b" "%datefolder%\%filename%.x_b"

start "%datefolder%\%filename%.x_b"
 
Replies continue below

Recommended for you

The "ug_inspect -extract" option will only extract bodies contained within the file. Unfortunately for you, the assembly file does not contain the bodies of the components. It contains links to the component part files. When you open the assembly, the components are loaded and positioned accordingly.

I don't think "ug_inspect" is up to the task. However, a journal could be made to open the assembly file, load the components, and export the assembly to a single parasolid file. With a few tweaks, such a journal could be made to work in 'batch' mode, where it is called with the command line utility 'run_journal'.

www.nxjournaling.com
 
Thank you cowski. I will look into that.
 
I have my journal set up and it works great when I have NX open, but I can't seem to pass the data on to the .vb from the .bat. From what I have seen others saying, you can enter "c:\path\run_journal.exe C:\path\journal.vb -args c:\path\part.prt". When I do this I get an error that says "Runtime error: System.nullReferenceException: Object reference not set to an instance of an object. Do I need to add some code to the .vb file to tell it to look for the info from the .bat file?
 
In your journal file, you will need to examine the arguments that have been passed in. Check that "args" contains a valid file path, then open the file so the journal can operate on it.

www.nxjournaling.com
 
I ended up finding a journal on a forum that worked for me. Thank you for your help.


Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations
 
Module ChangeNoteWord
   Dim s As Session = Session.GetSession()
   dim lw as listingwindow = s.listingwindow
	Dim dp as part
	Dim wp as part
 
 Sub Main(args() as string)
	lw.open
	OpenPart(args(0))
   Dim nc As NoteCollection = dp.Notes
   Dim notetext1 As String = "existing word"
   notetext1 = "COOL" 
   Dim notetext2 As String = "new word"
   notetext2 = "TEST"
   Dim notestring() As String
   Dim nolines As Integer = 0
   Dim found1 As Boolean = False
   Dim m1 As Session.UndoMarkId = s.SetUndoMark(Session.MarkVisibility.Visible, "M1")
   For Each a_note As Note In nc
     notestring = a_note.GetText()
     nolines = notestring.Length
     For i As Integer = 0 To nolines - 1
       found1 = notestring(i).Contains(notetext1)
         If found1 = True Then
          notestring(i) = notestring(i).Replace(notetext1, notetext2)
         End If
      Next
      a_note.SetText(notestring)
   Next
   s.UpdateManager.DoUpdate(m1)
 
   Dim partSaveStatus1 As PartSaveStatus
	partSaveStatus1 = dp.SaveAs(("R:\Engineering\Program_Files\temp_file\temp.step"))
	partSaveStatus1.Dispose()
 
 End Sub
 
 sub OpenPart(byval thePart as string)
	Dim basePart1 As BasePart
	Dim partLoadStatus1 As PartLoadStatus
	basePart1 = s.Parts.OpenBaseDisplay(thePart, partLoadStatus1)
 
	dp = s.Parts.Display
	wp = s.parts.work
 
	partLoadStatus1.Dispose()
End Sub
 
 Public Function GetUnloadOption(ByVal dummy As String) As Integer
  GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
 End Function
End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor