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

BlockUI Styler SetList

$
0
0

Hello guys :)
I`m a beginner with C# and NXOpen and i need some help :)

I want to create a Setlist for Collecting Curves with the Block UI Styler.

I Created 2 dlx. Files. 1.Setlist and 2. the CurveCollector.

Now i have to seed the .dlx File from the curve Collector in the initialize_cb() Function of the UI SetList.

But how ???

That´s how i tried it.

// Thats the path of the dlx File (CurveCollector)
                string sPath1 = System.AppDomain.CurrentDomain.BaseDirectory;
                string CurveCollector = (sPath1 + "CurveCollector.dlx");
 
 
   private NXOpen.BlockStyler.SetList seeder;// Block type: Set List
   seeder = new NXOpen.BlockStyler.SetList.SeedDlxFile(CurveCollector);
<code>
 
i hope you`ll help me :)
thanks :)

BlockUI Styler SetList

$
0
0

Hello guys :)
I`m a beginner with C# and NXOpen and i need some help :)

I want to create a Setlist for Collecting Curves with the Block UI Styler.

I Created 2 dlx. Files. 1.Setlist and 2. the CurveCollector.

Now i have to seed the .dlx File from the curve Collector in the initialize_cb() Function of the UI SetList.

But how ???

That´s how i tried it.

// Thats the path of the dlx File (CurveCollector)
                string sPath1 = System.AppDomain.CurrentDomain.BaseDirectory;
                string CurveCollector = (sPath1 + "CurveCollector.dlx");
 
 
   private NXOpen.BlockStyler.SetList seeder;// Block type: Set List
   seeder = new NXOpen.BlockStyler.SetList.SeedDlxFile(CurveCollector);
<code>
 
i hope you`ll help me :)
thanks :)

Placing a custom Stamp

$
0
0

Hi Everyone,

I have a situation here that...
I want to Custom symbol using journal
so that I can have buttons for different stamps
I tried to record and play but symbol is being placed always in the same place where it's been recorded (in it's natural way) but want to catch that symbol into cursor so that I can place wherever needed and open edit dialog box after placing......
Example "Recorded....."
Totally confused...........

Option Strict OffImports System
Imports NXOpen
 
Module NXJournal
Sub Main (ByVal args()AsString) 
Dim theSession As NXOpen.Session= NXOpen.Session.GetSession()Dim workPart As NXOpen.Part= theSession.Parts.Work 
Dim displayPart As NXOpen.Part= theSession.Parts.Display 
Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start") 
Dim nullNXOpen_Annotations_CustomSymbol As NXOpen.Annotations.CustomSymbol=Nothing 
Dim draftingCustomSymbolBuilder1 As NXOpen.Annotations.DraftingCustomSymbolBuilder
draftingCustomSymbolBuilder1 = workPart.Annotations.CustomSymbols.CreateDraftingCustomSymbolBuilder(nullNXOpen_Annotations_CustomSymbol) 
draftingCustomSymbolBuilder1.Origin.SetInferRelativeToGeometry(True) 
draftingCustomSymbolBuilder1.Origin.SetInferRelativeToGeometry(True) 
draftingCustomSymbolBuilder1.Origin.Anchor= NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter 
draftingCustomSymbolBuilder1.Scale.RightHandSide="1" 
draftingCustomSymbolBuilder1.Angle.RightHandSide="0" 
theSession.SetUndoMarkName(markId1, "Custom Symbol Dialog") 
draftingCustomSymbolBuilder1.Origin.Plane.PlaneMethod= NXOpen.Annotations.PlaneBuilder.PlaneMethodType.XyPlane 
draftingCustomSymbolBuilder1.Origin.SetInferRelativeToGeometry(True) 
Dim leaderData1 As NXOpen.Annotations.LeaderData
leaderData1 = workPart.Annotations.CreateLeaderData() 
leaderData1.StubSize=5.0 
leaderData1.Arrowhead= NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow 
leaderData1.VerticalAttachment= NXOpen.Annotations.LeaderVerticalAttachment.Center 
draftingCustomSymbolBuilder1.Leader.Leaders.Append(leaderData1) 
leaderData1.StubSide= NXOpen.Annotations.LeaderSide.Inferred 
draftingCustomSymbolBuilder1.SelectSymbol("C:\Users\Manhah Tashmeekh\Desktop\Mystamps\Ali\Shaik.sym.prt") 
draftingCustomSymbolBuilder1.Origin.SetInferRelativeToGeometry(True) 
draftingCustomSymbolBuilder1.Origin.SetInferRelativeToGeometry(True) 
' ----------------------------------------------'   Dialog Begin Custom Symbol' ----------------------------------------------Dim assocOrigin1 As NXOpen.Annotations.Annotation.AssociativeOriginData
assocOrigin1.OriginType= NXOpen.Annotations.AssociativeOriginType.DragDim nullNXOpen_View As NXOpen.View=Nothing 
assocOrigin1.View= nullNXOpen_View
assocOrigin1.ViewOfGeometry= nullNXOpen_View
Dim nullNXOpen_Point As NXOpen.Point=Nothing 
assocOrigin1.PointOnGeometry= nullNXOpen_Point
Dim nullNXOpen_Annotations_Annotation As NXOpen.Annotations.Annotation=Nothing 
assocOrigin1.VertAnnotation= nullNXOpen_Annotations_Annotation
assocOrigin1.VertAlignmentPosition= NXOpen.Annotations.AlignmentPosition.TopLeft
assocOrigin1.HorizAnnotation= nullNXOpen_Annotations_Annotation
assocOrigin1.HorizAlignmentPosition= NXOpen.Annotations.AlignmentPosition.TopLeft
assocOrigin1.AlignedAnnotation= nullNXOpen_Annotations_Annotation
assocOrigin1.DimensionLine=0
assocOrigin1.AssociatedView= nullNXOpen_View
assocOrigin1.AssociatedPoint= nullNXOpen_Point
assocOrigin1.OffsetAnnotation= nullNXOpen_Annotations_Annotation
assocOrigin1.OffsetAlignmentPosition= NXOpen.Annotations.AlignmentPosition.TopLeft
assocOrigin1.XOffsetFactor=0.0
assocOrigin1.YOffsetFactor=0.0
assocOrigin1.StackAlignmentPosition= NXOpen.Annotations.StackAlignmentPosition.Above
draftingCustomSymbolBuilder1.Origin.SetAssociativeOrigin(assocOrigin1) 
Dim point1 As NXOpen.Point3d=New NXOpen.Point3d(1023.95086050725, 139.404891304348, 0.0)
draftingCustomSymbolBuilder1.Origin.Origin.SetValue(Nothing, nullNXOpen_View, point1) 
draftingCustomSymbolBuilder1.Origin.SetInferRelativeToGeometry(True) 
Dim markId2 As NXOpen.Session.UndoMarkId
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Custom Symbol") 
Dim nXObject1 As NXOpen.NXObject
nXObject1 = draftingCustomSymbolBuilder1.Commit() 
theSession.DeleteUndoMark(markId2, Nothing) 
theSession.SetUndoMarkName(markId1, "Custom Symbol") 
theSession.SetUndoMarkVisibility(markId1, Nothing, NXOpen.Session.MarkVisibility.Visible) 
draftingCustomSymbolBuilder1.Destroy() 
Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start") 
Dim draftingCustomSymbolBuilder2 As NXOpen.Annotations.DraftingCustomSymbolBuilder
draftingCustomSymbolBuilder2 = workPart.Annotations.CustomSymbols.CreateDraftingCustomSymbolBuilder(nullNXOpen_Annotations_CustomSymbol) 
draftingCustomSymbolBuilder2.Origin.SetInferRelativeToGeometry(True) 
draftingCustomSymbolBuilder2.Origin.SetInferRelativeToGeometry(True) 
draftingCustomSymbolBuilder2.Origin.Anchor= NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter 
draftingCustomSymbolBuilder2.Scale.RightHandSide="1" 
draftingCustomSymbolBuilder2.Angle.RightHandSide="0" 
theSession.SetUndoMarkName(markId3, "Custom Symbol Dialog") 
draftingCustomSymbolBuilder2.Origin.Plane.PlaneMethod= NXOpen.Annotations.PlaneBuilder.PlaneMethodType.XyPlane 
draftingCustomSymbolBuilder2.Origin.SetInferRelativeToGeometry(True) 
Dim leaderData2 As NXOpen.Annotations.LeaderData
leaderData2 = workPart.Annotations.CreateLeaderData() 
leaderData2.StubSize=5.0 
leaderData2.Arrowhead= NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow 
leaderData2.VerticalAttachment= NXOpen.Annotations.LeaderVerticalAttachment.Center 
draftingCustomSymbolBuilder2.Leader.Leaders.Append(leaderData2) 
leaderData2.StubSide= NXOpen.Annotations.LeaderSide.Inferred 
draftingCustomSymbolBuilder2.SelectSymbol("C:\Users\Manhah Tashmeekh\Desktop\Mystamps\Ali\Shaik.sym.prt") 
draftingCustomSymbolBuilder2.Origin.SetInferRelativeToGeometry(True) 
draftingCustomSymbolBuilder2.Origin.SetInferRelativeToGeometry(True) 
draftingCustomSymbolBuilder2.Destroy() 
theSession.UndoToMark(markId3, Nothing) 
theSession.DeleteUndoMark(markId3, Nothing) 
' ----------------------------------------------'   Menu: Tools->Journal->Stop Recording' ---------------------------------------------- 
EndSubEnd Module

Creating new feature group

$
0
0

Hi,
Can any one please help me how to create a new feature group in VB?

I tried to run journal, but it doesn't support this command.

I am writing a code to create a feature group first and include all the features subsequently created inside that.

can some one please show me a sample using the following function?
CreateSetOfFeature ( _
name As String, _
features As Tag(), _
number_of_feature As Integer, _
hide_state As Integer, _
ByRef feature As Tag _
)

Thanks in advance.
Regards,
Nataraj

Call Sub from DLL - not found entry point

$
0
0

Hi!
not found the entry point in this simple example
what did I do wrong?

journal is compiled in the NX_fit.dll:

Option Strict OffImports System
Imports System.Collections.GenericImports NXOpen
Imports NXOpen.UFImports NXOpen.AnnotationsImports NXOpen.Assemblies 
Module NXJournal
Public theSession As Session = Session.GetSession()Public ufs As UFSession = UFSession.GetUFSession()Sub Main () 
Dim workPart As NXOpen.Part= theSession.Parts.WorkDim displayPart As NXOpen.Part= theSession.Parts.Display 
 fit() 
EndSub 
    Sub fit ()Dim workPart As NXOpen.Part= theSession.Parts.Work
workPart.ModelingViews.WorkView.Fit()EndSub 
End Module

journal of the caller of this dll:

Option Strict OffImports System
Imports System.Collections.GenericImports NXOpen
Imports NXOpen.UFImports NXOpen.AnnotationsImports NXOpen.Assemblies 
Module NXJournal
Public theSession As Session = Session.GetSession()Public ufs As UFSession = UFSession.GetUFSession() 
DeclareSub fit Lib "D:\macro\NX_fit.dll" 
Sub Main () 
Call fit
 
EndsubEnd Module

Get a geometry information of object

$
0
0

Hello.

I use Python, but I think it doesn't matter.

I need to get a geometry information of the Face as well as I get it through the user interface (Menu -> Information -> Object or Ctrl+I).

Actually I need just the following parameter:

Normal - Absolute    I  =   -0.420212290      
                     J  =   -0.907389507      
                     K  =   -0.008118760

I tried to record journal file:

selectedObjects1 = [NXOpen.NXObject.Null] * 1 
selectedObjects1[0] = face
self.theSession.Information.DisplayObjectsDetails(selectedObjects1)

But this code displays a ListingWindow. Of course I can parse it, but I think there is a better way.

How can I get this geometry parameter?

drawing sheet coordinates

Combine 4 Journal Files into One

$
0
0

Hello,

I have four journal files and needs to combine all in one, so that my work can be done faster.
The complexity is I have two journal files which have similar functionality with different parameters.
I hope this should cause any Problem for combining.
Let me know if this is possible to do.
I have attached all four journal files for your reference, the journal file name starts from "JOURNAL FILE 1", "JOURNAL FILE 2", "JOURNAL FILE 3"& "JOURNAL FILE 4".
And the code starts from below the journal file names.

 JOURNAL FILE1 
Option Strict OffImports System
Imports NXOpen
 
Module NXJournal
Sub Main (ByVal args()AsString) 
Dim theSession As Session = Session.GetSession()Dim workPart As Part = theSession.Parts.Work 
Dim displayPart As Part = theSession.Parts.Display 
' ----------------------------------------------'   Menu: Tools->Expressions...' ----------------------------------------------
theSession.Preferences.Modeling.UpdatePending=False 
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression") 
Dim expression1 As Expression =CType(workPart.Expressions.FindObject("setDESCRIPTION"), Expression) 
workPart.Expressions.Delete(expression1) 
Dim expression2 As Expression =CType(workPart.Expressions.FindObject("setHEAT_TREAT"), Expression) 
workPart.Expressions.Delete(expression2) 
Dim expression3 As Expression =CType(workPart.Expressions.FindObject("setPART_NO"), Expression) 
workPart.Expressions.Delete(expression3) 
Dim expression4 As Expression =CType(workPart.Expressions.FindObject("setSTAGE"), Expression) 
workPart.Expressions.Delete(expression4) 
Dim expression5 As Expression =CType(workPart.Expressions.FindObject("DESCRIPTION"), Expression) 
workPart.Expressions.Delete(expression5) 
Dim expression6 As Expression =CType(workPart.Expressions.FindObject("PART_NO"), Expression) 
workPart.Expressions.Delete(expression6) 
Dim expression7 As Expression =CType(workPart.Expressions.FindObject("DETAIL_NO"), Expression) 
workPart.Expressions.Delete(expression7) 
Dim expression8 As Expression =CType(workPart.Expressions.FindObject("DIE_NO"), Expression) 
workPart.Expressions.Delete(expression8) 
Dim expression9 As Expression =CType(workPart.Expressions.FindObject("DWG_TITLE"), Expression) 
workPart.Expressions.Delete(expression9) 
Dim expression10 As Expression =CType(workPart.Expressions.FindObject("DWG_TITLE_2"), Expression) 
workPart.Expressions.Delete(expression10) 
theSession.Preferences.Modeling.UpdatePending=False 
Dim nErrs1 AsInteger
nErrs1 = theSession.UpdateManager.DoUpdate(markId1) 
' ----------------------------------------------'   Menu: Tools->Journal->Stop Recording' ---------------------------------------------- 
EndSubEnd Module
 
 
JOURNAL FILE2 
Option Strict OffImports System
Imports NXOpen
 
Module Module4
 
    Sub Main() 
        Dim theSession As Session = Session.GetSession()If IsNothing(theSession.Parts.BaseWork)Then'active part requiredReturnEndIf 
        Dim workPart As Part = theSession.Parts.WorkDim lw As ListingWindow = theSession.ListingWindow
        lw.Open() 
        Const attributeName1 AsString="DWG_TITLE"Const attributeName2 AsString="DWG_TITLE_2"Const expName AsString="DESCRIPTION" 
        IfNot workPart.HasUserAttribute(attributeName1, NXObject.AttributeType.String, -1)Then
            lw.WriteLine("attribute "& attributeName1 &" not found, journal exiting")ReturnEndIf 
        IfNot workPart.HasUserAttribute(attributeName2, NXObject.AttributeType.String, -1)Then
            lw.WriteLine("attribute "& attributeName2 &" not found, journal exiting")ReturnEndIf 
        'get the underlying attribute expressionsDim attExp1 As Expression = workPart.Expressions.GetAttributeExpression(workPart, attributeName1, NXObject.AttributeType.String, -1)Dim attExp2 As Expression = workPart.Expressions.GetAttributeExpression(workPart, attributeName2, NXObject.AttributeType.String, -1) 
        'create/update the description expression using the attribute expressionsDim expDescription As Expression =NothingTry
            expDescription = workPart.Expressions.CreateExpression("String", expName &" = "& attExp1.Name&"+"" """&"+"& attExp2.Name)Catch ex As NXException
            If ex.ErrorCode=1050017Then'expression already exists 
                'get the existing expression
                expDescription = workPart.Expressions.FindObject(expName) 
                Dim markId2 As Session.UndoMarkId
                markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Expression edit") 
                'update the formula
                expDescription.RightHandSide= attExp1.Name&"+"" """&" +"& attExp2.Name 
                Dim nErrs1 AsInteger
                nErrs1 = theSession.UpdateManager.DoUpdate(markId2)Else'other error
                lw.WriteLine("NX exception: "& ex.ErrorCode&", "& ex.Message) 
            EndIf 
        EndTry 
        lw.Close() 
    EndSub 
 
    PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger 
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately 
    EndFunction 
End Module
 
JOURNAL FILE3 
Option Strict OffImports System
Imports NXOpen
 
Module Module4
 
    Sub Main() 
        Dim theSession As Session = Session.GetSession()If IsNothing(theSession.Parts.BaseWork)Then'active part requiredReturnEndIf 
        Dim workPart As Part = theSession.Parts.WorkDim lw As ListingWindow = theSession.ListingWindow
        lw.Open() 
        Const attributeName1 AsString="DIE_NO"Const attributeName2 AsString="DETAIL_NO"Const expName AsString="PART_NO" 
        IfNot workPart.HasUserAttribute(attributeName1, NXObject.AttributeType.String, -1)Then
            lw.WriteLine("attribute "& attributeName1 &" not found, journal exiting")ReturnEndIf 
        IfNot workPart.HasUserAttribute(attributeName2, NXObject.AttributeType.String, -1)Then
            lw.WriteLine("attribute "& attributeName2 &" not found, journal exiting")ReturnEndIf 
        'get the underlying attribute expressionsDim attExp1 As Expression = workPart.Expressions.GetAttributeExpression(workPart, attributeName1, NXObject.AttributeType.String, -1)Dim attExp2 As Expression = workPart.Expressions.GetAttributeExpression(workPart, attributeName2, NXObject.AttributeType.String, -1) 
        'create/update the description expression using the attribute expressionsDim expDescription As Expression =NothingTry
            expDescription = workPart.Expressions.CreateExpression("String", expName &" = "& attExp1.Name&"+""-"""&"+"& attExp2.Name)Catch ex As NXException
            If ex.ErrorCode=1050017Then'expression already exists 
                'get the existing expression
                expDescription = workPart.Expressions.FindObject(expName) 
                Dim markId2 As Session.UndoMarkId
                markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Expression edit") 
                'update the formula
                expDescription.RightHandSide= attExp1.Name&"+"" """&" +"& attExp2.Name 
                Dim nErrs1 AsInteger
                nErrs1 = theSession.UpdateManager.DoUpdate(markId2)Else'other error
                lw.WriteLine("NX exception: "& ex.ErrorCode&", "& ex.Message) 
            EndIf 
        EndTry 
        lw.Close() 
    EndSub 
 
    PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger 
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately 
    EndFunction 
End Module
 
JOURNAL FILE4 
JOURNALOption Strict OffImports System
Imports NXOpen
 
Module NXJournal
Sub Main (ByVal args()AsString) 
Dim theSession As Session = Session.GetSession()Dim workPart As Part = theSession.Parts.Work 
Dim displayPart As Part = theSession.Parts.Display 
' ----------------------------------------------'   Menu: File->Properties' ----------------------------------------------Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start") 
Dim objects1(0)As NXObject
objects1(0)= workPart
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects1, AttributePropertiesBuilder.OperationType.None) 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.DataType= AttributePropertiesBaseBuilder.DataTypeOptions.String 
attributePropertiesBuilder1.Units="MilliMeter" 
Dim objects2(0)As NXObject
objects2(0)= workPart
Dim massPropertiesBuilder1 As MassPropertiesBuilder
massPropertiesBuilder1 = workPart.PropertiesManager.CreateMassPropertiesBuilder(objects2) 
Dim selectNXObjectList1 As SelectNXObjectList
selectNXObjectList1 = massPropertiesBuilder1.SelectedObjects 
Dim objects3()As NXObject
objects3 = selectNXObjectList1.GetArray() 
massPropertiesBuilder1.UpdateOnSave= MassPropertiesBuilder.UpdateOptions.No 
massPropertiesBuilder1.LoadPartialComponents=True 
massPropertiesBuilder1.Accuracy=0.99 
Dim objects4(0)As NXObject
objects4(0)= workPart
Dim previewPropertiesBuilder1 As PreviewPropertiesBuilder
previewPropertiesBuilder1 = workPart.PropertiesManager.CreatePreviewPropertiesBuilder(objects4) 
previewPropertiesBuilder1.StorePartPreview=True 
previewPropertiesBuilder1.StoreModelViewPreview=True 
previewPropertiesBuilder1.ModelViewCreation= PreviewPropertiesBuilder.ModelViewCreationOptions.OnViewSave 
Dim objects5(0)As NXObject
objects5(0)= workPart
attributePropertiesBuilder1.SetAttributeObjects(objects5) 
attributePropertiesBuilder1.Units="MilliMeter" 
theSession.SetUndoMarkName(markId1, "Displayed Part Properties Dialog") 
attributePropertiesBuilder1.DateValue.DateItem.Day= DateItemBuilder.DayOfMonth.Day29 
attributePropertiesBuilder1.DateValue.DateItem.Month= DateItemBuilder.MonthOfYear.Apr 
attributePropertiesBuilder1.DateValue.DateItem.Year="2016" 
attributePropertiesBuilder1.DateValue.DateItem.Time="00:00:00" 
attributePropertiesBuilder1.Title="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.Title="DESCRIPTION" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="SET SCREW " 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Link to Expression") 
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Launch Expression Editor") 
' ----------------------------------------------'   Dialog Begin Expressions' ----------------------------------------------
attributePropertiesBuilder1.StringValue="SET SCREW " 
attributePropertiesBuilder1.IsReferenceType=False 
Dim expression1 As Expression =CType(workPart.Expressions.FindObject("DESCRIPTION"), Expression) 
attributePropertiesBuilder1.Expression= expression1
 
theSession.DeleteUndoMarksUpToMark(markId3, Nothing, False) 
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Accept Edit") 
Dim changed1 AsBoolean
changed1 = attributePropertiesBuilder1.CreateAttribute() 
attributePropertiesBuilder1.Title="" 
attributePropertiesBuilder1.IsReferenceType=False 
Dim nullExpression As Expression =Nothing 
attributePropertiesBuilder1.Expression= nullExpression
 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.Title="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.Title="CHECKED_DATE" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.Title="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.Title="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.Title="PART_NO" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="D220-30X-70800" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
Dim markId5 As Session.UndoMarkId
markId5 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Link to Expression") 
Dim markId6 As Session.UndoMarkId
markId6 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Launch Expression Editor") 
' ----------------------------------------------'   Dialog Begin Expressions' ----------------------------------------------
attributePropertiesBuilder1.StringValue="D220-30X-70800" 
attributePropertiesBuilder1.IsReferenceType=False 
Dim expression2 As Expression =CType(workPart.Expressions.FindObject("PART_NO"), Expression) 
attributePropertiesBuilder1.Expression= expression2
 
theSession.DeleteUndoMarksUpToMark(markId6, Nothing, False) 
Dim markId7 As Session.UndoMarkId
markId7 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Accept Edit") 
Dim changed2 AsBoolean
changed2 = attributePropertiesBuilder1.CreateAttribute() 
attributePropertiesBuilder1.Title="" 
attributePropertiesBuilder1.IsReferenceType=False 
attributePropertiesBuilder1.Expression= nullExpression
 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.StringValue="" 
attributePropertiesBuilder1.IsArray=False 
attributePropertiesBuilder1.IsArray=False 
Dim markId8 As Session.UndoMarkId
markId8 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Displayed Part Properties") 
theSession.DeleteUndoMark(markId8, Nothing) 
Dim markId9 As Session.UndoMarkId
markId9 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Displayed Part Properties") 
Dim nXObject1 As NXObject
nXObject1 = attributePropertiesBuilder1.Commit() 
Dim updateoption1 As MassPropertiesBuilder.UpdateOptions
updateoption1 = massPropertiesBuilder1.UpdateOnSave 
Dim nXObject2 As NXObject
nXObject2 = massPropertiesBuilder1.Commit() 
workPart.PartPreviewMode= BasePart.PartPreview.OnSave 
Dim nXObject3 As NXObject
nXObject3 = previewPropertiesBuilder1.Commit() 
Dim id1 As Session.UndoMarkId
id1 = theSession.GetNewestUndoMark(Session.MarkVisibility.Visible) 
Dim nErrs1 AsInteger
nErrs1 = theSession.UpdateManager.DoUpdate(id1) 
theSession.DeleteUndoMark(markId9, Nothing) 
theSession.SetUndoMarkName(markId1, "Displayed Part Properties") 
attributePropertiesBuilder1.Destroy() 
massPropertiesBuilder1.Destroy() 
previewPropertiesBuilder1.Destroy() 
theSession.DeleteUndoMark(id1, Nothing) 
theSession.DeleteUndoMark(markId5, Nothing) 
theSession.DeleteUndoMark(markId4, Nothing) 
theSession.DeleteUndoMark(markId2, Nothing) 
' ----------------------------------------------'   Menu: File->Save' ----------------------------------------------Dim part1 As Part
part1 = theSession.Parts.Display 
theSession.LogFile.WriteLine("") 
theSession.LogFile.WriteLine("Drafting Attributes User Exit starts here ############## ") 
theSession.LogFile.WriteLine("We are not in drafting, so let's not continue the user exit") 
Dim partSaveStatus1 As PartSaveStatus
partSaveStatus1 = workPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False) 
partSaveStatus1.Dispose()Dim partCloseResponses1 As PartCloseResponses
partCloseResponses1 = theSession.Parts.NewPartCloseResponses() 
workPart.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.UseResponses, partCloseResponses1) 
workPart =Nothing
displayPart =Nothing
partCloseResponses1.Dispose()' ----------------------------------------------'   Menu: Tools->Journal->Stop Recording' ---------------------------------------------- 
EndSubEnd Module FILE4

Find and replace note content

$
0
0

Hi,
I would like to find a specific Note with a name MAT and replace the content of that note in entire drawing, note was used more than 150 times in each drawing....
please help me with a code to replace that.....

Replace views

$
0
0

Hello all,

i have recorded a journal in NX where i move all my views, notes and dimension from sheet x to sheet y. This is because of a new titleblock.
in the past the pattern was used for this but the new templates are using the new titleblock function of NX.

What is the fastest way to change this.

My recorded script is always looking to the specified view names. How can i make this variable?

Kind regards

Ruud

' NX 10.0.3.5
' Journal created by Ruud on Mon May 30 13:37:49 2016 W. Europe Daylight Time
'
Option Strict Off
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: Format->Layer Settings...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
 
theSession.SetUndoMarkName(markId1, "Layer Settings Dialog")
 
Dim stateArray1(0) As NXOpen.Layer.StateInfo
stateArray1(0) = New NXOpen.Layer.StateInfo(256, NXOpen.Layer.State.Selectable)
workPart.Layers.ChangeStates(stateArray1, False)
 
Dim stateArray2(0) As NXOpen.Layer.StateInfo
stateArray2(0) = New NXOpen.Layer.StateInfo(256, NXOpen.Layer.State.Hidden)
workPart.Layers.ChangeStates(stateArray2, False)
 
theSession.SetUndoMarkName(markId1, "Layer Settings")
 
theSession.DeleteUndoMark(markId1, Nothing)
 
' ----------------------------------------------
'   Menu: Edit->Selection->Select All
' ----------------------------------------------
' Refer to the sample NXOpen application, Selection for "Select All" alternatives.
' ----------------------------------------------
'   Menu: Edit->Cut
' ----------------------------------------------
workPart.PmiManager.RestoreUnpastedObjects()
 
Dim markId2 As NXOpen.Session.UndoMarkId
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Drafting Cut")
 
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId2)
 
Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
 
Dim nullNXOpen_Drawings_DrawingSheet As NXOpen.Drawings.DrawingSheet = Nothing
 
Dim drawingSheetBuilder1 As NXOpen.Drawings.DrawingSheetBuilder
drawingSheetBuilder1 = workPart.DrawingSheets.DrawingSheetBuilder(nullNXOpen_Drawings_DrawingSheet)
 
drawingSheetBuilder1.AutoStartViewCreation = True
 
drawingSheetBuilder1.StandardMetricScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11
 
drawingSheetBuilder1.StandardEnglishScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11
 
drawingSheetBuilder1.AutoStartViewCreation = False
 
drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A0-Size2D-template.prt"
 
drawingSheetBuilder1.EnglishSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A-Size2D-template.prt"
 
drawingSheetBuilder1.Height = 841.0
 
drawingSheetBuilder1.Length = 1189.0
 
drawingSheetBuilder1.StandardMetricScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11
 
drawingSheetBuilder1.StandardEnglishScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11
 
drawingSheetBuilder1.ScaleNumerator = 1.0
 
drawingSheetBuilder1.ScaleDenominator = 1.0
 
drawingSheetBuilder1.Units = NXOpen.Drawings.DrawingSheetBuilder.SheetUnits.Metric
 
drawingSheetBuilder1.ProjectionAngle = NXOpen.Drawings.DrawingSheetBuilder.SheetProjectionAngle.Third
 
drawingSheetBuilder1.Number = "2"
 
drawingSheetBuilder1.SecondaryNumber = ""
 
drawingSheetBuilder1.Revision = "A"
 
theSession.SetUndoMarkName(markId3, "Sheet Dialog")
 
drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A0-Size2D-template.prt"
 
drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A2-Size2D-template.prt"
 
drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A0-Size2D-template.prt"
 
Dim markId4 As NXOpen.Session.UndoMarkId
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Sheet")
 
theSession.DeleteUndoMark(markId4, Nothing)
 
Dim markId5 As NXOpen.Session.UndoMarkId
markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Sheet")
 
Dim nXObject1 As NXOpen.NXObject
nXObject1 = drawingSheetBuilder1.Commit()
 
theSession.DeleteUndoMark(markId5, Nothing)
 
theSession.SetUndoMarkName(markId3, "Sheet")
 
drawingSheetBuilder1.Destroy()
 
workPart.Drafting.SetTemplateInstantiationIsComplete(True)
 
' ----------------------------------------------
'   Menu: Edit->Paste
' ----------------------------------------------
Dim markId6 As NXOpen.Session.UndoMarkId
markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Paste View(s)")
 
Dim baseView1 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Front@1"), NXOpen.Drawings.BaseView)
 
baseView1.RestoreViewBorder()
 
Dim detailView1 As NXOpen.Drawings.DetailView = CType(workPart.DraftingViews.FindObject("DETAIL@7"), NXOpen.Drawings.DetailView)
 
detailView1.RestoreViewBorder()
 
Dim detailView2 As NXOpen.Drawings.DetailView = CType(workPart.DraftingViews.FindObject("DETAIL@8"), NXOpen.Drawings.DetailView)
 
detailView2.RestoreViewBorder()
 
Dim detailView3 As NXOpen.Drawings.DetailView = CType(workPart.DraftingViews.FindObject("DETAIL@9"), NXOpen.Drawings.DetailView)
 
detailView3.RestoreViewBorder()
 
Dim baseView2 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Left@4"), NXOpen.Drawings.BaseView)
 
baseView2.RestoreViewBorder()
 
Dim baseView3 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Bottom@2"), NXOpen.Drawings.BaseView)
 
baseView3.RestoreViewBorder()
 
Dim baseView4 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Right@3"), NXOpen.Drawings.BaseView)
 
baseView4.RestoreViewBorder()
 
Dim detailView4 As NXOpen.Drawings.DetailView = CType(workPart.DraftingViews.FindObject("DETAIL@6"), NXOpen.Drawings.DetailView)
 
detailView4.RestoreViewBorder()
 
Dim views1(7) As NXOpen.Drawings.DraftingView
views1(0) = baseView1
views1(1) = detailView1
views1(2) = detailView2
views1(3) = detailView3
views1(4) = baseView2
views1(5) = baseView3
views1(6) = baseView4
views1(7) = detailView4
Dim drawingSheet1 As NXOpen.Drawings.DrawingSheet = CType(nXObject1, NXOpen.Drawings.DrawingSheet)
 
workPart.DraftingViews.MoveViewsToDrawing(views1, drawingSheet1)
 
Dim id1 As NXOpen.Session.UndoMarkId
id1 = theSession.NewestVisibleUndoMark
 
Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(id1)
 
' ----------------------------------------------
'   Menu: Edit->Delete...
' ----------------------------------------------
Dim markId7 As NXOpen.Session.UndoMarkId
markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Delete")
 
Dim notifyOnDelete1 As Boolean
notifyOnDelete1 = theSession.Preferences.Modeling.NotifyOnDelete
 
theSession.UpdateManager.ClearErrorList()
 
Dim markId8 As NXOpen.Session.UndoMarkId
markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Delete")
 
Dim objects1(0) As NXOpen.NXObject
Dim view1 As NXOpen.View = CType(workPart.Views.FindObject("Sheet 1@0"), NXOpen.View)
 
objects1(0) = view1
Dim nErrs3 As Integer
nErrs3 = theSession.UpdateManager.AddToDeleteList(objects1)
 
Dim notifyOnDelete2 As Boolean
notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete
 
Dim nErrs4 As Integer
nErrs4 = theSession.UpdateManager.DoUpdate(markId8)
 
theSession.DeleteUndoMark(markId7, Nothing)
 
' ----------------------------------------------
'   Menu: Format->Layer Settings...
' ----------------------------------------------
Dim markId9 As NXOpen.Session.UndoMarkId
markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
 
theSession.SetUndoMarkName(markId9, "Layer Settings Dialog")
 
Dim stateArray3(0) As NXOpen.Layer.StateInfo
stateArray3(0) = New NXOpen.Layer.StateInfo(256, NXOpen.Layer.State.Selectable)
workPart.Layers.ChangeStates(stateArray3, False)
 
Dim stateArray4(0) As NXOpen.Layer.StateInfo
stateArray4(0) = New NXOpen.Layer.StateInfo(256, NXOpen.Layer.State.Visible)
workPart.Layers.ChangeStates(stateArray4, False)
 
theSession.SetUndoMarkName(markId9, "Layer Settings")
 
theSession.DeleteUndoMark(markId9, Nothing)
 
' ----------------------------------------------
'   Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
 
End Sub
End Module
<code>

How to get the centre of mass of a face.

$
0
0

I can get the centroid of a Solid Body by using Measure Manager-newMassProperties.
But Its not possible with faces of the Body. I need the center of mass of the face.

How to find the common faces between to parts of an assembly?

$
0
0

I have two parts A,B.

A-is a body through which air can flow.
B-is the air flow profile ,that flows through A.

So they have common faces when assembled.(whhich are the faces which air touches when it flows).
I want t find these faces.

So essentially, I want to find the common faces of two parts in an assembly.

Thanks
Darvin.

Return Physical Material Usage

$
0
0

Does anyone know of a method to determine if a PhysicalMaterial is used in the current part?

I have
Dim LocalMaterials()As PhysicalMaterial = displaypart.MaterialManager.PhysicalMaterials.GetUsedMaterials

but this return materials that are used in components as well as displayPart. The Manage Materials windows differentiates between used, un-used, and used in components. I just can't seem to locate a method to get this information.

Ask function for UF constant UF_UI_SEL_FEATURE_SOLID_BODY

$
0
0

Hi all,

I am new to NXJournaling. I have been editing few Journals and using them to measure volume.

I have a doubt in UF constant method which has been used in a code block.

In this block of code , i want to add additional filter to select only solid bodies(Non -sheet bodies). I have found out the UF constant for the same.

"UF_UI_SEL_FEATURE_SOLID_BODY" this UF constant will select only solid bodies.

Dim aBodyTag As Tag = Tag.NullDo
            theUFSession.Obj.CycleObjsInPart(thePart.Tag, _
                UFConstants.UF_solid_type, aBodyTag) 
            If aBodyTag = Tag.NullThenExitDoEndIf 
             Dim theType AsInteger, theSubtype AsInteger
            theUFSession.Obj.AskTypeAndSubtype(aBodyTag, theType, theSubtype) 
            If theSubtype = UFConstants.UF_solid_body_subtypeThen                theBodies.Add(theSession.GetObjectManager.GetTaggedObject(aBodyTag))EndIf 
        LoopWhileTrue

So the new code block will have the following codes.

Dim thesolidsubtype AsInteger
    theUFSession.***.*************(thesolidsubtype)If thesolidsubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODYThen

I am not sure about the ask function (indicated in ****) for the solid body sub type.

Any help will be appreciated.

Problems combining Macro with Journal.

$
0
0

Hello, I would like to combine a macro with a Journal.

I’ve a macro and now I created a journal to export drawings to PDF, I need that this journal first call and execute the macro and then exporting to PDF.
The problem is the macro doesn’t execute until the journals ends.

What can I do to make the macro run before the rest of the Journal?

Thanks in advance.


How do I measure the displacement of a moved part while constraining in Assembly mode?

$
0
0

Hi All,

After constraining two face with Touch option in Assembly mode, how do I measure the displacement of a moved part? One part is cylindrical pim, the other is a fixed 3D surface. Pim moves and touches the surface using Assembly constraint(Touch Align --> Touch).

Could somebody help me?

Enkay

Dividing a surface in a constant value and finding center of mass.

$
0
0

Hello , How can I divide a surface's area to a constant integer value. After How can I calculate the each areas center of mass?
Thank you.

Regarding Zone location for diimensions in Nx drawings

$
0
0

Hi,
I am trying to write VB script for getting zone location, dimensions, Requirement symbols and GD&T symbols. Also want to export all the data to Spreadsheet.

Can anyone here please help me out regarding this?

Thanks & Regards,
Ravi

Problem with path.combine command

$
0
0

Hi
I am a bit of a novice when it comes to Journals, but have several files that work in NX7.5 that now don't work in NX10. they all appear to have the same problem:

If possible is anyone able to offer any advice.
Regards
Martyn

The journal below fails on lines 43,44,45,46,54,65 with the error

Line 43: 'path' is ambiguous, imported from the namespaces or types 'NXOpem.CAM, system.IO'

' NX 6.0.5.3
' Journal created by rt134694 on Tue Dec 14 10:27:51 2010 GMT Standard Time
' This journal copies the .brd file output by the EPAK software from the working
' or C:\temp directory (depends where user saved it) to a network folder for use
' in downstream apps

Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.CAM
Imports System.Windows.Forms

Public Class NXJournal
Public Shared destFolder As String
Public Shared sourceFolder1 As String
Public Shared sourceFolder2 As String
Public Shared fileName As String
Public Shared brdExt As String = ".brd"

Public Shared Sub Main(args As String())
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim ufUgMgr As UFUgmgr = theUfSession.Ugmgr
Dim brdSourcePath As String
Dim partName As String
Dim projName As String

' Get global variables
ufUgMgr.AskExportDirectory(workPart.Tag, sourceFolder1)
sourceFolder2 = Environment.GetEnvironmentVariable("TEMP")
destFolder = Environment.GetEnvironmentVariable("EPAK_DEST_DIR")

' Get Part Name
partName = AskPartName(workPart.Tag)

' Get Project Name
projName = partName.Substring((partName.IndexOf("-") + 1), 4)

' Check if brd file exists
If File.Exists(Path.Combine(sourceFolder1, partName & brdExt)) Then
brdSourcePath = Path.Combine(sourceFolder1, partName & brdExt)
ElseIf File.Exists(Path.Combine(sourceFolder2, partName & brdExt)) Then
brdSourcePath = Path.Combine(sourceFolder2, partName & brdExt)
Else
MessageBox.Show("Cannot find Board File to Export."& vbCr & vbLf & "Ensure you have run EPAK and saved the board file to either C:\Temp or the default working directory for this part."& vbCr & vbLf & "Also Ensure you use the correct naming convention PART-NAME-REV.brd (e.g. '"& partName & brdExt & "')")
Return
End If

' Create dest folder if needed
If projName.Length > 0 AndAlso partName.Length > 0 Then
destFolder = Path.Combine(destFolder, projName)
If Not Directory.Exists(destFolder) Then
Directory.CreateDirectory(destFolder)
End If
Else
MessageBox.Show("Can't determine Project Name or Part Name")
Return
End If

'Copy file to dest
Try
File.Copy(brdSourcePath, Path.Combine(destFolder, partName & brdExt), True)
MessageBox.Show("Board File Successfully Sent.")
Catch copyError As IOException
MessageBox.Show(copyError.Message)
Return
End Try
End Sub

' Good old Siemens - there is a method Part.Name but this doesn't work
' for some reason, raised as an issue, have to do it the hard way instead
Public Shared Function AskPartName(partTag As Tag) As String
Dim partName As String

Dim theUfSession As UFSession = UFSession.GetUFSession()
theUfSession.Part.AskPartName(partTag, partName)

Try
' Assemblies have different name string layout
Dim nameStartPos As Int32 = partName.IndexOf("AN=") + 3
Dim nameEndPos As Int32 = partName.IndexOf("", partName.IndexOf("AN="))
Dim nameLength As Int32 = nameEndPos - nameStartPos
partName = partName.Substring(nameStartPos, nameLength)
Catch
Dim nameStartPos As Int32 = partName.IndexOf("PN=") + 3
Dim nameEndPos As Int32 = partName.IndexOf("", partName.IndexOf("PN="))
Dim nameLength As Int32 = nameEndPos - nameStartPos
partName = partName.Substring(nameStartPos, nameLength) & "-"& partName.Substring((partName.IndexOf("PRN=") + 4), 1)
End Try
Return partName
End Function
End Class

[NXOpen VB.NET Journal] Working with Builders

$
0
0

Hello to everyone,

I'm trying to understand how to work with Builder features in NXOpen.
For example, if I want to make a circle with a diameter of 100.00mm, I usually have two ways:

1. Using the following journal VB code:

Option Strict Off
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
 
Dim origin3d As NXOpen.Point3d = New NXOpen.Point3d(0, 0, 0)
Dim arc_test As NXOpen.Arc
Dim Y As NXOpen.Vector3d = New NXOpen.Vector3d(0, 1, 0)
Dim Z As NXOpen.Vector3d = New NXOpen.Vector3d(0, 0, 1)
arc_test = workPart.Curves.CreateArc(origin3d, Y, Z, 50, 0, 2*System.Math.Pi)
MsgBox("Radius value is " & arc_test.Radius)
 
End Sub
End Module

2. Recording a Journal, then editing the code.

If I choose the second option, after tuning the output code of the recorded journal I obtain this result:

Option Strict Off
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
 
Dim nullNXOpen_Features_AssociativeArc As NXOpen.Features.AssociativeArc = Nothing
Dim associativeArcBuilder1 As NXOpen.Features.AssociativeArcBuilder
associativeArcBuilder1 = workPart.BaseFeatures.CreateAssociativeArcBuilder(nullNXOpen_Features_AssociativeArc)
 
associativeArcBuilder1.Associative = False
 
associativeArcBuilder1.Type = NXOpen.Features.AssociativeArcBuilder.Types.ArcFromCenter
associativeArcBuilder1.CenterPointReference = NXOpen.Features.AssociativeArcBuilder.CenterReference.Absolute
Dim origin3d As NXOpen.Point3d = New NXOpen.Point3d(0, 0, 0)
Dim origin As NXOpen.Point = workPart.Points.CreatePoint(origin3d)
associativeArcBuilder1.CenterPoint.Value = origin
 
associativeArcBuilder1.EndPointOptions = NXOpen.Features.AssociativeArcBuilder.EndOption.Radius
associativeArcBuilder1.Radius.RightHandSide = "50"
associativeArcBuilder1.Limits.FullCircle = True
 
Dim arc_test As NXOpen.Arc
arc_test = associativeArcBuilder1.Commit()
associativeArcBuilder1.Destroy()
 
MsgBox("Radius value is " & arc_test.Radius)
 
End Sub
End Module

To test the code, I simply ask for the radius value of the arc through a message box, which does not work in the second case.
If I use the first method, the radius value is correctly shown on a message box.

Now the question is: how to work with builders?
In the second method, I declare "arc_test" as an Arc which is the result of a Commit() of a builder. This should be true. But in the reality I cannot do anythig with that arc (like an extrusion, discover the radius value, etc, etc). I can only simply see the result on the part model.

Is there anyone who can help me?
Thank You in advance, best regards,

kalo86

Viewing all 783 articles
Browse latest View live