×
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

vb step translator- issues on translating layer 0

vb step translator- issues on translating layer 0

vb step translator- issues on translating layer 0

(OP)
I have this journal file that translates parts to step. but when i try to translate an assemble file with surfaces in it and on layer 0 they do not show. Can someone help! Below is the code i have so far.


'Purpose: automate STEP export of the following entities:
'Layer 1 - Solids
'Layer 4 - Solids
'Layer 5 - Solids
'Layer 41 - Lines
'Layer 44 - Points
'Layer 63 - Solids
'eng-tips thread561-321704: Step File Export Automation

'May 11, 2012

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim ufs As UFSession = UFSession.GetUFSession()
Sub Main()

lw.Open()
Dim strCurrentDate As String = Format(Today, "MMddy")
Dim mySelectedObjects As New List(Of NXObject)
Dim tempSelectedObjects() As NXObject
Dim step214File As String
dim pos as integer
Dim outputFile2 As String
Dim outputPath As String = IO.Path.GetDirectoryName(workPart.FullPath)
Dim outputFile As String = IO.Path.GetFileNameWithoutExtension(workPart.FullPath)

'look for position of hyphen
pos = InStr(outputfile, "_dwr")
'if hyphen is found, trim off all characters before hyphen (+1 to trim hyphen as well)
if pos > 0 then
outputfile = left(outputfile, pos - 1)
End if



outputFile = IO.Path.Combine(outputPath, outputFile & "_" & strCurrentDate & ".stp")



Dim STEP214UG_DIR As String = theSession.GetEnvironmentVariableValue("STEP214UG_DIR")
step214File = IO.Path.Combine(STEP214UG_DIR, "ugstep214.def")


'export to STEP214 file
Dim step214Creator1 As Step214Creator
step214Creator1 = theSession.DexManager.CreateStep214Creator()

step214Creator1.SettingsFile = step214File
step214Creator1.ObjectTypes.Solids = True
step214Creator1.ObjectTypes.Surfaces = True
step214Creator1.LayerMask = "1-256"
step214Creator1.InputFile = workPart.FullPath
step214Creator1.OutputFile = outputFile
step214Creator1.FileSaveFlag = False
step214Creator1.ExportSelectionBlock.SelectionScope = ObjectSelector.Scope.SelectedObjects

Dim added1 As Boolean
added1 = step214Creator1.ExportSelectionBlock.SelectionComp.Add(mySelectedObjects.ToArray)

Dim nXObject1 As NXObject
nXObject1 = step214Creator1.Commit()

step214Creator1.Destroy()
lw.Close()

End Sub

Sub AddSolidsFromLayer(ByVal layer As Integer, ByRef objList As List(Of NXObject))

Dim tempselectedobjects() As NXObject
Dim tempSolidObj As Body

tempselectedobjects = workPart.Layers.GetAllObjectsOnLayer(layer)
'filter out the solid bodies on the layer and add them to the export list
For Each obj As NXObject In tempselectedobjects
If TypeOf obj Is Body Then
tempSolidObj = CType(obj, Body)
If tempSolidObj.IsSolidBody Then
objList.Add(tempSolidObj)
End If
End If
Next


End Sub

Function SelectObjects(ByVal prompt As String, _
ByRef selObj As NXObject()) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.All}

Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects( _
prompt, "Select Objects for STEP Export", _
Selection.SelectionScope.WorkPart, _
False, typeArray, selObj)

If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Or _
resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

End Function

End Module



RE: vb step translator- issues on translating layer 0

How is it that you have surfaces on layer 0?

www.nxjournaling.com

RE: vb step translator- issues on translating layer 0

(OP)
my journal file works great! thanks! I have on issue though after running it a few times in a row it locks up my UG screen. Anybody know how to resolve that?

RE: vb step translator- issues on translating layer 0

When you call the stepCreator.Commit method, it starts an external process to convert the geometry. If you start another translation before the first finishes, it can cause problems. Try putting the journal thread to sleep until the output file exists. An example can be seen in thread561-352169: Exporting step files for animations (journal) (see the post timestamped: 20 Sep 13 15:32).

www.nxjournaling.com

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