Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

"Import IGES and sew bodies" Journal

Status
Not open for further replies.

pittbuck

Computer
May 1, 2017
31
0
0
US
Hello All.

Need some assistance with how to adjust this journal. Currently, this journal brings in the designated IGES file as a number of bodies. I would like it if this could be adjusted to also sew these bodies together, but I'm stuck on what to add. Any help would be great.

Below, I've essentially just copied part of what is in a journal we currently use. Hopefully I didn't miss anything that would need to be referenced for the task I am requesting, but if I did, please let me know and I will find the necessary information.

Thanks in advance!

Code:
' ----------------------------------------------
'   Menu: File->Save As...
' ----------------------------------------------
Dim partSaveStatus3 As PartSaveStatus
partSaveStatus3 = workPart.SaveAs(currentPath & "\" & currentFile & " Insert Name Here")

partSaveStatus3.Dispose()

Dim currentPathAppDwu as string
Dim currentFileAppDwu as string

'currentFile = GetFilePath() & GetFileName() & ".prt"
currentPathAppDwu = GetFilePath()
currentFileAppDwu = GetFileName()

' ----------------------------------------------
'   Menu: File->Import->IGES...
' ----------------------------------------------
Dim markId9 As Session.UndoMarkId
markId9 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim igesImporter1 As IgesImporter
igesImporter1 = theSession.DexManager.CreateIgesImporter()

igesImporter1.CopiousData = IgesImporter.CopiousDataEnum.LinearNURBSpline

igesImporter1.SmoothBSurf = True

igesImporter1.LayerDefault = 1

igesImporter1.GeomFixupTol = 0.0127

igesImporter1.InputFile = currentPath & "\" & currentFile & " DWU.igs"

'Original Iges import setings file
'igesImporter1.SettingsFile = "D:\Program Files\Siemens\NX 8.0\iges\igesimport.def"

'igesImporter1.SettingsFile = DriveLetter & ":\WORKING PRT FILES for FRAME Design\Automation Tasks\igesimport.def"

igesImporter1.ObjectTypes.Curves = True

igesImporter1.ObjectTypes.Surfaces = True

igesImporter1.ObjectTypes.Solids = True

igesImporter1.ObjectTypes.Annotations = True

igesImporter1.ObjectTypes.Structures = True

igesImporter1.SimplifyGeometry = True

igesImporter1.LayerDefault = 1

igesImporter1.InputFile = ""

theSession.SetUndoMarkName(markId9, "Import from IGES Options Dialog")

igesImporter1.InputFile = currentPath & "\" & currentFile & " DWU.igs"

igesImporter1.OutputFile = currentPath & "\" & currentFile & " DWU.prt"

Dim markId10 As Session.UndoMarkId
markId10 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import from IGES Options")

igesImporter1.FileOpenFlag = False

igesImporter1.LayerMask = "0-99999"

Dim nXObject4 As NXObject
nXObject4 = igesImporter1.Commit()

theSession.DeleteUndoMark(markId10, Nothing)

theSession.SetUndoMarkName(markId9, "Import from IGES Options")

igesImporter1.Destroy()
 
Replies continue below

Recommended for you

Try adding the following line before the call to the igesImporter1.Commit method.

Code:
igesImporter1.SewSurfaces = True

However, this might not work as well as you'd like. I've not seen many IGES files that will sew perfectly without a little help.

www.nxjournaling.com
 
cowski,

Thanks. I figured it would be a line similar to that, but I wasn't sure of the exact phrasing of it. And yes. I know all too well how moody sewing IGES files/bodies can be. But as with everything in life, better to try and maybe succeed but possibly fail than to never try at all.
 
Cowski,

Well. It happened. As we both predicted, that journal "worked" on the rarest of circumstances because NX doesn't know how to handle IGES sheets most of the time. SO. I want to try something different. If I import the IGES file manually, is it possible to have a journal that could do the following:

1) Sew all the planes on a designated body (lets say 188)
2) Copy this new sewn body to another layer (layer 180) (I know the coding for that)
3) Delete everything on layer 188 so that all that is left is the copied body on layer 180

I did "record" what I was doing through NX to get a general idea of what the journal may look like and it was over 6000 lines, which makes sense, but I am not sure how to simplify it. Any help would be great from anybody.
 
Are you stuck with this very-very-very old file format or can you try a different format?

"After the initial release of STEP (ISO 10303) in 1994, interest in further development of IGES declined, and Version 5.3 (1996) was the last published standard."
( from Wikipedia)

Even if there might be things that could be improved in NX Iges conversion,
I can imagine that Siemens will not spend any money on development other that pure bugfixes.

Regards,
Tomas


 
Toost,

So you may have just revolutionized how we do stuff here. lol. SO my new question is how do you distinguish which layer to import a STP file to? Here is what I currently do:

Import -> STEP 214
Select File-> OK

How do I put this on a specific layer? It constantly puts it on Layer 1 and I want it to go on 180, so I have to manually move it from 1 to 180.

Thought?

Thanks!!!
 
Hey guys. So here is where I am at now. Presently, I am getting an error that says "Line 159 (and line 178): 'displayPart is not declared. It may be inaccessible due to its protection level." This is in the "GET FILE PATH/NAME" section. Thoughts?

Code:
Option Strict Off
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports NXOpen

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim displayPart As Part = theSession.Parts.Display

Dim i as Integer = 0

' ----------------------------------------------
'   Menu: File->Import->STEP214...
' ----------------------------------------------

'*******************************************
'Following code is used to get the current file name and path for approval file

Dim currentPath as string
Dim currentFile as string

'currentFile = GetFilePath() & GetFileName() & ".prt"
currentPath = GetFilePath()
currentFile = GetFileName()


Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim step214Importer1 As Step214Importer
step214Importer1 = theSession.DexManager.CreateStep214Importer()

step214Importer1.SimplifyGeometry = True

step214Importer1.LayerDefault = 1

step214Importer1.InputFile = currentPath & "\" & currentFile & " DWUCB.stp"

step214Importer1.SettingsFile = "C:\Program Files (x86)\Siemens\NX 8.0\step214ug\step214ug.def"

step214Importer1.ObjectTypes.Curves = True

step214Importer1.ObjectTypes.Surfaces = True

step214Importer1.ObjectTypes.Solids = True

step214Importer1.LayerDefault = 1

step214Importer1.InputFile = ""

theSession.SetUndoMarkName(markId1, "Import from STEP214 Options Dialog")

step214Importer1.InputFile = currentPath & "\" & currentFile & " DWUCB.stp"

step214Importer1.OutputFile = currentPath & "\" & currentFile & " DWUCB.prt"

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import from STEP214 Options")

step214Importer1.FileOpenFlag = False

Dim nXObject1 As NXObject
nXObject1 = step214Importer1.Commit()

theSession.DeleteUndoMark(markId2, Nothing)

theSession.SetUndoMarkName(markId1, "Import from STEP214 Options")

step214Importer1.Destroy()


'*************************************
'Following code makes STP Bodies on layer 1 medium purple and translucent

dim layerNumber as Integer = 1
dim k as Integer = 0


Dim purpleObjects as NXObject()
Dim mypurpleBodies as DisplayableObject()

Dim displayModification2 As DisplayModification
displayModification2 = theSession.DisplayManager.NewDisplayModification()

purpleObjects = workPart.Layers.GetAllObjectsOnLayer(layerNumber)

for each someObject as NXObject in purpleObjects
	'The Following Line is Key. "NXOpen.____" will determine whether points, bodies, lines, or whatever are selected.
    if someObject.GetType.ToString = "NXOpen.Body" then
        redim preserve mypurpleBodies(k)
        mypurpleBodies(k) = someObject
        k += 1
    end if
next

if k>0
	With displayModification2
    		.NewColor = 127
    		.NewTranslucency = 50        'only applies to faces; you can set this for points, but it will have no effect
    		.Apply(mypurpleBodies)
    		.Dispose
	End With
end if

displayModification2.Dispose()

'*************************************************************************
'Moving Objects from layer 1 to 180
'*************************************************************************

'Declaring variables for moving objects to 180
Dim MoveObjects as NXObject()
Dim myMoveBodies as DisplayableObject()

'displayModification for Moving objects
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()

MoveObjects = workPart.Layers.GetAllObjectsOnLayer(1)

for each someObject as NXObject in MoveObjects
    if someObject.GetType.ToString = "NXOpen.Body" then
        redim preserve myMoveBodies(i)
        myMoveBodies(i) = someObject
        i += 1
    end if
next

With displayModification1
    'move layers with a display modification
    .NewLayer = 180
    .Apply(myMoveBodies)
    .Dispose
End With

displayPart = nothing
displayPart = theSession.Parts.Display

end sub

Function GetFileName()
	Dim strPath as String
	Dim strPart as String
	Dim pos as Integer
	
	'get the full file path
	strPath = displayPart.fullpath
	'get the part file name
	pos = InStrRev(strPath, "\")
	strPart = Mid(strPath, pos + 1)
	
	strPath = Left(strPath, pos)
	'strip off the ".prt" extension
	strPart = Left(strPart, Len(strPart) - 12)
	
	GetFileName = strPart
End Function

Function GetFilePath()
	Dim strPath as String
	Dim strPart as String
	Dim pos as Integer
	Dim pos2 as Integer
	
	'get the full file path
	strPath = displayPart.fullpath
	'get the part file name
	pos = InStrRev(strPath, "\")
	strPart = Mid(strPath, pos + 1)
	
	strPath = Left(strPath, pos - 1)
	'strip off the ".prt" extension
	strPart = Left(strPart, Len(strPart) - 12)

	'pos2 = InStrRev(strPath, "\")
	'strPath = Left(strPath, pos2)

	
	GetFilePath = strPath
End Function

End Module
 
Status
Not open for further replies.
Back
Top