What method should I use to get access to all of the hidden and visible objects of any type?
Thanks in advance.
What method should I use to get access to all of the hidden and visible objects of any type?
Thanks in advance.
How can I hide/show a specific layer?
Thanks in advance.
Is there a way to access the transform feature under Edit->Transform? It appears the journal recorder doesn't record the commands? Can I manually program it from the API? Are there any tutorials? I'm trying to mirror a solid body.
Thanks
We are presently developing an external NXOpen application. This is a console based application which can also be executed in batch mode. We will be deploying this application on several machines both Win7 and Linux. NX installation is needed for such an application to work.
Problem 1:
The NX version used here is updated from time to time as and when Siemens releases them. This is taken care by the system administrators and updates are done through push mechanism. Thus there is a distinct possibility that some of the functionalities/routines that are changed between versions may affect the behaviour of the application being developed or the results may vary. This is undesirable on our part.
We are exploring the possibility that a set of tested NX DLLs (and only needed ones) to be shipped along with the tool such that the application will refer to 'these DLLs' instead of the NX version installed on the system. Is there a way to do this ?
Problem 2:
NX takes a long time for initialization. We tested and found that the initialization for application takes around 2 minutes. This doesn't sound reasonable especially due to the fact that the said application being developed may be executed iteratively through another script. Each initialization takes around 2 minutes which would mean the whole iteration process may run in days.
a. We are looking for a solution to bring this time down to a few seconds. Is there a way to achieve this?
b. Or An option to launch NX session (without UI) as a constantly running process (similar to a windows service) and a way to attach our application to this process when needed to run iteratively. This approach should be usable on other platforms like Linux as well.
Thanks is advance for all the help here.
Hi, I hope someone can help me out.
I am a newbe on journaling.
I have made a Journal for creating "Reference Set".
I would like to have the possibility to ad lines and run it again.
There for i need help to run by the existing created reference set.
Thanks in advance, Hove.
NX 8.5
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Module Module1
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main()
Try
Dim referenceSet1 As ReferenceSet
referenceSet1 = workPart.CreateReferenceSet()
referenceSet1.SetName("test_1")
'add all components (existing and future)
referenceSet1.SetAddComponentsAutomatically(False, False)
Catch ex As NXException
If ex.ErrorCode = 650030 Then goto lab2 else goto lab2
lab2:
End Try
Try
Dim referenceSet2 As ReferenceSet
referenceSet2 = workPart.CreateReferenceSet()
referenceSet2.SetName("test_2")
'add all components (existing and future)
referenceSet2.SetAddComponentsAutomatically(False, False)
Catch ex As NXException
If ex.ErrorCode = 650030 Then goto lab3 else goto lab3
lab3:
End Try
Try
Dim referenceSet3 As ReferenceSet
referenceSet3 = workpart.CreateReferenceSet()
referenceSet3.SetName("test_3")
'add all components (existing and future)
referenceSet3.SetAddComponentsAutomatically(False, False)
Catch ex As NXException
If ex.ErrorCode = 650030 Then goto lab4 else goto lab4
lab4:
End Try
End sub
End Module
Hello All,
I find myself working with many view labels and I was wondering if there was a way to edit this label with a journal file.
I would like to use the journal to find "(c2.0000)" and replace with "(c1.5)(d2)" as well as "(c)" and replace to "(c)(d)"
Is this possible? I have typically only used macros and I am new to journals.
Edit* ( ) = Greater than Less than signs
Thanks in advance for your help,
Riley
Here I have written a small program
In Active Work Part Copy DB_PART_NO into Clipboard.
Best Regards
BK
' Copy DB_PART_NO (Active Work Part) into Clipboard ' Ausgabe der DB_PART_NO des Aktiven Parts in den Windows Zwischenspeicher (Clipboard) ' Tested in NX10.0.3 ' Copyright 2015 Big King Option Strict Off Imports System Imports NXOpen Module NXJournal Sub Main Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work ' it's only Filename without Revision Dim filename As String = workPart.GetStringAttribute("DB_PART_NO") 'System.Windows.Forms.MessageBox.Show(filename) 'Clipboard My.Computer.Clipboard.SetText(filename) End Sub End Module
Hi,
When i try to run the below code (Stamped PDF for QC), If I have one sheet Dwg it is adding empty second sheet while creating the table, If it is multi sheet Dwg I am not getting any issues. Please let me know where is the problem, So that I could correct it.
Option Strict OffImports System Imports NXOpen Imports NXOpen.UFImports System.Windows.FormsImports NXOpen.AnnotationsImports NXOpen.UtilitiesImports System.Collections.GenericImports NXOpen.UF.UFDrawImports NXOpen.DrawingsImports System.Windows.Forms.MessageBoxImports System.IOImports System.Collections ' NX Echeck Stamp' Journal created by Alto on 10-06-2015 Module NXJournal Dim theSession As Session = Session.GetSession()Dim workPart As Part = theSession.Parts.WorkDim displayPart As Part = theSession.Parts.DisplayDim ufs As UFSession = UFSession.GetUFSession()Dim ui As UI = ui.GetUI()Dim fontIndex1 AsInteger Sub Main()' Create the tabular noteDim taborgin As Point3d =New Point3d(9.72414748499, 2.55025773063, 0)Dim newcolumns AsInteger=3Dim newrows AsInteger=5Dim tabnote As NXOpen.Tag= CreateTabnoteWithSize(newrows, newcolumns, taborgin) ' Get the column tagsDim columns(newcolumns -1)As NXOpen.TagDim rows(newrows)As NXOpen.TagDim i AsIntegerDim j AsIntegerDim height AsDouble=NothingDimwidthAsDouble=NothingFor i =0To newcolumns -1 ufs.Tabnot.AskNthColumn(tabnote, i, columns(i)) ufs.Tabnot.AskColumnWidth(columns(i), width)width=0.7 ufs.Tabnot.SetColumnWidth(columns(i), width)Next For j =0To newrows -1 ufs.Tabnot.AskNthRow(tabnote, j, rows(j)) ufs.Tabnot.AskRowHeight(rows(j), height) height =0.22 ufs.Tabnot.SetRowHeight(rows(j), height)Next Dim pt1 As Point =NothingDim cell1 As NXOpen.TagDim cellprefes As UFTabnot.CellPrefs=Nothing ufs.Tabnot.AskCellAtRowCol(rows(0), columns(0), cell1)Dim cell2 As NXOpen.Tag ufs.Tabnot.AskCellAtRowCol(rows(0), columns(2), cell2) ufs.Tabnot.MergeCells(cell1, cell2)Dim cell3 As NXOpen.Tag ufs.Tabnot.AskCellAtRowCol(rows(4), columns(0), cell3)Dim cell4 As NXOpen.Tag ufs.Tabnot.AskCellAtRowCol(rows(4), columns(2), cell4) ufs.Tabnot.MergeCells(cell3, cell4) ufs.Tabnot.AskCellAtRowCol(rows(0), columns(0), cell1) ufs.Tabnot.SetCellText(cell1, "IN REVIEW PROCESS CHECK") ufs.Tabnot.AskCellAtRowCol(rows(1), columns(0), cell1) ufs.Tabnot.SetCellText(cell1, "E CHECK") ufs.Tabnot.AskCellAtRowCol(rows(1), columns(1), cell1) ufs.Tabnot.SetCellText(cell1, "NOG") ufs.Tabnot.AskCellAtRowCol(rows(1), columns(2), cell1) ufs.Tabnot.SetCellText(cell1, "CM") ufs.Tabnot.AskCellAtRowCol(rows(2), columns(0), cell1) ufs.Tabnot.SetCellText(cell1, "CHECK") ufs.Tabnot.AskCellAtRowCol(rows(2), columns(1), cell1) ufs.Tabnot.SetCellText(cell1, "CERT") ufs.Tabnot.AskCellAtRowCol(rows(2), columns(2), cell1) ufs.Tabnot.SetCellText(cell1, "ENG APVD") ufs.Tabnot.AskCellAtRowCol(rows(3), columns(0), cell1) ufs.Tabnot.SetCellText(cell1, "METHODS") ufs.Tabnot.AskCellAtRowCol(rows(3), columns(1), cell1) ufs.Tabnot.SetCellText(cell1, "FLAM") ufs.Tabnot.AskCellAtRowCol(rows(3), columns(2), cell1) ufs.Tabnot.SetCellText(cell1, "DESIGN ENG") ufs.Tabnot.AskCellAtRowCol(rows(4), columns(0), cell1) ufs.Tabnot.SetCellText(cell1, "(IN ACCORDANCE WITH ALL APPLICABLE PROCESSES AND PROCEDURES)") ufs.Tabnot.AskCellAtRowCol(rows(4), columns(0), cell4) ufs.Tabnot.AskCellPrefs(cell4, cellprefes) cellprefes.fit_methods(0)= UFTabnot.FitMethod.FitMethodWrap ufs.Tabnot.SetCellPrefs(cell4, cellprefes) ufs.Tabnot.AskCellAtRowCol(rows(0), columns(0), cell4) ufs.Tabnot.AskCellPrefs(cell4, cellprefes) cellprefes.fit_methods(0)= UFTabnot.FitMethod.FitMethodAutoSizeText ufs.Tabnot.SetCellPrefs(cell4, cellprefes)For i =0To newrows -1For j =0To newcolumns -1 ufs.Tabnot.AskCellAtRowCol(rows(i), columns(j), cell1) ufs.Tabnot.AskCellPrefs(cell1, cellprefes) fontIndex1 = workPart.Fonts.AddFont("ideas_iso") cellprefes.format= UFTabnot.Format.FormatText cellprefes.text_font= fontIndex1 cellprefes.text_height=0.05 cellprefes.text_aspect_ratio=1.0' cellprefes.text_angle=0.0 cellprefes.text_slant=0.0 cellprefes.line_space_factor=1.0 cellprefes.char_space_factor=1.0 cellprefes.text_color=6 cellprefes.horiz_just= UFTabnot.Just.JustLeft cellprefes.vert_just= UFTabnot.Just.JustTop ufs.Tabnot.SetCellPrefs(cell1, cellprefes) NextNext For i =0To newcolumns -1 ufs.Tabnot.AskNthColumn(tabnote, i, columns(i)) ufs.Tabnot.AskColumnWidth(columns(i), width)width=0.75 ufs.Tabnot.SetColumnWidth(columns(i), width)Next For j =0To newrows -1 ufs.Tabnot.AskNthRow(tabnote, j, rows(j)) ufs.Tabnot.AskRowHeight(rows(j), height) height =0.23238 ufs.Tabnot.SetRowHeight(rows(j), height)Next ufs.Tabnot.AskRowHeight(rows(0), height) height =0.1 ufs.Tabnot.SetRowHeight(rows(0), height) ufs.Tabnot.AskRowHeight(rows(4), height) height =0.2 ufs.Tabnot.SetRowHeight(rows(4), height) Dim letteringPrefs As LetteringPreferences =NothingDim userSymPrefs As UserSymbolPreferences =Nothing Call Printpdf() Dim notifyOnDelete1 AsBoolean notifyOnDelete1 = theSession.Preferences.Modeling.NotifyOnDelete theSession.UpdateManager.ClearErrorList() Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Delete") Dim objects1(0)As NXObject Dim displayableObject1 As DisplayableObject =CType(workPart.FindObject("ENTITY 165 9 1"), DisplayableObject) objects1(0)= displayableObject1 Dim nErrs1 AsInteger nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1) Dim notifyOnDelete2 AsBoolean notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete Dim nErrs2 AsInteger nErrs2 = theSession.UpdateManager.DoUpdate(markId1)EndSub Sub Printpdf() Dim dwgs As Drawings.DrawingSheetCollection dwgs = workPart.DrawingSheetsDim sheet As Drawings.DrawingSheetDim i AsIntegerDim pdfFile AsString=NothingDim currentPath AsString=NothingDim currentFile AsString=NothingDim exportFile AsString=NothingDim partUnits AsInteger=NothingDim strOutputFolder AsString=NothingDim strRevision AsString=NothingDim rspFileExists Dim rspAdvancePrint =Nothing Dim IsTcEng AsBoolean=FalseDim UFSes As UFSession = UFSession.GetUFSession() UFSes.UF.IsUgmanagerActive(IsTcEng) partUnits = displayPart.PartUnits 'Read TCE attributesIf IsTcEng Then currentFile = workPart.GetStringAttribute("DB_PART_NO") strRevision = workPart.GetStringAttribute("DB_PART_REV")EndIf exportFile = currentFile strOutputFolder = OutputPath()'if we don't have a valid directory (ie the user pressed 'cancel') exit the journalIfNotDirectory.Exists(strOutputFolder)ThenExitSubEndIf strOutputFolder = strOutputFolder &"\" Dim shts AsNew ArrayList()ForEach sheet In dwgs shts.Add(sheet.Name)Next shts.Sort() i =0Dim sht AsStringForEach sht In shts ForEach sheet In dwgs If sheet.Name= sht Then i = i +1 If strRevision <> ""Then pdfFile = strOutputFolder & exportFile &"_"& strRevision &".pdf"Else pdfFile = strOutputFolder & exportFile &".pdf" EndIf If i =1ThenIfFile.Exists(pdfFile)Then rspFileExists =MsgBox("The file: '"& pdfFile &"' Already exists; overwrite?", vbYesNo + vbQuestion)If rspFileExists = vbYes ThenTryFile.Delete(pdfFile)Catch ex As Exception MsgBox(ex.Message& vbCrLf &"Journal exiting", vbCritical + vbOKOnly, "Error")ExitSubEndTryElseExitSubEndIfEndIfEndIf 'update any views that are out of date theSession.Parts.Work.DraftingViews.UpdateViews(Drawings.DraftingViewCollection.ViewUpdateOption.OutOfDate, sheet) Try ExportPDF(sheet, pdfFile, partUnits, rspAdvancePrint)Catch ex As Exception MsgBox("Error occurred in PDF export"& vbCrLf & ex.Message& vbCrLf &"journal exiting", vbCritical + vbOKOnly, "Error")ExitSubEndTryExitForEndIfNext Next If i =0Then MessageBox.Show("This part has no drawing sheets to export", "PDF export failure", MessageBoxButtons.OK, MessageBoxIcon.Warning)Else MessageBox.Show("Exported: "& i &" sheet(s) to pdf file"& vbCrLf & pdfFile, "PDF export success", MessageBoxButtons.OK, MessageBoxIcon.Information)EndIf EndSub Function OutputPath() Dim strLastPath AsString=Nothing Try strLastPath =GetSetting("NX journal", "Export pdf", "ExportPath")Catch e As ArgumentException Catch e As Exception MsgBox(e.GetType.ToString)FinallyEndTry Dim FolderBrowserDialog1 AsNew FolderBrowserDialog With FolderBrowserDialog1 .RootFolder= Environment.SpecialFolder.DesktopIfDirectory.Exists(strLastPath)Then .SelectedPath= strLastPath Else .SelectedPath="H:\"EndIf .Description="Select the directory to export .pdf file"If .ShowDialog= DialogResult.OKThen OutputPath = .SelectedPathSaveSetting("NX journal", "Export pdf", "ExportPath", .SelectedPath)Else OutputPath =0EndIfEndWith EndFunction Sub ExportPDF(dwg As Drawings.DrawingSheet, outputFile AsString, units AsInteger, advancePrint AsInteger) Dim printPDFBuilder1 As PrintPDFBuilder printPDFBuilder1 = workPart.PlotManager.CreatePrintPdfbuilder() printPDFBuilder1.Scale=1.0 printPDFBuilder1.Action= PrintPDFBuilder.ActionOption.Native printPDFBuilder1.Colors= PrintPDFBuilder.Color.BlackOnWhite printPDFBuilder1.Size= PrintPDFBuilder.SizeOption.ScaleFactorIf units =0Then printPDFBuilder1.Units= PrintPDFBuilder.UnitsOption.EnglishElse printPDFBuilder1.Units= PrintPDFBuilder.UnitsOption.MetricEndIf printPDFBuilder1.XDimension= dwg.Height printPDFBuilder1.YDimension= dwg.Length printPDFBuilder1.OutputText= PrintPDFBuilder.OutputTextOption.Polylines printPDFBuilder1.RasterImages=True printPDFBuilder1.ImageResolution= PrintPDFBuilder.ImageResolutionOption.Medium printPDFBuilder1.Append=True Dim sheets1(0)As NXObject Dim drawingSheet1 As Drawings.DrawingSheet=CType(dwg, Drawings.DrawingSheet) sheets1(0)= drawingSheet1 printPDFBuilder1.SourceBuilder.SetSheets(sheets1) printPDFBuilder1.Filename= outputFile Dim nXObject1 As NXObject nXObject1 = printPDFBuilder1.Commit() printPDFBuilder1.Destroy() EndSub PublicFunction CreateTabnoteWithSize( _ ByVal nRows AsInteger, ByVal nColumns AsInteger, ByVallocAs Point3d)As NXOpen.TagDim secPrefs As UFTabnot.SectionPrefs=Nothing ufs.Tabnot.AskDefaultSectionPrefs(secPrefs)Dim cellPrefs As UFTabnot.CellPrefs=NothingDim origin(2)AsDouble origin(0)=loc.X origin(1)=loc.Y origin(2)=loc.ZDim tabnote As NXOpen.Tag ufs.Tabnot.Create(secPrefs, origin, tabnote)Dim nmRows AsInteger=0 ufs.Tabnot.AskNmRows(tabnote, nmRows)For ii AsInteger=0To nmRows -1Dim row As NXOpen.Tag ufs.Tabnot.AskNthRow(tabnote, 0, row) ufs.Tabnot.RemoveRow(row) ufs.Obj.DeleteObject(row)NextDim nmColumns AsInteger=0 ufs.Tabnot.AskNmColumns(tabnote, nmColumns)For ii AsInteger=0To nmColumns -1Dim column As NXOpen.Tag ufs.Tabnot.AskNthColumn(tabnote, 0, column) ufs.Tabnot.RemoveColumn(column) ufs.Obj.DeleteObject(column)Next Dim columns(nColumns -1)As NXOpen.TagFor ii AsInteger=0To nColumns -1If ii =0Then ufs.Tabnot.CreateColumn(20, columns(ii))Else ufs.Tabnot.CreateColumn(40, columns(ii))EndIf ufs.Tabnot.AddColumn(tabnote, columns(ii), UFConstants.UF_TABNOT_APPEND)Next Dim rows(nRows -1)As NXOpen.TagFor ii AsInteger=0To nRows -1 ufs.Tabnot.CreateRow(10, rows(ii)) ufs.Tabnot.AddRow(tabnote, rows(ii), UFConstants.UF_TABNOT_APPEND)NextReturn tabnote EndFunction PublicFunction GetUnloadOption(ByVal dummy AsString)AsIntegerReturn Session.LibraryUnloadOption.ImmediatelyEndFunction End Module
To all,
I am trying to understand if there is a fast way to convert a List (of Integer) into an array of (NX)taggedobject without looping through each item (of the list)
What I have
Dim ListofFEElmLabel As New List(Of Integer) Dim theTaggedObjects() As TaggedObject 'I'd like to convert the List into an array of different type Dim theOutputGroup As CAE.CaeGroup theOutputGroup = theCAEPart.CaeGroups.CreateGroup("NewgNXGroupName", theTaggedObjects)
Can this be done?
Thanks
Regards
Hi all!
I need journal, which removes all existing layers categories and makes all layers invisible.
Help me please.
Hi all!
In the layer setting menu has checkbox "Category Display".
But this check box is not supported in the process of recording journal.
I need to programmatically disable the display of categories, in this case, if they were turned off earlier, it is necessary that the program did not give a fatal error.
Can you please tell how to do it.
Part have a reference set "SOLIDS" and some other reference sets.
We need a code that adds in this reference set of all of the solid objects.
How i can do it in journal?
And one more my problem..
It should automatically wave freeze persistently the displayed part.
Is there any hope?
i have a assembly structure .i need to generate mid surface for each component and then translate the assy FILE into a parasolid at run time.
I am trying to populate a row of a tabular note by using a form. Is this possible?
Hi all,
Is there any Code available to Copy Selected component name to clipboard from properties > General tab,.....
NX 10.0.1.4
Hello, I am wondering if somebody can tell me what NXOpen API calls I can make to model something to specific dimensions.
What I am aiming to do is, create a little program that I can use to input dimensions so it will model pipe fittings for me. I need to model pipe fittings to specific dimensions so I can get accurate volume and fluid volume measurements. I can model these things by hand, but it would be nice if I could automate the process.
Any ideas?
I want to create a Journal that will create holes in reference to WCS. We wan't to have a button which (after placing the WCS on a face ; Z axis perpendicular to plane) will create hole at X,Y coordinates in reference to WCS.
Since AFAIK the only option in UG to position a hole is a sketch or datum, my idea is to create a Datum in WCS, reposition it to the new coords and create a Hole attached to this datum.
UPDATE:
I came up with code that creates Datums and Holes and looks like it works but the problem is that the Datums are broken. Origin is detached from Datum and after modification of one Datum all Datum CSYS are goint to the same point.
Can someone help me with that? I think the problem lies in the fixed reference to "POINT 1" CType(datumCsys2.FindObject("POINT 1")
I wanted to use CType(datumCsys2.Location) but it's a Point3D
I dont really know what effect has the:
rule1
helpPoint1
in .HolePosition.AddToSection(rules1, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint1, NXOpen.Section.Mode.Create, False)
"working" code
' NX 10.0.1.4' Journal created by wizdar on Mon Mar 21 12:52:39 2016 Mitteleuropäische Zeit'Option Strict OffImports System Imports NXOpen Imports NXOpen.UF Module NXJournal Dim theSession As NXOpen.Session= NXOpen.Session.GetSession()Dim workPart As NXOpen.Part= theSession.Parts.WorkDim ufs As UFSession = UFSession.GetUFSession()Dim displayPart As NXOpen.Part= theSession.Parts.Display Sub Main (ByVal args()AsString) Dim markId1 As NXOpen.Session.UndoMarkId markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start") 'How to make body select??Dim body1 As NXOpen.Body body1 = SelectSolid() Dim itargetBodies(0)As NXOpen.Body itargetBodies(0)= body1 IfNot workPart.Preferences.Modeling.GetHistoryModeThenThrow(New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))EndIf CreateHole(0, 0, itargetBodies) CreateHole(15, 0, itargetBodies) CreateHole(30, 0, itargetBodies) EndSub Sub CreateHole (xcoord AsDouble, ycoord AsDouble, targetBodies As NXOpen.Body()) Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature=Nothing Dim datumCsysBuilder1 As NXOpen.Features.DatumCsysBuilder datumCsysBuilder1 = workPart.Features.CreateDatumCsysBuilder(nullNXOpen_Features_Feature) Dim cartesianCoordinateSystem1 As NXOpen.CartesianCoordinateSystem cartesianCoordinateSystem1 = workPart.WCS.CoordinateSystem 'Define origin Dim orPt As Point3d orPt.X= xcoord orPt.Y= ycoord orPt.Z=0'New origin for CSYS cartesianCoordinateSystem1.Origin= WCS2Abs(orPt) datumCsysBuilder1.Csys= cartesianCoordinateSystem1 datumCsysBuilder1.DisplayScaleFactor=0.5 Dim nXObject1 As NXOpen.NXObject nXObject1 = datumCsysBuilder1.Commit() Dim datumCsys2 As NXOpen.Features.DatumCsys=CType(nXObject1, NXOpen.Features.DatumCsys) 'Need to select datum origin. Dim point1 As NXOpen.Point=CType(datumCsys2.FindObject("POINT 1"), NXOpen.Point) 'Dim point1 As NXOpen.Point = CType(datumCsys2.Location, NXOpen.Point) datumCsysBuilder1.Destroy() 'Create Hole PartDim nullNXOpen_Features_HolePackage As NXOpen.Features.HolePackage=Nothing Dim holePackageBuilder1 As NXOpen.Features.HolePackageBuilder holePackageBuilder1 = workPart.Features.CreateHolePackageBuilder(nullNXOpen_Features_HolePackage) 'Point Dim points1(0)As NXOpen.Point points1(0)= point1 Dim curveDumbRule1 As NXOpen.CurveDumbRule curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumbFromPoints(points1) Dim rules1(0)As NXOpen.SelectionIntentRule rules1(0)= curveDumbRule1 Dim nullNXOpen_NXObject As NXOpen.NXObject=Nothing Dim helpPoint1 As NXOpen.Point3d=New NXOpen.Point3d(0.0, 0.0, 0.0) With holePackageBuilder1 .HolePosition.AllowSelfIntersection(True) .HolePosition.AddToSection(rules1, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint1, NXOpen.Section.Mode.Create, False) .BooleanOperation.Type= NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract .BooleanOperation.SetTargetBodies(targetBodies) EndWith 'Hole Type 6With holePackageBuilder1 .GeneralHoleForm= Features.HolePackageBuilder.HoleForms.Simple .HoleDepthLimitOption= Features.HolePackageBuilder.HoleDepthLimitOptions.ThroughBody .GeneralSimpleHoleDiameter.RightHandSide="6" .GeneralSimpleHoleDepth.RightHandSide="12" .Tolerance=0.001 EndWith 'Commit HoleDim nXObject2 As NXOpen.NXObject nXObject2 = holePackageBuilder1.Commit() holePackageBuilder1.Destroy() EndSub Function SelectSolid()As Body Dim ui As UI = ui.GetUIDim message AsString="Select solid body"Dim title AsString="Selection" Dim scope As Selection.SelectionScope= Selection.SelectionScope.WorkPartDim keepHighlighted AsBoolean=FalseDim includeFeatures AsBoolean=True Dim selectionAction As Selection.SelectionAction= _ Selection.SelectionAction.ClearAndEnableSpecific Dim selectionMask_array(0)As Selection.MaskTripleWith selectionMask_array(0) .Type= UFConstants.UF_solid_type .Subtype=0 .SolidBodySubtype= UFConstants.UF_UI_SEL_FEATURE_SOLID_BODYEndWith Dim selectedObject As NXObject =NothingDim cursor As Point3d ui.SelectionManager.SelectObject(message, title, scope, _ selectionAction, includeFeatures, _ keepHighlighted, selectionMask_array, _ selectedObject, cursor) Dim solid As Body =CType(selectedObject, Body) If solid IsNothingThenReturnNothingEndIf Return solid EndFunction Function Abs2WCS(ByVal inPt As Point3d)As Point3d Dim pt1(2), pt2(2)AsDouble pt1(0)= inPt.X pt1(1)= inPt.Y pt1(2)= inPt.Z ufs.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_COORDS, pt1, _ UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt2) Abs2WCS.X= pt2(0) Abs2WCS.Y= pt2(1) Abs2WCS.Z= pt2(2) EndFunction Function WCS2Abs(ByVal inPt As Point3d)As Point3d Dim pt1(2), pt2(2)AsDouble pt1(0)= inPt.X pt1(1)= inPt.Y pt1(2)= inPt.Z ufs.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt1, _ UFConstants.UF_CSYS_ROOT_COORDS, pt2) WCS2Abs.X= pt2(0) WCS2Abs.Y= pt2(1) WCS2Abs.Z= pt2(2) EndFunction PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination EndFunction End Module
...leaves a Feature in the model.
That empty and unnamed feature is not erased if I destroy the builder. I can't figure out a way to find it and get rid of it.
The reason I need to do this is because I am using exception handling to retry to build the loft feature slightly differently until it gets it to commit.
If I try to delete it from the GUI I get a memory access violation error.
I've been able to write a function that will re-link a wave linked curve using a single curve selected through the BlockUIStyler's CurveCollector block. Now i want to use the SectionBuilder block instead.
I can't figure out how to set the section of the compositeCurveBuilder using the SectionBuilder's section object. it seems that the compositecurvebuilder only allows you to add a single curve at a time to the existing section.
public static void ReLinkCompositeSection(Part workPart, Part otherPart, String WaveLinkFeatureName, Section otherPartSection, DisplayableObject objectToVerifyDirection) { Session theSession = Session.GetSession(); NXOpen.Features.Feature startingCurrentFeature = workPart.CurrentFeature; NXOpen.Features.CompositeCurve waveLinkFeature = (NXOpen.Features.CompositeCurve)Utilities.GetNamedFeature(workPart, WaveLinkFeatureName); if (waveLinkFeature != null) { workPart.Features.SetEditWithRollbackFeature(waveLinkFeature); waveLinkFeature.MakeCurrentFeature(); NXOpen.Features.CompositeCurveBuilder compositeCurveBuilder1; compositeCurveBuilder1 = workPart.Features.CreateCompositeCurveBuilder(waveLinkFeature); compositeCurveBuilder1.Section.PrepareMappingData(); compositeCurveBuilder1.Section.DistanceTolerance = 0.001; compositeCurveBuilder1.Section.ChainingTolerance = 0.00095; compositeCurveBuilder1.FixAtCurrentTimestamp = true; /*builds section for a single line //NEED TO REPLACE THIS PORTION OF CODE TO USE the Section input parameter instead of otherPartLine //curves1[0] = otherPartLine; CurveDumbRule curveDumbRule1; curveDumbRule1 = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves1); compositeCurveBuilder1.Section.AllowSelfIntersection(false); SelectionIntentRule[] rules1 = new SelectionIntentRule[1]; rules1[0] = curveDumbRule1; NXObject nullNXObject = null; Point3d helpPoint1 = otherPartLine.StartPoint; compositeCurveBuilder1.Section.AddToSection(rules1, otherPartLine, nullNXObject, nullNXObject, helpPoint1, NXOpen.Section.Mode.Create, false); compositeCurveBuilder1.Associative = true; */ NXOpen.Features.Feature frecfeat = otherPart.CurrentFeature; compositeCurveBuilder1.FrecAtTimeStamp = frecfeat; //ensure direction is correct ICurve startElement; Point3d startPoint; Vector3d direction; compositeCurveBuilder1.Section.GetStartAndDirection(out startElement, out startPoint, out direction); Point linkedStartPoint = workPart.Points.CreatePoint(startPoint); Unit unit1 = (Unit)workPart.UnitCollection.FindObject("Inch"); MeasureDistance Dist; Dist = workPart.MeasureManager.NewDistance(unit1, NXOpen.MeasureManager.MeasureType.Minimum, objectToVerifyDirection, linkedStartPoint); if (Dist.Value < .5) { //start of wave linked curve should be at opposite side from the start point compositeCurveBuilder1.Section.ReverseDirectionOfLoop(0); } workPart.Points.DeletePoint(linkedStartPoint); NXObject nXObject2; nXObject2 = compositeCurveBuilder1.Commit(); nXObject2.SetName(WaveLinkFeatureName); //map old curve to new curve Section section1 = compositeCurveBuilder1.Section; NXObject[] outputs1; section1.GetOutputCurves(out outputs1); NXObject[] oldoutputs1; section1.GetOldOutputCurves(out oldoutputs1); section1.MapSectionElements((Line)oldoutputs1[0], (Line)outputs1[0]); section1.CleanMappingData(); compositeCurveBuilder1.Destroy(); //update model theSession.UpdateManager.InterpartDelay = true; startingCurrentFeature.MakeCurrentFeature(); } }