Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all 787 articles
Browse latest View live

Automation with expressions and scripts

$
0
0

Dear People,

There is a parametric model that I am working on. All its features are controlled by expressions values, which in turn have some if else code incorporated to some expressions.
This is my master model.

To reuse it I clone this, then update the parameters, I have externally created a journal file which I run this then takes some input and make the entire model.
But the disadvantage of this is that for each time I want a change, I have to re-run the entire journal file.

Is there a way with which I can include script files in the part navigator,
so that if I intend to change a specific feature, I can go there edit the programming part of that feature and everything below it gets updated automatically without affecting the expressions of features above it.

It would also be of great help if I can know whether we have a solver in NX.
I intend to solve an equation,
Currently I rely on external solvers to do that, and have to update those values each time I run the code.


Export Part (modify Journal)

$
0
0

Hello,

I have a journal (*.vb) that exports the part to the OS-Filesystem from a managed NX session.

Everything works as it should. The only thing I would like to change is, that the user is able to select more than one solid in NX.
Right now, the export starts as soon as the user selects one solid.

Can anyone tell me how to modify that code to be able to select more than one solid?

I am a beginner with NXOpen :-)

Thanks!!

Regards,
Thomas

Here is the code:

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim theUFSession As UFSession = UFSession.GetUFSession()

Dim abody As Body = SelectABody("Export")

Dim objects() as Tag = { abody.Tag }

Dim itemName as String = theSession.Parts.Work.GetUserAttribute("DB_PART_NAME", NXObject.AttributeType.String, -1).StringValue
Dim itemId as String = theSession.Parts.Work.GetUserAttribute("DB_PART_NO", NXObject.AttributeType.String, -1).StringValue
Dim itemId_Rev as String = theSession.Parts.Work.GetUserAttribute("DB_PART_REV", NXObject.AttributeType.String, -1).StringValue

Dim fileName as String = "C:\Temp" + itemId + "_" + itemId_Rev + "_" + itemName + ".prt"

theUFSession.Part.Export(fileName, 1, objects)

End Sub

Function SelectABody(ByVal prompt As String) As Body

Dim ui As UI = GetUI()
Dim mask(0) As Selection.MaskTriple
With mask(0)
.Type = UFConstants.UF_solid_type
.Subtype = UFConstants.UF_solid_body_subtype
.SolidBodySubtype = 0
End With
Dim obj As NXObject = Nothing
Dim cursor As Point3d = Nothing

ui.SelectionManager.SelectObject(prompt, "Select Body",
Selection.SelectionScope.AnyInAssembly,
Selection.SelectionAction.ClearAndEnableSpecific,
False, False, mask, obj, cursor)

Return obj

End Function

End Module

Getting the feature from Drafting curve

$
0
0

Hi All,

I am trying to get the feature from the selected drafting curve. I used ask drafting curve parents to get the object(Edge).

Now I am asking the features using askedgefeats

now coming to the question:

for eg, my model(simple block feature) has 4 holes(2 simple holes and another 2 patterned from the 2nd simple holw)

if the selected drafting curve belongs to a direct hole feature(ie like simple hole, threaded hole) it is returning correctly the features including the hole package(total number of features returned-3(block, bodyfeature,holepackage))

But if i select the drafting curve belonging to patterned holes, it is returning only block and bodyfeature. It is not even returning the pattern feature.(from which I would get the reference to the holepackage).

I also tried to get the face from the edge and tried using askfacefeats, it is also having the same issue. Please let me know if there is anyother way to get the feature from the drafting curve or refining this code bleow.

int parantscount;
Tag[] parentstag;

theUfSession.Draw.AskDraftingCurveParents(dftcurve.Tag, out parantscount, out parentstag);

foreach (Tag temp_tag in parentstag)

{

//NXObject obj = (NXObject)NXOpen.Utilities.NXObjectManager.Get(parentstag[0]);
NXObject obj = (NXObject)NXOpen.Utilities.NXObjectManager.Get(temp_tag);
NXObject testobj = null;
if (obj.IsOccurrence == true)
{

testobj = (NXObject)obj.Prototype;

}

else

{

testobj = obj;

}
if (testobj.GetType() == typeof(NXOpen.Edge))
{

NXOpen.Edge proto_edg = (NXOpen.Edge)testobj;
//proto_edg.GetFaces()
Tag[] Feat_array_tag;
theUfSession.Modl.AskEdgeFeats(proto_edg.Tag, out Feat_array_tag);

theSession.ListingWindow.Open();
theSession.ListingWindow.WriteLine(Feat_array_tag.Length.ToString());

foreach (Tag feat_tag in Feat_array_tag)
{

NXObject test_obj = (NXObject)NXObjectManager.Get(feat_tag);

theSession.ListingWindow.WriteLine(test_obj.GetType().ToString());

}

}

thanks
Raghavan

How to rotate component by 4x4 matrix?

$
0
0

NXOpen.Session.Parts.Work.ComponentAssembly.MoveComponent(component, translation, rotation) method.
due to the fact that this method does not accept a 4x4 matrix, I have to cut it to 3x3, which causes the Z-axis to be lost.

Currently, I calculate 4x4 rotation matrix, after multiplicate vector of coordinate component and move a component by delta (current coordinates - coordinates from multiplication). But this works if point of rotation and component point is are equal.

Code:

def rotation_matrix(center: List[float], current_rotate: NXOpen.Matrix3x3, new_angleX: int, new_angleY: int):
    rotation1 = NXOpen.Matrix3x3()
 
    asin = math.sin(new_angleX)    
    acos = math.cos(new_angleX)
 
    bsin = math.sin(new_angleY)    
    bcos = math.cos(new_angleY)
 
    rotX = [
        [1, 0, 0, 0],
        [0, acos, 0 - asin, 0],
        [0, asin, acos, 0],
        [0, 0, 0, 1]
    ]
 
    rotY = [
        [bcos, 0, 0-bsin, 0],
        [0, 1, 0, 0],
        [bsin, 0, bcos, 0],
        [0, 0, 0, 1],
    ]
 
    res = matrixmult(rotX, rotY)
    transf = matrixmult([center], res)[0]
 
    rotation1.Xx = res[0][0]
    rotation1.Xy = res[0][1]
    rotation1.Xz = res[0][2]
 
    rotation1.Yx = res[1][0]
    rotation1.Yy = res[1][1]
    rotation1.Yz = res[1][2]
 
    rotation1.Zx = res[2][0]
    rotation1.Zy = res[2][1]
    rotation1.Zz = res[2][2]
 
    return transf1, rotation1

How to select automaticly all solids

$
0
0

Hello all,

I have a situation with the journal following. I'm using it to take backups of parts as just solid body but I don't want it to ask me to select solids on screen. How can I make it select all solids automaticly?

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
 
Module NXJournal
    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim theUFSession As UFSession = UFSession.GetUFSession()
 
        '********************************************************************************
 
        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
 
        'find file name and folder path
        Dim fileName As String = IO.Path.GetFileName(workPart.FullPath)
        Dim fileNameNoExt As String = IO.Path.GetFileNameWithoutExtension(workPart.FullPath)
        Dim parentFolder As String = IO.Path.GetDirectoryName(workPart.FullPath)
 
        'prepare a clean dd.mm.yy hh.mm.ss type string
        Dim TimeNote As DateTime
        TimeNote = System.DateTime.Now()
        Dim full_date_time As String = TimeNote
        Dim hour As String = Mid(full_date_time, Len(full_date_time) - 7, 2)
        Dim minute As String = Mid(full_date_time, Len(full_date_time) - 4, 2)
        Dim second As String = Mid(full_date_time, Len(full_date_time) - 1, 2)
        Dim ddmmyy As String = Left(full_date_time, Len(full_date_time) - 9)
        Dim year_short As String = Right(ddmmyy, 2)
        ddmmyy = Left(ddmmyy, Len(ddmmyy) - 4) & year_short
        ddmmyy = ddmmyy.PadLeft(8, "0")
 
        'prepare new backup folder if doesn't exist
        Dim yeni_klasor As String = parentFolder & "\backup"
        My.Computer.FileSystem.CreateDirectory(yeni_klasor)
 
        'result of new file path with new file name
        Dim sonuc As String = yeni_klasor & "\" & fileNameNoExt & " " & ddmmyy & " " & hour & "." & minute & "." & second & ".prt"
 
        '********************************************************************************
 
        Dim abody() As TaggedObject
        If SelectBodies("select bodies", abody) = Selection.Response.Cancel Then
            Return
        End If
 
        Dim bodyTags As New List(Of Tag)
 
        For Each temp As TaggedObject In abody
            bodyTags.Add(temp.Tag)
        Next
 
        Dim options As UFPart.ExportOptions
        With options
            .expression_mode = UFPart.ExportExpMode.CopyExpDeeply
            .new_part = True
            .params_mode = UFPart.ExportParamsMode.RemoveParams
        End With
 
        theUFSession.Part.ExportWithOptions(sonuc, bodyTags.Count, bodyTags.ToArray, options)
 
    End Sub
 
    Function SelectBodies(ByVal prompt As String, ByRef selObj() As TaggedObject) As Selection.Response
 
        Dim theUI As UI = UI.GetUI
        Dim title As String = "Select one or more bodies"
        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.WorkPart
        Dim selectionMask_array(0) As Selection.MaskTriple
 
        With selectionMask_array(0)
            .Type = UFConstants.UF_solid_type
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
        End With
 
        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selobj)
        If resp = Selection.Response.Ok Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
 
    End Function
End Module

How can I play a journal automaticly when NX start?

$
0
0

Hello all again,

Is there a way to play/work a journal automaticly at NX software startup? I have been searching for it and couldn't find a proper solution. Due to security reasons, there are some limitations with my computer and I can't "save as default" my assembly load options. So I wanted to prepare a journal (or alternative way can be a macro) and to make it work automaticly at start. So I think I can fake it like I saved it as default...

Delete all interpart expressions

$
0
0

Hello

I'd like to remove all interpart expressions in my script.
In the NX GUI there is a button "delete all references", but if I record a journal of that, I only get the code snipped for the specific references I deleted:

found1 = workPart.Expressions.RemoveInterpartReferences("%UGMGR=V3.2 PH=yzHACH6Jhqmj3C PRH=6AIADHfBhqmj3C PN=1048065 PRN=K RT=""has shape"" AT=""UG master part file"" ")

Is the a way to delete all of them? Or check which references exist and then loop trough all of them?

Thank you and Regards

Folder selection in Journal


Get current TeamCenter working directory

$
0
0

Hello

Is there a way to check in which directory/folder of TeamCennter the User is currently working in? I'm only able to set a new location with:
theSession.PdmSession.SetDefaultFolder(Folder)
Also this code doesn't result in an Error when the user specifies one, that isn't in TeamCenter. Is there a way to check if its available?

And how can I read the current working path?

Kind Regards

Tolerance and dimensions input from XLS

$
0
0

Hello,

Right now I am exporting all the dimensions and tol into a spreadsheet that we use for stacks.
I'm curios how do I revert that, if I make some tol tweaks I would like to bring the data from the XLS to the drawing back.
This is the code I use to get from drawing to XLS:

Option Strict Off
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports System.IO
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.Annotations
Imports NXOpen.UF

Module Module1

Sub Main()

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

Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

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

Dim row As Long = 1
Dim column As Long = 1

'create Excel object
Dim objExcel as Object
Try
objExcel = Marshal.GetActiveObject("Excel.Application")
Catch
objExcel = CreateObject("Excel.Application")
End Try

If objExcel Is Nothing Then
theUISession.NXMessageBox.Show("Error", NXMessageBox.DialogType.Error, "Could not start Excel, journal exiting")
theSession.UndoToMark(markId1, "journal")
Exit Sub
End If

' open a blank Excel file to output dimensions into
Dim objWorkbook = objExcel.Workbooks.Add()
If objWorkbook Is Nothing Then
theUISession.NXMessageBox.Show("Error", NXMessageBox.DialogType.Error, "Could not open Excel file")
theSession.UndoToMark(markId1, "journal")
Exit Sub
End If

objExcel.visible = True

objExcel.Cells(row, 1) = workPart.FullPath

Dim objects1(0) As NXOpen.DisplayableObject
Dim myDimText() As String
Dim myDimDualText() As String
Dim draftingFeatureControlFrameBuilder1
For Each myDimension As Annotations.Dimension In workPart.Dimensions
row += 1

' (1) get the current value and put that into a cell
myDimension.GetDimensionText(myDimText, myDimDualText)
objExcel.Cells(row, column) = myDimText(0)

' (1) get the current value and put that into a cell
myDimension.GetDimensionText(myDimText, myDimDualText)
objExcel.Cells(row, column + 1) = myDimText(0)
objExcel.Cells(row, column+2) = myDimension.UpperToleranceValue
objExcel.Cells(row, column+0) = myDimension.GetAppendedText().GetAfterText()
objExcel.Cells(row, column+3) = myDimension.GetAppendedText().GetBeforeText()
'objExcel.Cells(row, column+4) = myDimension.GetAppendedText().GetBelowText()

' (2) force the dimension back to a numerical value
objects1(0) = myDimension
Dim editSettingsBuilder1 As NXOpen.Annotations.EditSettingsBuilder = Nothing
editSettingsBuilder1 = workPart.SettingsManager.CreateAnnotationEditSettingsBuilder(objects1)

Dim editsettingsbuilders1(0) As NXOpen.Drafting.BaseEditSettingsBuilder
editsettingsbuilders1(0) = editSettingsBuilder1
workPart.SettingsManager.ProcessForMultipleObjectsSettings(editsettingsbuilders1)
editSettingsBuilder1.AnnotationStyle.DimensionStyle.OverrideDimensionText = False

Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = editSettingsBuilder1.Commit()
editSettingsBuilder1.Destroy()

' (3) put the new value into Excel
myDimension.GetDimensionText(myDimText, myDimDualText)
objExcel.Cells(row, column+1) = myDimText(0)
objExcel.Cells(row, column+2) = myDimension.UpperToleranceValue

Next

For Each temp As Gdt In workPart.Gdts

row += 1

If Not TypeOf (temp) Is Annotations.DraftingFcf Then
Continue For
End If

Dim fcfBuilder As Annotations.DraftingFeatureControlFrameBuilder
fcfBuilder = workPart.Annotations.CreateDraftingFeatureControlFrameBuilder(temp)

Dim featureControlFrameDataBuilder1 As Annotations.FeatureControlFrameDataBuilder = fcfBuilder.FeatureControlFrameDataList.FindItem(0)

objExcel.Cells(row, column+2) = featureControlFrameDataBuilder1.ToleranceValue / 2.0
objExcel.Cells(row, column) = featureControlFrameDataBuilder1.PrimaryDatumExtendedText
objExcel.Cells(row, column + 1) = 0.0
'objExcel.Cells(row, column+2) = fcfBuilder.Characteristic.ToString
'objExcel.Cells(row, column) = featureControlFrameDataBuilder1.ZoneShape.ToString

'objExcel.Cells(row, column+5) = featureControlFrameDataBuilder1.PrimaryDatumReference.MaterialCondition

fcfBuilder.Destroy()

Next

' get a reference to the stack data work book
Dim OpenFileDialog1 as New OpenFileDialog()
Dim strFilePath as String

Dim result As DialogResult = OpenFileDialog1.ShowDialog()
' Test result.
If result = DialogResult.OK Then
' Do something.
strFilePath = OpenFileDialog1.FileName
End If

Dim wkbkStackData
Dim wkbkOpen as Object
For Each wkbkOpen in objExcel.Workbooks
Dim nameOnly = Path.GetFileName(strFilePath)
If wkbkOpen.Name = nameOnly Then
wkbkStackData = objExcel.Workbooks(nameOnly)
End if
Next

If wkbkStackData Is Nothing Then
wkbkStackData = objExcel.Workbooks.Open(strFilePath)
End If

' prompt for a file - if name is already open, prompt if that workbook should be used

' clear out the changes worksheet (or create if not there)
Dim doesSheetExist as Boolean
Dim shtTest as Object
For Each shtTest In wkbkStackData.Sheets
If shtTest.Name = "Changes"
doesSheetExist = True
End If
Next

If Not doesSheetExist Then
wkbkStackData.Sheets.Add( After:=wkbkStackData.Sheets("Stack_Data"))
wkbkStackData.Sheets(wkbkStackData.Sheets.Count).Name = "Changes"
End If

wkbkStackData.Sheets("Changes").UsedRange.Clear()
wkbkStackData.Sheets("Changes").Cells(1,1).Value = "Cleared"

Dim index as Integer
index = 1

Dim sht as Object
sht = objWorkbook.Sheets("Sheet1")

Dim rngAllData as Object
rngAllData = sht.UsedRange

Dim rngRows as Object
rngRows = rngAllData.Rows()

' run through each row, check if valid stack label
Dim rngRow as Object
For Each rngRow In rngRows
wkbkStackData.Sheets("Changes").Cells(1, 1) = index
Dim possibleRange = rngRow.Cells(1,1).Value

Dim isValidRange = False
Dim rng as Object

Try
rng = wkbkStackData.Sheets("Stack_Data").Range(possibleRange)
isValidRange = True
Catch

End Try

' if valid label, go ahead check against excisting info
If isValidRange Then

Try

wkbkStackData.Sheets("Changes").Cells(index, 2) = possibleRange

' if anythign changed, add to the changes worksheet

Dim curDim = rng.Value
Dim curTol = rng.Offset(0,1).Value

If curDim is Nothing Then
curDim = 0.0
End If

If curTol is Nothing Then
curTol = 0.0
End if

Dim didDimChange as Boolean
didDimChange = rng.Value <> rngRow.Cells(1,2).Value
Dim didTolChange as Boolean
didTolChange = rng.Offset(0,1).Value <> rngRow.Cells(1,3).Value

rng.Value = rngRow.Cells(1,2).Value
rng.Offset(0,1).Value = rngRow.Cells(1,3).Value

If didDimChange
wkbkStackData.Sheets("Changes").Cells(index, 3) = possibleRange + "Dimension changed" + curDim.ToString() + "--->" + rng.Value.ToString()
rng.Style="Bad"
End If

If didTolChange
wkbkStackData.Sheets("Changes").Cells(index, 4) = possibleRange + "Tolerance changed" + curTol.ToString() + "--->" + rng.Offset(0,1).Value.ToString()
rng.Offset(0,1).Style="Bad"
End If

Catch ex as Exception
wkbkStackData.Sheets("Changes").Cells(index, 4) = ex.ToString()

End Try
index = index + 1

End If

Next

wkbkStackData.Sheets("Changes").Columns().AutoFit()

' comment this line out if you want to leave the intermediate sheet open
objWorkbook.Close(False)

objWorkbook = Nothing
objExcel = Nothing

lw.Close()

' ----------------------------------------------
' Menu: Edit->Undo
' ----------------------------------------------
Dim marksRecycled1 As Boolean = Nothing
Dim undoUnavailable1 As Boolean = Nothing
theSession.UndoLastNVisibleMarks(1, marksRecycled1, undoUnavailable1)

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------

End Function

End Module

Zone Location for View at View Location and Transfer to Parent and child views

$
0
0

Hi,

How to get Zone location for all Views at "View Names/labels"(Ex : View A) and how to Transfer zone location of Parent view to child views (Ex: Section View, Detail view and projected view) and from child views to parent view, can you please help me,
Thanks In Advance

Thanks & Regards
Laxman

NXOpen Component get color in rgb

$
0
0

Hi everyone,
Can you help me?

How can I get the color of a NXOpen.Component in RGB mode by coding?

Thank you very much.

Assembly File Attributes to Excel

Selection of points In Drafting which are created in MasterModel in TeamCenter

$
0
0

Hello All,

Below Code

For Each myPoint As Point in Workpart.Points
myPoint.Highlight
Next

Is working In Individual File, but when Points are created in MasterModel file, these points are not selecting In Drawing file for note creation / Highlighting In Teamcenter, Can you please Help Me, Thanks In Advance

Assign Attributes From Excel

$
0
0

I apologize if this has already been covered but I have been searching for a while and can't find anything.

I'm looking for something like the AssignAttributesForTooltips journal in the sample NX Open apps that come with the installation, except I want to assign attributes for each part in an assembly (and the assembly part itself).

Let's say I have an assembly named 123 which contains parts AAA, BBB, and CCC, and an Excel sheet that lists the part name in column A and another separate attribute for each part name in column B (like cell A1 contains 123 and cell B1 contains 456, cell A2 contains AAA and cell B2 contains ZZZ, and so on). I want to cycle through each part, look up the appropriate cell in the sheet based on the part name attribute, and then create a new attribute with the value in the corresponding cell in column B.

I think I could eventually figure out how to do this, but I thought I would check and see if maybe it had already been done first.


Dropdown List for user to select - Simple code if possible please

$
0
0

Hi everyone. I am very new to NX Journaling and am looking for a way to create a dialog box with a dropdown list that displays part numbers of the components in the assembly for the user to select and click OK. I have found some code but they are quite lengthy and difficult to follow. Can someone please come up with a simple code only related to creation of the drop down list. Thanks in advance.

How To Get View Label On Parent view of Detail View

Get all dimensions with formula set as value

$
0
0

Hello

Is there a way to get all dimensions of a part that have a formula set as value? Or even better; That use an expression in the formula? This should work if the dimension is still named p** or is a named expression.

If not, can you tell me how to get a list of all expressions? I might figure something out that fits my case.

Thank you and regards

NX Deawing Template

$
0
0

Hi guys, is there a any way to write an NX Journal ( in Visual Basic ) which opens an template ( .prt file ) , edit the content from it (addition of text in every revision of a drawing) and paste it to an opened drawing ? Thanks . Any input appreciated.

Edit Information MoldBase in Create MoldBase

$
0
0

Hello,
In the process of creating Moldbase, I want to edit the information according to the BITMAP interface I created. But after using Jounaling record and playing it again, I get this error message:
"NXOpen.NXException: No object found with this name
at NXOpen.PartCollection.FindOject (String name)
at NXJournal.Main (String [] args) in C: \ Users \ Dell \ AppData \ Local \ Temp \ NXJournals33032 \ journal0.vb: line279 "
Please tell me what problem am I having? If anyone is working on an equivalent topic please share it for me so I can do it? Thanks so much
The code I have recorded below:

<' NX 12.0.0.27
' Journal created by DELL on Thu Feb 6 17:46:36 2020 SE Asia Standard Time
'
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

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

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

' ----------------------------------------------
' Menu: Tools->Process Specific->Mold Wizard->Mold Base Library...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim standardPartBuilder1 As NXOpen.Tooling.StandardPartBuilder = Nothing
standardPartBuilder1 = workPart.ToolingManager.StandardPart.CreateStandardPartBuilder()

Dim spreadsheetData1 As NXOpen.Tooling.SpreadsheetData = Nothing
spreadsheetData1 = theSession.ToolingSession.CreateSpreadsheetData()

standardPartBuilder1.ShowInfoWindow = True

standardPartBuilder1.AssociativePosition = True

standardPartBuilder1.RenameComponents = True

theSession.SetUndoMarkName(markId1, "Mold Base Library Dialog")

spreadsheetData1.ReadData("")

spreadsheetData1.ReadData("C:\Program Files\Siemens\NX 12.0\moldwizard\moldbase\metric\futaba\fm_de\de_series.xlsx::FUTABA")

spreadsheetData1.ReadData("C:\Program Files\Siemens\NX 12.0\moldwizard\moldbase\metric\futaba\fm_de\de_series.xlsx::FUTABA")

standardPartBuilder1.RenameComponents = False

Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Mold Base Library")

theSession.DeleteUndoMark(markId2, Nothing)

Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Mold Base Library")

Dim addReusablePart1 As NXOpen.Tooling.AddReusablePart = Nothing
addReusablePart1 = workPart.ReusableParts.CreateBuilder()

Dim cloneObject1 As NXOpen.Tooling.CloneObject = Nothing
cloneObject1 = addReusablePart1.CreateCloneObject(NXOpen.Tooling.ToolingApplication.MoldWizard, "C:\Program Files\Siemens\NX 12.0\moldwizard\moldbase\metric\futaba\fm_de\fd.prt")

cloneObject1.CloneMethod = NXOpen.Tooling.ToolingClonemethod.Rename

cloneObject1.SetProjectName("proj")

cloneObject1.OutputFolder = ""

cloneObject1.SyncPartNumber()

cloneObject1.AddAssembly("C:\Program Files\Siemens\NX 12.0\moldwizard\moldbase\metric\futaba\fm_de\fd.prt")

cloneObject1.BuildAllClonePartItems()

Dim clonedpartname1 As String = Nothing
clonedpartname1 = cloneObject1.Commit()

cloneObject1.SyncPartNumber()

cloneObject1.Dispose()
addReusablePart1.Destroy()

Dim part1 As NXOpen.Part = CType(theSession.Parts.FindObject("proj_fd_781"), NXOpen.Part)

Dim basePoint1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim orientation1 As NXOpen.Matrix3x3 = Nothing
orientation1.Xx = 1.0
orientation1.Xy = 0.0
orientation1.Xz = 0.0
orientation1.Yx = 0.0
orientation1.Yy = 1.0
orientation1.Yz = 0.0
orientation1.Zx = 0.0
orientation1.Zy = 0.0
orientation1.Zz = 1.0
Dim partLoadStatus1 As NXOpen.PartLoadStatus = Nothing
Dim component1 As NXOpen.Assemblies.Component = Nothing
component1 = workPart.ComponentAssembly.AddComponent(part1, Nothing, "MOLD BASE", basePoint1, orientation1, -1, partLoadStatus1)

partLoadStatus1.Dispose()
theSession.DeleteUndoMark(markId3, Nothing)

workPart = theSession.Parts.Work ' TestFillSurface
theSession.SetUndoMarkName(markId1, "Mold Base Library")

standardPartBuilder1.Destroy()

spreadsheetData1.Dispose()
Dim components1(0) As NXOpen.Assemblies.Component
components1(0) = component1
component1.UpdateStructure(components1, 2, True)

Dim component2 As NXOpen.Assemblies.Component = CType(component1.FindObject("COMPONENT proj_movehalf_773 1"), NXOpen.Assemblies.Component)

Dim components2(0) As NXOpen.Assemblies.Component
components2(0) = component2
component2.UpdateStructure(components2, 2, True)

Dim component3 As NXOpen.Assemblies.Component = CType(component1.FindObject("COMPONENT proj_fixhalf_769 1"), NXOpen.Assemblies.Component)

Dim components3(0) As NXOpen.Assemblies.Component
components3(0) = component3
component3.UpdateStructure(components3, 2, True)

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module>

Viewing all 787 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>