Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX1872 - Looking for a journal

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
Does anyone have a journal that imports a part file but prompts the user to select a position to bring it in?

I want to import a file with notes to add to a Title Block. However the title blocks location will change depending on the length of the sheet. So I was hoping to prompt the user to select the bottom right corner of the title block. However, the prompt is not important. Just so long as the user can pick the location for the file to be imported to.

Thanks in advance

 
Replies continue below

Recommended for you

For what it is worth, we have a program that brings in a note block, then it places the note block at a certain X Y depending on sheet size. This makes it nice to have our standard notes block in the same position in most of the drawings. It may get moved later but at least it starts in the same place. We use teamcenter so I do not know if you need code with or without teamcenter.
 
Thanks for responding SDETERS.

This would be for Team Center, however if this is code that is already written and you dont mind sharing it, I would not mind having both in case the Native version came in handy later on. Plus seeing the comparison of the two might help me understand more.

I have learned a lot of different things and have no problem self teaching for the most part. However, this VB code stuff just doesnt seem to stick in my mind. It is coming along ever so slowly... and frustratingly. lol
 
See Code below. You will have to go in and change what you want imported. Find this line "@DB/ST-Note-Block_english/P" and edit it. You may have to edit the sheet "a" area also depends if you use metric or inches.
Hopefully it will work for you. I am not a VB guy either but I play one when I try to hack one. ha. Hope this will give ya a good start.

Hope this will work for you. If Not someone else may be able to help trouble shoot if you get some errors.

Code:
' NX 7.5.4.4
' Journal created by xxxxxxxxxx on Wed May 09 14:03:06 2012 Central Daylight Time
' journal Copied from above on 03-15-13 xxxxxxxx to insert a standard note block.
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main

        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work

        Dim displayPart As Part = theSession.Parts.Display

        ' ----------------------------------------------
        '   Menu: File->Import->Part...
        ' ----------------------------------------------
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")

        theSession.SetUndoMarkName(markId1, "Import Part Dialog")

        ' ----------------------------------------------
        '   Dialog Begin Import Part
        ' ----------------------------------------------
        Dim markId2 As Session.UndoMarkId
        markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Import Part")

        theSession.DeleteUndoMark(markId2, Nothing)

        theSession.SetUndoMarkName(markId1, "Import Part")

        theSession.DeleteUndoMark(markId1, Nothing)

        theSession.Parts.SetNonmasterSeedPartData("@DB/ST-Note-Block_english/P")

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

        Dim importer1 As Importer
        importer1 = workPart.ImportManager.CreatePartImporter()

        Dim partImporter1 As PartImporter = CType(importer1, PartImporter)

        partImporter1.FileName = "@DB/ST-Note-Block_english/P"

        partImporter1.Scale = 1.0

        partImporter1.CreateNamedGroup = True

        partImporter1.ImportViews = False

        partImporter1.ImportCamObjects = False

        partImporter1.LayerOption = PartImporter.LayerOptionType.original

        partImporter1.DestinationCoordinateSystemSpecification = PartImporter.DestinationCoordinateSystemSpecificationType.Work

        Dim element1 As Matrix3x3
        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 NXMatrix
        nXMatrix1 = workPart.NXMatrices.Create(element1)

        partImporter1.DestinationCoordinateSystem = nXMatrix1

        Dim x As Double = 0
        Dim y As Double = 0
	Dim shtName As String = workPart.DrawingSheets().CurrentDrawingSheet.Name()
        Dim drawingSheet1 As Drawings.DrawingSheet = CType(workPart.DrawingSheets.FindObject(shtName), Drawings.DrawingSheet)


        'Sheet A
        If DrawingSheet1.height = 8.5 Then
            msgbox("Sheet size too small for ST Gear Note Block." & vbcrlf & "Use B or larger", vbokonly, "ST Gear Note Block")
            Exit Sub
        End If

        'Sheet B
        If DrawingSheet1.height = 11 Then
            x = 6.5
            y = 9.75
        End If

        'Sheet C
        If DrawingSheet1.height = 17 Then
            x = 11.5
            y = 16.5
        End If

        'Sheet D
        If DrawingSheet1.height = 22 Then
            x = 23.5
            y = 21.5
        End If

        'Sheet E
        If DrawingSheet1.height = 34 Then
            x = 33.1
            y = 33.5
        End If

        'Sheet F
        If DrawingSheet1.height = 28 Then
            x = 29.5
            y = 27.5
        End If






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

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

        Dim nXObject1 As NXObject
        nXObject1 = partImporter1.Commit()

        theSession.DeleteUndoMark(markId4, Nothing)

        partImporter1.Destroy()


    End Sub
End Module
 
Thanks SDETERS

This has me slightly confused with the file name... "@DB/ST-Note-Block_english/P"

I take it you import another team center file. I was looking to import a file from the operating system. Not that I cant import a Team Center file instead. I just never gave that any thought. lol I will need to create the file to do this. Not a problem.

To be honest, however, this still has me confused. I believe the "@" is code to direct it to another team center file. But the forward slashes have me curious. Is the DB and the P part of your file name? I didnt even know we were allowed to create TC files with words as the file name. lol
 
Nevermind the last comment. lol I see how to do this, but I will let you know how it goes as I will need to make some changes due to the fact we wont use standard sheet sizes but will use roll size at 900 hgt and a varying length.

Thanks again. I will post how it comes out or if I have any problems.
 
Cool Glad you have it figured out. We have a really open teamcenter standards as for now. So we name Items like this with text, we get away with it. This will depend on how your teamcenter and rules are setup. The first part is "item name"/revision.
 
Thanks SDETERS. Got the code set up and it works well. Had to add plenty more options for the lengths instead of height, but luckily they range from 1000 to 5000 in length and only go by hundred mm increments. lol

Truly appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor