×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Parasolid export version

Parasolid export version

Parasolid export version

(OP)
Is it possible in NX9 to set a default parasolid export version?
I see customer defaults for everything except parasolid.
I am exporting parasolids quite often using an earlier version due to the capabilities of the software I am importing it in to.

Thanks,
Bart

RE: Parasolid export version

I don't know of a way to set the default parasolid export version, but a journal could be used to accomplish what you need.

www.nxjournaling.com

RE: Parasolid export version

No, there is no way to preset the default version on an exported Parasolid file. Perhaps a journal or macro could be written to take care of that.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Digital Factory
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.

RE: Parasolid export version

What parasolid version do you need to export to?

www.nxjournaling.com

RE: Parasolid export version

Hello everyone.

I have similar problem with NX 9. Not every software can read parasolid from NX 9or above. Sometimes there is also need to import something to earlier version of NX. So I wanna use this function:

CODE

ufs.Ps.ExportLinkedData(taglist, n_tags, exportFileName, 240, link_fnc , n_unexported, unexported_tags) 


but I don't now what use for:
  • n_tags
  • link_fnc
  • n_unexported
  • unexported_tags
When I use 0 I receive an error. I using modified code from this site:Link

anyone can help me solve this problem?

With best regards
Michael

RE: Parasolid export version

  • n_tags = the number of items in the tag list
  • link_fnc = Nothing (VB) or Null (C#)
  • n_unexported = declare a variable of type integer and pass it in, the function will use it as output
  • unexported_tags = Nothing (or Null) if you do not need error info, otherwise pass in an array of UF_PS_unexported_t structures (the function will use the array as output)

Below is a simplified version of a subroutine that I use.

CODE

Sub PsExport(ByVal theBodies As List(Of Body), ByVal PsVersion As Integer, ByVal exportFileName As String)

        'parasolid export
        Dim exportTags(theBodies.Count - 1) As NXOpen.Tag
        For i As Integer = 0 To theBodies.Count - 1
            exportTags(i) = theBodies.Item(i).Tag
        Next

        Dim numUnexported As Integer

        Try
            theUfSession.Ps.ExportLinkedData(exportTags, exportTags.Length, exportFileName, PsVersion, Nothing, numUnexported, Nothing)

        Catch ex As NXException
            MsgBox(ex.Message)

        End Try

    End Sub 

www.nxjournaling.com

RE: Parasolid export version

Thank Cowski for Your support. I have adopted Your code but it doesn't create the parasolid file. Below is my updated code.

CODE

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports Microsoft.VisualBasic
 
Module NXJournal
    Sub Main()
 
       Dim theSession As Session = Session.GetSession()
       Dim ufs As UFSession = UFSession.GetUFSession()
       Dim workPart As Part = theSession.Parts.Work
       Dim displayPart As Part = theSession.Parts.Display
       Dim lw As ListingWindow = theSession.ListingWindow
       Dim mySelectedObjects() As NXObject
       Dim myResponse As Selection.Response
 
       Dim tagList() As NXOpen.Tag
       Dim exportFileName As String = Nothing
       Dim exportFileName1 As String = Nothing
       Dim nazwa as string
       Dim path As String 
       'Dim PSversion as integer = 240	
	

       Dim i As Integer = 0
 
       lw.Open()
       myResponse = SelectObjects(mySelectedObjects)
       If (myResponse = Selection.Response.Cancel) OrElse (myResponse = Selection.Response.Back) Then
           'user canceled selection, exit journal
           Exit Sub
       End If
 
       ReDim tagList(mySelectedObjects.GetUpperBound(0))
       For i = 0 To mySelectedObjects.GetUpperBound(0)
           tagList(i) = mySelectedObjects(i).Tag
       Next
 
       'return the full path of the work part

       exportFileName = workPart.FullPath
       nazwa = workPart.Leaf
      
        exportFileName = exportFileName.Remove(exportFileName.Length - (workPart.Leaf.length + 4))

	path = exportfilename + "step"

	If(Not System.IO.Directory.Exists(Path)) Then
    		System.IO.Directory.CreateDirectory(Path)
	End If

        exportFileName = "step\" + nazwa + ".x_t"

	'msgbox(exportFileName)

       'if this file already exists, delete it
       If My.Computer.FileSystem.FileExists(exportFileName) Then
           My.Computer.FileSystem.DeleteFile(exportFileName)
       End If
 
        Dim numUnexported As Integer

       Try
           'ufs.Ps.ExportData(tagList, exportFileName)
	   ufs.Ps.ExportLinkedData(Taglist, Taglist.Length, exportFileName, 220, Nothing, numUnexported, Nothing)

       Catch ex As NXException
           lw.WriteLine("*** ERROR ***")
           lw.WriteLine(ex.ErrorCode.ToString & " : " & ex.Message)
       End Try
 
       lw.Close()
 
    End Sub
 
   Function SelectObjects(ByRef selobj() As NXObject) As Selection.Response
 
       Dim theUI As UI = UI.GetUI
       Dim prompt as String = "Select Solid Bodies"
       Dim title As String = "Selection"
       Dim includeFeatures As Boolean = False
       Dim keepHighlighted As Boolean = False
       Dim selAction As Selection.SelectionAction = _
           Selection.SelectionAction.ClearAndEnableSpecific
 
       Dim scope As Selection.SelectionScope = _
           Selection.SelectionScope.AnyInAssembly
       Dim selectionMask_array(0) As Selection.MaskTriple
 
       With selectionMask_array(0)
           .Type = UFConstants.UF_solid_type
           .Subtype = 0
           .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
       End With
 
       Dim resp As Selection.Response = _
           theUI.SelectionManager.SelectObjects( _
           prompt, title, scope, selAction, _
            includeFeatures, keepHighlighted, _
            selectionMask_array, selobj)
 
       Return resp
 
   End Function
 
End Module 

It create the folder but nothing else. Do You have any suggestions?

With best regards
Michael

RE: Parasolid export version

CODE

exportFileName = exportFileName.Remove(exportFileName.Length - (workPart.Leaf.length + 4))

	path = exportfilename + "step"

	If(Not System.IO.Directory.Exists(Path)) Then
    		System.IO.Directory.CreateDirectory(Path)
	End If

    exportFileName = "step\" + nazwa + ".x_t" 

The "path" variable is created from "exportFileName", but then most of the directory information is removed from "exportFileName" before the export happens. If you are not getting any error messages from the code, I'd assume that the files are being exported, just not to the location that you expect.

Perhaps something like this would work:

CODE

path = IO.Path.Combine(IO.Path.GetDirectoryName(workPart.FullPath), "step")

	If(Not System.IO.Directory.Exists(Path)) Then
    		System.IO.Directory.CreateDirectory(Path)
	End If

    exportFileName = IO.Path.Combine(path, nazwa & ".x_t") 

www.nxjournaling.com

RE: Parasolid export version

Thanks Cowski, Your code work perfect. I looked for error in function not in my code. I looked in my code once more and I think used older version of my code, where export of parasolid was not solved yet.
I'm thinking to write journal which will process whole assembly and in each part select all solid bodies on layer 1 and then export this part to parasolid. Have You ever tried \thought about it?

With best regards
Michael

RE: Parasolid export version

I have several journals that process the entire assembly in some way, but I don't have one that exports parasolids from the assembly.

www.nxjournaling.com

RE: Parasolid export version

I have made some changes in code, but I receive an error. I think the problem is with taglist.
I changed:

CODE

myResponse = SelectObjects(mySelectedObjects)
       If (myResponse = Selection.Response.Cancel) OrElse (myResponse = Selection.Response.Back) Then
           'user canceled selection, exit journal
           Exit Sub
       End If
 
       ReDim tagList(mySelectedObjects.GetUpperBound(0))
       For i = 0 To mySelectedObjects.GetUpperBound(0)
           tagList(i) = mySelectedObjects(i).Tag
       Next 

To:

CODE

allObjects = workPart.Layers.GetAllObjectsOnLayer(1)
	 for each someObject as NXObject in allObjects
	    if someObject.GetType.ToString = "NXOpen.BODY" then
  		redim preserve taglist(i)
                i += 1
   	 end if
        Next 

Do You have any suggestions?

With best regards
Michael

RE: Parasolid export version

Quote (niedzviedz)

I have made some changes in code, but I receive an error.

It always helps to know the nature of the error. Is a specific error code/message returned or is the code just not doing what you expect it to?

In the code that you posted, it doesn't look like the body tag is added to the array. If this is the case, I'd expect nothing gets exported...

To make the programming easier, I'd suggest using a list object in this case. It would avoid the "redim preserve" calls and eliminate the need for the element counter variable "i". The list .Add method will handle resizing the list for you and you can use the .ToArray method when you need an array instead of a list (in the .ExportLinkedData function).

www.nxjournaling.com

RE: Parasolid export version

The error is"

Quote:

system.nullreferenceexception object reference not set to an instance of an object

When I add this line:

CODE

Taglist(i) = someObject 

I get error:

Quote:

cannot convert nxopen.nxobject to nxopen.tag

With best regards
Michael

RE: Parasolid export version

The code that you posted attempts to add an NXObject to an array declared to hold Tags. Try this:

CODE

tagList(i) = someObject.Tag 

www.nxjournaling.com

RE: Parasolid export version

Thanks Cowski, it solve one problem but there still is "system.nullreferenceexception object reference not set to an instance of an object (...) line 85"

Which is:
ufs.Ps.ExportLinkedData(Taglist, Taglist.Length, exportFileName, PSversion, Nothing, numUnexported, Nothing)

What is Taglist in this command?

With best regards
Michael

RE: Parasolid export version

Quote (niedzviedz)

What is Taglist in this command?

The tagList variable is the array of body tags that you want to export. You might want to check that the taglist holds at least one item before calling the export function.

www.nxjournaling.com

RE: Parasolid export version

Thank Cowski, I have made some changes. Now it select all bodies in part, but there are 2 problems:
  • It's works for all layers, not only for layer 1
  • After import parasolid, I receive many parts, so it's useless
Here is my code:

CODE

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
 
Module NXJournal
    Sub Main()
 
       Dim theSession As Session = Session.GetSession()
       Dim ufs As UFSession = UFSession.GetUFSession()
       Dim workPart As Part = theSession.Parts.Work
       Dim displayPart As Part = theSession.Parts.Display
       Dim lw As ListingWindow = theSession.ListingWindow
       Dim mySelectedObjects() As NXObject
       Dim myResponse As Selection.Response
       

      ' Dim tagList() As NXOpen.Tag
       Dim exportFileName As String = Nothing
       Dim exportFileName1 As String = Nothing
       Dim nazwa as string
       Dim path As String 
       Dim PSversion as integer = 240
       Dim layerNumber as Integer = 1	
       Dim i As Integer = 0
       Dim theBodies As New List(Of Body) 

    Dim inx As Integer = 0
    Dim n As String = vbCrLf

    Dim bodies As BodyCollection = workPart.Bodies
    Dim bodyCount As Integer = bodies.ToArray.Length
    Dim tagList(bodyCount - 1) As NXOpen.Tag
       
    Do
        tagList(inx) = workPart.Bodies.ToArray(inx).Tag
        inx = inx + 1

    Loop Until inx = bodyCount

       exportFileName = workPart.FullPath
       nazwa = workPart.Leaf
      
       path = IO.Path.Combine(IO.Path.GetDirectoryName(workPart.FullPath), "step")

	If(Not System.IO.Directory.Exists(Path)) Then
    		System.IO.Directory.CreateDirectory(Path)
	End If

	exportFileName = IO.Path.Combine(path, nazwa & ".x_t") 
	
       'if this file already exists, delete it
       If My.Computer.FileSystem.FileExists(exportFileName) Then
           My.Computer.FileSystem.DeleteFile(exportFileName)
       End If
 
        Dim numUnexported As Integer
       Try
       ufs.Ps.ExportLinkedData(Taglist, Taglist.Length, exportFileName, PSversion, Nothing, numUnexported, Nothing)

       Catch ex As NXException
           lw.WriteLine("*** ERROR ***")
           lw.WriteLine(ex.ErrorCode.ToString & " : " & ex.Message)
       End Try
 
       lw.Close()
 
    End Sub
End Module 

With best regards
Michael

RE: Parasolid export version

Quote (niedzviedz)

It's works for all layers, not only for layer 1

Not surprising, since nowhere in the code do you check the layer of the body...
There are at least two ways to get the bodies on a particular layer.
  • iterate through the body collection, check the layer of the body, if it is on the desired layer, add it to the list
  • use .GetAllObjectsOnLayer (as in a previous snippet you posted), then look for objects of type "Body", add those to the list

www.nxjournaling.com

RE: Parasolid export version

Thank Cowski. I have question, how to check if body is on desired layer?
I also tried second option but with no results. It seems that body wasn't selected, because I received an error in part of code which is respond to export parasolid. I'm not sure, because I don't now how to check this.
I also tried this:

CODE

allObjects = workPart.Layers.GetAllObjectsOnLayer(1) 
   	For Each temp As body In allObjects
            theBodies.Add(temp) 
	 Next 

And got an error: "System.invalidcastexeption: You cannot project type of object 'NXOpen.face' to type 'NXOpen.body' (...) line 48" Which is "for each temp As body In allObjects"

Any suggestion?

With best regards
Michael

RE: Parasolid export version

If you iterate through the body collection, the code might look like this:

CODE

For each tempBody as Body in part.Bodies
    if tempBody.Layer = 1 then
        theBodies.Add(tempBody)
    end if
Next 

We can define tempBody as type of Body because we know there are only body objects in the body collection. The body collection contains both solid and sheet bodies, we can differentiate between the two with the .IsSolidBody or .IsSheetBody properties of the body object.



If you use the .GetAllObjectsOnLayer command, the code might look like:

CODE

For each temp as DisplayableObject in allObjects
    if TypeOf(temp) is Body then
        theBodies.Add(temp)
    end if
Next 

In this case, various object types can be returned (anything that can be shown on a layer); all of the objects shown in the graphics window derive from the DisplayableObject type, so we use that in the For each loop. We can test for the specific object type with the TypeOf command.

www.nxjournaling.com

RE: Parasolid export version

Thank You.

I try this to be sure, if something is selected but I get an error:

CODE

lw.open
	For each tempBody as Body in workpart.Bodies
 	   if tempBody.Layer = 1 then
 	       theBodies.Add(tempBody)
 	   end if
	Next 

        For Each temp As Body In theBodies  
            lw.WriteLine(temp.Tag.ToString)  
        Next 

Quote:

37441
*** ERROR ***
650004 : Incorrect object for this operation.

With best regards
Michael

RE: Parasolid export version

The .net exception mechanism always reports the line(s) of code in which an unhandled error occurs. It would be helpful if you could clearly indicate which line of code was reported. Perhaps highlight the posted line of code in which the error occurred.

Also, it would be helpful to know how "theBodies" and "workPart" are defined in your code.

www.nxjournaling.com

RE: Parasolid export version

This is error from listing window, so there wasn't any line no. It appears when I uncomment lw.writeline(temp.Tag.ToString).
Below is actual code:

CODE

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
 
Module NXJournal
    Sub Main()
 
       Dim theSession As Session = Session.GetSession()
       Dim ufs As UFSession = UFSession.GetUFSession()
       Dim workPart As Part = theSession.Parts.Work
       Dim displayPart As Part = theSession.Parts.Display
       Dim lw As ListingWindow = theSession.ListingWindow
     

'       Dim tagList() As NXOpen.Tag
       Dim exportFileName As String = Nothing
       Dim exportFileName1 As String = Nothing
       Dim nazwa as string
       Dim path As String 
       Dim PSversion as integer = 240
       Dim layerNumber as Integer = 1	
       Dim i As Integer = 0
       Dim theBodies As New List(Of Body) 
       Dim inx As Integer = 0

	lw.open

	For each tempBody as Body in workpart.Bodies
 	   if tempBody.Layer = 1 then
 	       theBodies.Add(tempBody)
 	   end if
	Next 

'        For Each temp As Body In theBodies  
'            lw.WriteLine(temp.Tag.ToString)  
'        Next 

    Dim bodyCount As Integer = thebodies.ToArray.Length
    Dim tagList(bodyCount - 1) As NXOpen.Tag

    Do
        tagList(inx) = workPart.Bodies.ToArray(inx).Tag
        inx = inx + 1

    Loop Until inx = bodyCount

'       ReDim tagList(thebodies.GetUpperBound(0))
'       For i = 0 To thebodies.GetUpperBound(0)
'           tagList(i) = thebodies(i).Tag
'       next

'*****************************************************************************************************************
       exportFileName = workPart.FullPath
       nazwa = workPart.Leaf
      
       path = IO.Path.Combine(IO.Path.GetDirectoryName(workPart.FullPath), "step")

	If(Not System.IO.Directory.Exists(Path)) Then
    		System.IO.Directory.CreateDirectory(Path)
	End If

	exportFileName = IO.Path.Combine(path, nazwa & ".x_t") 
	
       'if this file already exists, delete it
       If My.Computer.FileSystem.FileExists(exportFileName) Then
           My.Computer.FileSystem.DeleteFile(exportFileName)
       End If
        Dim numUnexported As Integer
       Try
       ufs.Ps.ExportLinkedData(Taglist, Taglist.Length, exportFileName, PSversion, Nothing, numUnexported, Nothing)
       Catch ex As NXException
           lw.WriteLine("*** ERROR ***")
           lw.WriteLine(ex.ErrorCode.ToString & " : " & ex.Message)
       End Try
        lw.Close()
     End Sub
 End Module 

It's working but not I desired. It's generating parasolid, but when I open It in NX I only see body from layer 99 (reference set "FALSE").
When I add another body on layer 1, then in imported parasolid I have assembly with 2 parts, one with false, and second with true (first body). I think the code which respond for taglist is broken.
I commented "Redim (..)" from the first code, because I received an error:

Quote:

"Element '.GetUpperBound' is not the member of element 'system.collections.generic.list(of NXOpen.Body)' "

With best regards
Michael

RE: Parasolid export version

If the error message shows up in the listing window (and not in a .net error message box) then it must be coming from this portion of your code:

CODE

Try
    ufs.Ps.ExportLinkedData(tagList, tagList.Length, exportFileName, PSversion, Nothing, numUnexported, Nothing)
Catch ex As NXException
    lw.WriteLine("*** ERROR ***")
    lw.WriteLine(ex.ErrorCode.ToString & " : " & ex.Message)
End Try 

The error is caught and handled in your code. The error occurs in the .ExportLinkedData function and your code responds by writing the error message to the listing window. The fact that the error occurred after you uncommented the "lw.writeline" code is most likely just coincidental.

Ultimately, the .ExportLinkedData function needs an array of body tags. Your code to retrieve the body tags is problematic. It ignores the bodies that you have found on layer 1 (if any) and indiscriminately uses the first n bodies that it finds in the body collection. Since we only need the body tags and not the bodies themselves, we can dispense with the list of Bodies and use a list of Tags instead.

CODE

Dim theBodyTags as New List(Of Tag)

For Each tempBody As Body In workPart.Bodies
    If tempBody.Layer = 1 Then
        theBodyTags.Add(tempBody.Tag)
    End If
Next

lw.WriteLine("number of bodies found: " & theBodyTags.Count.ToString)

if theBodyTags.Count = 0 then
    'no bodies to export
    return
end if 

Then in the .ExportLinkedData function, we can use:

CODE

ufs.Ps.ExportLinkedData(theBodyTags.ToArray, theBodyTags.Count, exportFileName, PSversion, Nothing, numUnexported, Nothing) 



p.s. Don't run this code in an assembly file; it won't run as you expect. First get it working in a part file.

www.nxjournaling.com

RE: Parasolid export version

Thanks Cowski, You are Great, now it's wok perfect. Now I start with whole assembly journal.

I wish I could know VB like You know. I bought book "Beginning Visual Basic 2005" Thearon Wills, but I haven't much time to study it.

With best regards
Michael

RE: Parasolid export version

Ok, here is my code, maybe it will be useful to someone else in the future:

CODE

'Journal to recursively walk through the assembly structure
' will run on assemblies or piece parts
' will step through all components of the displayed part
'NX 7.5, native
'NXJournaling.com February 24, 2012
 
Option Strict Off
 
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies
Imports System.Collections.Generic
 
Module NXJournal
 
    Public theSession As Session = Session.GetSession()
    Public ufs As UFSession = UFSession.GetUFSession()
    Public lw As ListingWindow = theSession.ListingWindow


    Sub Main()

    Dim workPart As Part = theSession.Parts.Work
    Dim dispPart As Part = theSession.Parts.Display
 
    lw.Open
    Try
        Dim c As ComponentAssembly = dispPart.ComponentAssembly

	if not IsNothing(c.RootComponent) then

            ReportComponentChildren(c.RootComponent, 0)
        else

            lw.WriteLine("Part has no components")

        end if
    Catch e As Exception
        theSession.ListingWindow.WriteLine("Failed: " & e.ToString)
    End Try
    lw.Close
 
    End Sub
 
'**********************************************************
    Sub reportComponentChildren( ByVal comp As Component, _
        ByVal indent As Integer)

	Dim dispPart As Part = theSession.Parts.Display
        Dim lw As ListingWindow = theSession.ListingWindow

       Dim tagList() As NXOpen.Tag
       Dim exportFileName As String = Nothing
       Dim exportFileName1 As String = Nothing
       Dim nazwa as string
       Dim path As String 
       Dim PSversion as integer = 240
       Dim layerNumber as Integer = 1	
       Dim i As Integer = 0
       Dim theBodies As New List(Of Body) 
       Dim inx As Integer = 0
       Dim theBodyTags as New List(Of Tag)

	
        For Each child As Component In comp.GetChildren()
	
             If LoadComponent(child) Then

		Dim MyPart As Part = child.Prototype.OwningPart 

	lw.open

	theBodyTags.clear()

	For each tempBody as Body in mypart.Bodies
 	  if tempBody.Layer = 1 then
 	       theBodytags.Add(tempBody.tag)
	   end if
	Next 

 

'	lw.WriteLine("number of bodies found: " & theBodyTags.Count.ToString)


	if theBodyTags.Count = 0 then
	    lw.writeline("no bodies to export")
	    return
	end if 
    
	exportFileName = myPart.FullPath
        nazwa = myPart.Leaf
      
       path = IO.Path.Combine(IO.Path.GetDirectoryName(myPart.FullPath), "step")


	If(Not System.IO.Directory.Exists(Path)) Then
    		System.IO.Directory.CreateDirectory(Path)
	End If

	exportFileName = IO.Path.Combine(path, nazwa & ".x_t") 
	

       'if this file already exists, delete it
       If My.Computer.FileSystem.FileExists(exportFileName) Then
           My.Computer.FileSystem.DeleteFile(exportFileName)
       End If
 
       Dim numUnexported As Integer

       Try

       ufs.Ps.ExportLinkedData(theBodyTags.ToArray, theBodyTags.Count, exportFileName, PSversion, Nothing, 

numUnexported, Nothing) 

       Catch ex As NXException
           lw.WriteLine("*** ERROR ***")
           lw.WriteLine(ex.ErrorCode.ToString & " : " & ex.Message)
       End Try
 
       lw.Close()
 	 		
		
  	            Else

                'component could not be loaded

            End If

            reportComponentChildren(child, indent + 1)
        Next
    End Sub

    Private Function LoadComponent(ByVal theComponent As Component) As Boolean
 
        Dim thePart As Part = theComponent.Prototype.OwningPart
 
        Dim partName As String = ""
        Dim refsetName As String = ""
        Dim instanceName As String = ""
        Dim origin(2) As Double
        Dim csysMatrix(8) As Double
        Dim transform(3, 3) As Double
 
        Try
            If thePart.IsFullyLoaded Then
                'component is fully loaded
            Else
                'component is partially loaded
            End If
            Return True
        Catch ex As NullReferenceException
            'component is not loaded
            Try
                ufs.Assem.AskComponentData(theComponent.Tag, partName, refsetName, instanceName, origin, 

csysMatrix, transform)
 
                Dim theLoadStatus As PartLoadStatus
                theSession.Parts.Open(partName, theLoadStatus)
 
                If theLoadStatus.NumberUnloadedParts > 0 Then
 
                    Dim allReadOnly As Boolean = True
                    For i As Integer = 0 To theLoadStatus.NumberUnloadedParts - 1
                        If theLoadStatus.GetStatus(i) = 641058 Then
                            'read-only warning, file loaded ok
                        Else
                            '641044: file not found
                            lw.WriteLine("file not found")
                            allReadOnly = False
                        End If
                    Next
                    If allReadOnly Then
                        Return True
                    Else
                        'warnings other than read-only...
                        Return False
                    End If
                Else
                    Return True
                End If
 
            Catch ex2 As NXException
                lw.WriteLine("error: " & ex2.Message)
                Return False
            End Try
        Catch ex As NXException
            'unexpected error
            lw.WriteLine("error: " & ex.Message)
            Return False
        End Try
 
    End Function

'**********************************************************
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function
'**********************************************************
 
End Module 

With best regards
Michael

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources