Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Import multi sheets and title blocks

Status
Not open for further replies.

UGMENTALCASE

Aerospace
Oct 10, 2011
123
After a little help. I don't program and wouldn't know where to start but here goes.
Our NX drawings are done a specific way. One drawing file and multiple sheets. First sheet has a title block imported in has a BOM and notes etc. The following however many sheets have a different title block, same on each sheet though.

The two title block files are named differently. Stored in the same folder.
What I like to do is set up the drawing with X amount of sheets and import all the borders. With anything more than 10 sheets it's quite timely doing this.

I'm looking for a journal or something which will do this for me. So run the journal, select amount of sheets and then it imports the borders, one for the front sheet same for the rest.

Any help, journals I can play with and test or anything would be great.

Thanks in advance
 
Replies continue below

Recommended for you

Possibly write a journal simply to copy a sheet.
Your master file can consist of only two sheets, with their title blocks, then if you needs more sheets copy the second sheet to the amount you need.

Jerry J.
UGV5-NX1884
 
The simplest way to achieve this is record or write macro / journal. Whole way may look like this:
- Add new sheet
- activate new sheet
- start recording macro / journal
- when recording don't use Zoom in / out, scroll or any other unnecessary moves because all moves will be recorder
- then select file -> import -> part
- set Your preferences about layers and etc.
- select part with sheet template
- choose ok and then cancel
- stop record macro / journal

The macros are much faster than journals but there are few disadvantages:
- when You migrate to newer version of NX You have to records them again, because it won't work any more
- Sometimes macros works on one NX and on another not (even if NX versions are the same and computers / Windows are the same)
- There aren't any documentation how to code in macros, so You cannot change code in notepad

Journals are slower than macros (sometimes few seconds on similar operation i.e. coloring the face), but are (almost) version independent. When You write code in NX i.e. 6 it will work on NX 12.

Below is my code for importing A4 sheet to drawing:

Code:
Option Strict Off

Imports System
Imports NXOpen

Module NXJournal

	Public theSession As NXOpen.Session = NXOpen.Session.GetSession()
	Public lw As ListingWindow = theSession.ListingWindow

Sub Main (ByVal args() As String) 

	Dim workPart As NXOpen.Part = theSession.Parts.Work
	Dim displayPart As NXOpen.Part = theSession.Parts.Display

	Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
	markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Import Part")

	lw.open

	Dim DRW_DIR as String = "C:\DRW_TEMPLATES\"
	Dim File_name as String
	Dim DRW_name as String
	
	DRW_name = "ISO_A4.prt"
	
	File_name = IO.path.combine(DRW_DIR, DRW_name)
	
	Dim partImporter1 As NXOpen.PartImporter = Nothing
	partImporter1 = workPart.ImportManager.CreatePartImporter()

	partImporter1.FileName = File_name
	partImporter1.Scale = 1.0
	partImporter1.CreateNamedGroup = True
	partImporter1.ImportViews = False
	partImporter1.ImportCamObjects = False
	partImporter1.LayerOption = NXOpen.PartImporter.LayerOptionType.Original
	partImporter1.DestinationCoordinateSystemSpecification = NXOpen.PartImporter.DestinationCoordinateSystemSpecificationType.Work

	Dim element1 As NXOpen.Matrix3x3 = Nothing
	element1.Xx = 1.0
	element1.Xy = 0.0
	element1.Xz = 0.0
	element1.Yx = 0.0
	element1.Yy = 1.0
	element1.Yz = 0.0
	element1.Zx = 0.0
	element1.Zy = 0.0
	element1.Zz = 1.0

	Dim nXMatrix1 As NXOpen.NXMatrix = Nothing
	nXMatrix1 = workPart.NXMatrices.Create(element1)

	partImporter1.DestinationCoordinateSystem = nXMatrix1

	Dim destinationPoint1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
	partImporter1.DestinationPoint = destinationPoint1

	Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
	markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Import Part Commit")

	Dim nXObject1 As NXOpen.NXObject = Nothing
	nXObject1 = partImporter1.Commit()

	theSession.DeleteUndoMark(markId2, Nothing)

	partImporter1.Destroy()

	lw.close
	
End Sub
End Module

With best regards
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor