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

Edit part attribute in catagory

$
0
0

Dear all,

I'm trying to edit the text in one of the attributes of the part. However, I am unable to do so when the attribute is in a catagory. I don't think I am the first one who tries to do something like this. There is probably some code out there. Sadly enough I am not able to find it.

Any help would be greatly appriciated!

Kind regards,

Frank


Error/questions about a nongui running NX vb.script

$
0
0

Hello,

My name is Olaf I am longtime user of NX ( If 16 years is long) In my career I have written only two VB scripts, both using info of this site. I find it difficult how the NX objects are structured and my programming knowledge is before Object Oriented became mainstream.

Please could you look at my questions.

Start situation:

In NX a face divide into two parts by a plane. The intention of this script is to get the plane at such a position that both sides are equal.

However the code is not made that the left area divided by the right area equals 1, but the total area divided by the left area equals 2.

The result is as expected, the plane is positioned at the correct position.
However I have some messages appearing I don't understand.

Below is the result after running non_gui.bat. In this batch file the part and VisualBasic script is called, area_boundary_ratio.prt and plane_definition.vb.
In the block quote, the output of the script is given, some print statement are shown for debugging purposes and tracking of the program flow. But at the end messages are printed that I don't like or understand.

C:\Users\s021355\Dropbox\Master\afstuderen\VisualBasic\nongui>rem Run non_gui.bat

partLoadStatus1: PartLoadStatus 140699257591264
difference_area : 32.1460183660255
big_step : 5.35766972767092

Index : 0
expA.RightHandSide : 55
result total : 2485.84073464102
result left : 1885.84073464102
result division total_area/left_area : 1.3181604835332
Here I am value2 <= two_plus After End If: 1.3181604835332
Here I am value2 <= two_plus In the IF: 1.3181604835332
NOT (value2 < two_plus) AND (value2 > two_minus) : 1.3181604835332
Index third while : 1
expA.RightHandSide third while : 55
expA.RightHandSide third while after assign : 49.6423302723291
expA.RightHandSide third while after update : 49.6423302723291
result division total_area/left_area : 1.48716138328055
Index third while : 2
expA.RightHandSide third while : 49.6423302723291
expA.RightHandSide third while after assign : 44.2846605446582
expA.RightHandSide third while after update : 44.2846605446582
result division total_area/left_area : 1.70587044283165
Index third while : 3
expA.RightHandSide third while : 44.2846605446582
expA.RightHandSide third while after assign : 38.9269908169873
expA.RightHandSide third while after update : 38.9269908169873
result division total_area/left_area : 2
*** ERROR system never initialised, sending output to stderr ***

Journal execution results for C:\Users\s021355\Dropbox\Master\afstuderen\VisualB
asic\nongui\plane_definition.vb...
Execution was successful.

Journal execution results for C:\Users\s021355\Dropbox\Master\afstuderen\VisualB
asic\nongui\plane_definition.vb...
Execution was successful.

Press any key to continue . . .

My questions, how do I get rid of the message:
*** ERROR system never initialised, sending output to stderr ***

Why do I get two times?:
Journal execution results for C:\Users\s021355\Dropbox\Master\afstuderen\VisualB
asic\nongui\plane_definition.vb...
Execution was successful.

How do I code that the necessary expressions: height, left, total and plane_definition are found and when not I get an error message expression property is missing? I know it is something with try and catch

Last question, in what environment can I code the best with NX? Are there environments where you can debug instead of writing everywhere print statements?

What I have coded, thanks to the information at your forum plane_definition.vbs and non_gui.bar:

Thanks for your time.

Regards,

Olaf

rem Run non_gui.bat
@ECHO OFF
ECHO.
call "C:\Program Files\Siemens\NX 12.0\NXBIN\run_journal.exe" plane_definition.vb -args area_boundary_ratio.prt
rem Finished rem Run test_non_gui.bat
ECHO.
PAUSE()
CLS()
EXIT
Option Strict Off
Imports System
Imports NXOpen
 
Module startup_no_gui
     Dim theSession As Session = Session.GetSession()Dim lw As ListingWindow = theSession.ListingWindowDim workPart As Part
     Dim displayedPart As Part
    Dim sTextFile AsNew System.Text.StringBuilderDim sFileName AsString="C:\Users\s021355\Dropbox\Master\afstuderen\VisualBasic\test.txt"Sub Main(args()asstring)
        lw.Open()Const two_plus AsDouble=2.0001Const two_minus AsDouble=1.9999Dim big_step AsDouble=0.001Dim small_step AsDoubleConst undoMarkName AsString="NXJ query expressions"Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)Dim partSaveStatus1 As NXOpen.PartSaveStatus=Nothing
        OpenPart(args(0))Dim expA As NXOpen.Expression= workPart.Expressions.FindObject("plane_definition")' ----------------------------------------------'   Menu: File->Save' ----------------------------------------------
            partSaveStatus1 = workPart.Save(NXOpen.BasePart.SaveComponents.True, NXOpen.BasePart.CloseAfterSave.False)
            partSaveStatus1.Dispose()Dim height As NXOpen.Expression= workPart.Expressions.FindObject("height")Dim total As NXOpen.Expression= workPart.Expressions.FindObject("total")Dim left As NXOpen.Expression= workPart.Expressions.FindObject("left")Dim left_area asDoubleDim total_area asDoubleDim height_length asDoubleDim value2 asDoubleDim Index asIntegerDim nErrs1 AsIntegerDim difference_area AsDouble
            total=workPart.Expressions.FindObject("total")
            left=workPart.Expressions.FindObject("left")
            height=workPart.Expressions.FindObject("height")
            left_area =CType(left.value, Double)
            total_area =CType(total.value, Double)
            height_length=CType(height.value, Double)
            difference_area=Math.abs(total_area-2*left_area)/height_length
            big_step= difference_area/6
            lw.Writeline("difference_area : "& difference_area.ToString)
            lw.Writeline("big_step        : "& big_step.ToString)
            expA = workPart.Expressions.FindObject("plane_definition")
            nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
            value2=total_area/left_area
            lw.Writeline(" ")
            lw.Writeline("Index   : "& Index.ToString)
            lw.Writeline("expA.RightHandSide    : "& expA.RightHandSide.ToString)
            lw.WriteLine("result total    : "& total.Value.ToString)
            lw.Writeline("result left    : "& left.Value.Tostring)
            lw.Writeline("result division total_area/left_area : "& value2.ToString)IfNOT((value2> two_minus)AND(value2< two_plus))If value2 > two_plus ThenwhileNOT((value2 <= two_plus)AND(value2 >= two_minus))While value2 > two_plus
                            index+=1
                            lw.Writeline("Index first while  : "& Index.ToString)If index =50ThenExitWhileEndIf
                            expA.RightHandSide+= big_step
                            nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
                            lw.Writeline("expA.RightHandSide first while  : "& expA.RightHandSide.ToString)
                            total=workPart.Expressions.FindObject("total")
                            left=workPart.Expressions.FindObject("left")
                            left_area =CType(left.value, Double)
                            total_area =CType(total.value, Double)
                            value2=total_area/left_area
                            lw.Writeline("result division total_area/left_area : "& value2.ToString)EndWhile
                        small_step= big_step/3While value2 < two_minus
                            index+=1
                            lw.Writeline("Index second while   : "& Index.ToString)If index =50ThenExitWhileEndIf
                            expA.RightHandSide-= small_step
                            nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
                            lw.Writeline("expA.RightHandSide second while  : "& expA.RightHandSide.ToString)
                            total=workPart.Expressions.FindObject("total")
                            left=workPart.Expressions.FindObject("left")
                            left_area =CType(left.value, Double)
                            total_area =CType(total.value, Double)
                            value2=total_area/left_area
                            lw.Writeline("result division total_area/left_area : "& value2.ToString)EndWhile
                        big_step=small_step/3
                        index+=1
                        lw.Writeline("Index after while  : "& Index.ToString)
                        lw.Writeline("result division total_area/left_area : "& value2.ToString)
                        lw.Writeline("expA.RightHandSide second while  : "& expA.RightHandSide.ToString)EndWhileEndIF 
                lw.Writeline("Here I am value2 <= two_plus  After End If: "& value2.ToString)
                markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)If value2 < two_minus Then
                    lw.Writeline("Here I am value2 <= two_plus  In the IF: "& value2.ToString)whileNOT((value2 <= two_plus)AND(value2 >= two_minus))
                        lw.Writeline("NOT (value2 < two_plus) AND (value2 > two_minus) : "& value2.ToString)While value2 < two_minus
                            index+=1
                            lw.Writeline("Index third while  : "& Index.ToString)If index =50ThenExitWhileEndIf
                            lw.Writeline("expA.RightHandSide third while  : "& expA.RightHandSide.ToString)
                            expA.RightHandSide-= big_step
                            lw.Writeline("expA.RightHandSide third while after assign : "& expA.RightHandSide.ToString)
                            nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
                            lw.Writeline("expA.RightHandSide third while after update : "& expA.RightHandSide.ToString)
                            total=workPart.Expressions.FindObject("total")
                            left=workPart.Expressions.FindObject("left")
                            left_area =CType(left.value, Double)
                            total_area =CType(total.value, Double)
                            value2=total_area/left_area
                            lw.Writeline("result division total_area/left_area : "& value2.ToString)EndWhile
                        small_step=big_step/3While value2 > two_plus
                            index+=1
                            lw.Writeline("Index fourth while   : "& Index.ToString)If index =50ThenExitWhileEndIf
                            lw.Writeline("expA.RightHandSide fourth while  : "& expA.RightHandSide.ToString)
                            expA.RightHandSide+= small_step
                            nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
                            lw.Writeline("expA.RightHandSide fourth while  : "& expA.RightHandSide.ToString)
                            total=workPart.Expressions.FindObject("total")
                            left=workPart.Expressions.FindObject("left")
                            left_area =CType(left.value, Double)
                            total_area =CType(total.value, Double)
                            value2=total_area/left_area
                            lw.Writeline("result division total_area/left_area : "& value2.ToString)EndWhile
                        big_step=small_step/3EndWhileEndIfEndif
        System.IO.File.AppendAllText(sFileName, sTextFile.ToString)
        lw.Close()
        partSaveStatus1 = workPart.Save(NXOpen.BasePart.SaveComponents.True, NXOpen.BasePart.CloseAfterSave.False)
        partSaveStatus1.Dispose()EndSubsub OpenPart(byval thePart asstring)Dim basePart1 As BasePart
        Dim partLoadStatus1 As PartLoadStatus =Nothing
        basePart1 = theSession.Parts.OpenBaseDisplay(thePart, partLoadStatus1)
        lw.Writeline("partLoadStatus1: "& partLoadStatus1.ToString)
        sTextFile.AppendLine("partLoadStatus1: "& partLoadStatus1.ToString)
        displayedPart = theSession.Parts.Display
        workPart = theSession.parts.work 
        partLoadStatus1.Dispose()EndSub 
    PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger 
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately 
    EndFunction 
EndModule

Creating sketch on a user selected plane (or face) and sketch origin on a user selected point

$
0
0

Hi,

I have the following code that creates an sketch in a predefined sketch plane and point. But I would like user to select the plane and point (as sketch origin point). What is the best way to define the axis and point locations, so that the arcs, circles or lines follow the same direction and doesn't get distorted for changing planes?

Imports System
Imports NXOpen
Imports NXOpen.Selection
Imports NXOpen.UF
Imports NXOpenUI
 
 
Module NXJournal
 
    Dim theSession = NXOpen.Session.GetSession()
    Dim workPart = theSession.Parts.Work
    Dim displayPart As NXOpen.Part = theSession.Parts.Display
 
    Sub Main(ByVal args() As String)
 
        Dim origin As New NXOpen.Point3d(0, 0, 0)
        Dim axisX As New NXOpen.Point3d(1, 0, 0)
        Dim wcsMatrix As NXOpen.Matrix3x3 = workPart.WCS.CoordinateSystem.Orientation.Element
        Dim sketchPlane As NXOpen.DatumPlane = workPart.Datums.CreateFixedDatumPlane(origin, wcsMatrix)
        Dim horizAxis As NXOpen.DatumAxis = workPart.Datums.CreateFixedDatumAxis(origin, axisX)
 
 
        Dim sketchBuilder As NXOpen.SketchInPlaceBuilder
        sketchBuilder = workPart.Sketches.CreateNewSketchInPlaceBuilder(Nothing)
 
        sketchBuilder.PlaneOrFace.Value = sketchPlane
        sketchBuilder.Axis.Value = horizAxis
        sketchBuilder.SketchOrigin = workPart.Points.CreatePoint(origin)
 
        sketchBuilder.PlaneOption = NXOpen.Sketch.PlaneOption.Inferred
 
        Dim bridgeSketch As NXOpen.Sketch = sketchBuilder.Commit
 
        sketchBuilder.Destroy()
 
 
        bridgeSketch.Activate(NXOpen.Sketch.ViewReorient.False)
 
 
        Dim p0 As New NXOpen.Point3d(2, 0, 0)    ' Start point 
        Dim p1 As New NXOpen.Point3d(0, 0, 0)    ' End point 
        Dim pm As New NXOpen.Point3d(1, 1, 0)    ' Interior point 
        Dim gotFlipped As Boolean = False
        Dim bridge As NXOpen.Arc = workPart.Curves.CreateArc(p0, pm, p1, False, gotFlipped)
 
        theSession.ActiveSketch.AddGeometry(bridge,
         NXOpen.Sketch.InferConstraintsOption.InferNoConstraints)
 
        Dim arcPt0 As New NXOpen.Sketch.ConstraintGeometry
        arcPt0.Geometry = bridge
        arcPt0.PointType = NXOpen.Sketch.ConstraintPointType.StartVertex
        arcPt0.SplineDefiningPointIndex = 0
 
        Dim pt0 As New NXOpen.Sketch.ConstraintGeometry
        pt0.Geometry = workPart.Points.CreatePoint(p0)
        pt0.PointType = NXOpen.Sketch.ConstraintPointType.None
        pt0.SplineDefiningPointIndex = 0
 
        theSession.ActiveSketch.CreateCoincidentConstraint(arcPt0, pt0)
 
              Dim arcPt1 As New NXOpen.Sketch.ConstraintGeometry
        arcPt1.Geometry = bridge
        arcPt1.PointType = NXOpen.Sketch.ConstraintPointType.EndVertex
        arcPt1.SplineDefiningPointIndex = 0
 
        Dim pt1 As New NXOpen.Sketch.ConstraintGeometry
        pt1.Geometry = workPart.Points.CreatePoint(p1)
        pt1.PointType = NXOpen.Sketch.ConstraintPointType.None
        pt1.SplineDefiningPointIndex = 0
 
        Dim length As NXOpen.Expression = workPart.Expressions.CreateExpression("Number", "length = 2.5")
        Dim perimeter As NXOpen.Curve() = {bridge}
        theSession.ActiveSketch.CreatePerimeterDimension(perimeter, origin, length)
 
        theSession.ActiveSketch.LocalUpdate
        theSession.ActiveSketch.Deactivate(NXOpen.Sketch.ViewReorient.False, NXOpen.Sketch.UpdateLevel.Model)
 
    End Sub
End Module

Long run time when working with loaded assembly

$
0
0

I've put together some code to create text on face. Works fine with single part file. When I run it on part in a fully loaded assembly, run time is very long. What is the reason for this? I use NX12

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports MiniSnap
Imports System.Windows.Forms
Imports NXOpen.Features
 
 
Module Text_on_face
 
 
    Public theSession As NXOpen.Session = NXOpen.Session.GetSession()
    Public theUfSession As UFSession = UFSession.GetUFSession()
    Public workPart As NXOpen.Part = theSession.Parts.Work
    Public ui As UI = UI.GetUI()
    Public ufs As UFSession = UFSession.GetUFSession()
    Public prompt As String = "Select Position on Face"
    Public temptag As Tag = Tag.Null
    Public cp(2) As Double
    Public face1 As Face = Nothing
    Public facetag As Tag = Tag.Null
    Public pointC As Point = Nothing
    Public displayPart As NXOpen.Part = theSession.Parts.Display
    Public TextLayer As Integer = 45
 
    Sub Main()
 
 
 
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()
 
 
Start1:
 
        facetag = select_point_on_face(prompt, cp)
 
        If facetag = Tag.Null Then GoTo End1
        face1 = NXObjectManager.Get(facetag)
        Dim pnt3d As Point3d = New Point3d(cp(0), cp(1), cp(2))
 
        ' ----------------------------------------------
        Dim ufmodl As UFModl = theUfSession.Modl
        Dim faceType As Integer
        Dim facePt As Double() = New Double(2) {}
        Dim faceDir As Double() = New Double(2) {}
        Dim bbox As Double() = New Double(5) {}
        Dim faceRadius As Double
        Dim faceRadData As Double
        Dim normDirection As Integer
        Dim bodyObjFaceID As Tag
        ufmodl.AskFaceData(facetag, faceType, facePt, faceDir, bbox, faceRadius, faceRadData, normDirection)
        Dim dir As Vector = faceDir
        Dim uvminmax As Double() = New Double(3) {}
        ufmodl.AskFaceUvMinmax(facetag, uvminmax)
        ufmodl.AskFaceBody(facetag, bodyObjFaceID)
        Dim umin As Double = uvminmax(0)
        Dim vmin As Double = uvminmax(2)
        Dim surfaceValue As NXOpen.UF.ModlSrfValue = New NXOpen.UF.ModlSrfValue()
        Dim mode As Integer = NXOpen.UF.UFConstants.UF_MODL_EVAL_UNIT_NORMAL
        ufmodl.EvaluateFace(facetag, mode, New Double() {umin, vmin}, surfaceValue)
        Dim u As Vector = surfaceValue.srf_du
        Dim v As Vector = Vector.Cross(dir, u)
        Dim oriview As MiniSnap.Orientation = New MiniSnap.Orientation(workPart.ModelingViews.WorkView.Matrix)
        Dim a0 As Double = u * oriview.AxisX + v * oriview.AxisY
        Dim a1 As Double = v * oriview.AxisX - u * oriview.AxisY
        Dim a2 As Double = -u * oriview.AxisX - v * oriview.AxisY
        Dim faceA As NXOpen.Face = face1
        Dim text2DScale As Double = 130.0
        Dim text3DScale As Double = 90.0
        Dim nullNXOpen_Features_Text As NXOpen.Features.Text = Nothing
 
        ' ----------------------------------------------
        Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
 
        Dim text As String = "20"
 
 
        Dim textBuilder2 As NXOpen.Features.TextBuilder = Nothing
        Dim unit1 As NXOpen.Unit = Nothing
        textBuilder2 = workPart.Features.CreateTextBuilder(nullNXOpen_Features_Text)
        unit1 = textBuilder2.PrintMarkThickness.Units
        textBuilder2.CanReferenceText = False
        textBuilder2.PlanarFrame.AnchorLocation = NXOpen.GeometricUtilities.RectangularFrameBuilder.AnchorLocationType.MiddleCenter
        textBuilder2.PlanarFrame.Height.RightHandSide = "10"
        textBuilder2.PlanarFrame.WScale = text3DScale
        textBuilder2.PlanarFrame.Shear.RightHandSide = "0"
        textBuilder2.FrameOnPath.Height.RightHandSide = "10"
        textBuilder2.PrintMarkThickness.RightHandSide = "1"
        textBuilder2.TextString = text
        textBuilder2.SelectFont("Arial", NXOpen.Features.TextBuilder.ScriptOptions.CentralEuropean)
        theSession.SetUndoMarkName(markId1, "Text Dialog")
        Dim xform2 As NXOpen.Xform = Nothing
        xform2 = workPart.Xforms.CreateXform(faceA, NXOpen.SmartObject.UpdateOption.WithinModeling)
        Dim cartesianCoordinateSystem2 As NXOpen.CartesianCoordinateSystem = Nothing
        cartesianCoordinateSystem2 = workPart.CoordinateSystems.CreateCoordinateSystem(pnt3d, u, v)
        textBuilder2.PlanarFrame.CoordinateSystem = cartesianCoordinateSystem2
        ufs.Obj.DeleteObject(cartesianCoordinateSystem2.Tag)
        textBuilder2.PlanarFrame.UpdateOnCoordinateSystem()
        cartesianCoordinateSystem2.SetVisibility(SmartObject.VisibilityOption.Invisible)
        cartesianCoordinateSystem2.Evaluate()
        theSession.UpdateManager.ClearErrorList()
        Dim nXObject2 As NXOpen.NXObject = Nothing
        nXObject2 = textBuilder2.Commit()
        textBuilder2.Destroy()
 
 
 
        Dim allFeats() As Feature = displayPart.Features.ToArray()
        Dim topFeat As Integer = allFeats.GetUpperBound(0)
        Dim lastFeature As Feature = allFeats(topFeat)
        Dim myCurve As Curve
        Dim featTag As Tag = Tag.Null
        Dim myFeature As Features.Feature
 
        myFeature = Utilities.NXObjectManager.Get(lastFeature.Tag)
        ' lw.WriteLine("used by: " & myFeature.GetFeatureName)
 
        Dim FeatStr As String = myFeature.ToString.Substring(0, 4)
 
        If FeatStr = "Text" Then
            Dim numObjs As Integer
            Dim objs() As NXOpen.Tag = Nothing
 
            ufs.Modl.AskFeatObject(myFeature.Tag, numObjs, objs)
            For Each thisObj As NXOpen.Tag In objs
                ufs.Obj.SetLayer(thisObj, TextLayer)
            Next
 
        End If
 
        Dim stateArray1(0) As NXOpen.Layer.StateInfo
        stateArray1(0) = New NXOpen.Layer.StateInfo(TextLayer, NXOpen.Layer.State.Hidden)
        workPart.Layers.ChangeStates(stateArray1, False)
 
 
        Dim section1 As Section
        section1 = theSession.Parts.Work.Sections.CreateSection(0.00038, 0.0004, 0.5)
        section1.SetAllowedEntityTypes(Section.AllowTypes.OnlyCurves)
        Dim curveFeatureRule1 As CurveFeatureRule
        curveFeatureRule1 = theSession.Parts.Work.ScRuleFactory.CreateRuleCurveFeature({myFeature})
        section1.AllowSelfIntersection(True)
        Dim rules1(0) As SelectionIntentRule
        rules1(0) = curveFeatureRule1
        Dim nullNXObject As NXObject = Nothing
        section1.AddToSection(rules1, myCurve, nullNXObject, nullNXObject, Nothing, Section.Mode.Create, False)
 
        Dim nullFeatures_Feature As Features.Feature = Nothing
        Dim extrudeBuilder1 As Features.ExtrudeBuilder
        extrudeBuilder1 = theSession.Parts.Work.Features.CreateExtrudeBuilder(nullFeatures_Feature)
        extrudeBuilder1.Section = section1
        extrudeBuilder1.Limits.SymmetricOption = True
        extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = ".1"
        extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = ".1"
        extrudeBuilder1.Limits.StartExtend.TrimType = NXOpen.GeometricUtilities.Extend.ExtendType.Symmetric
        extrudeBuilder1.Limits.EndExtend.TrimType = NXOpen.GeometricUtilities.Extend.ExtendType.Symmetric
        extrudeBuilder1.AllowSelfIntersectingSection(True)
        extrudeBuilder1.DistanceTolerance = 0.001
        extrudeBuilder1.BooleanOperation.Type = GeometricUtilities.BooleanOperation.BooleanType.Create
        extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract
        Dim The_Body As NXOpen.Body = NXObjectManager.Get(bodyObjFaceID)
        Dim targetBodies2(0) As Body
        targetBodies2(0) = The_Body
        extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies2)
        Dim origin1 As Point3d = New Point3d(0.0, 0.0, 0.0)
        Dim vector1 As Vector3d = New Vector3d(0.0, 0.0, 1.0)
        Dim direction1 As Direction
        direction1 = theSession.Parts.Work.Directions.CreateDirection(pnt3d, dir, SmartObject.UpdateOption.WithinModeling)
        extrudeBuilder1.Direction = direction1
        extrudeBuilder1.Draft.DraftOption = GeometricUtilities.SimpleDraft.SimpleDraftType.NoDraft
        extrudeBuilder1.ParentFeatureInternal = False
        Dim feature1 As Features.Feature
        feature1 = extrudeBuilder1.CommitFeature()
        extrudeBuilder1.Destroy()
 
 
        workPart.Views.WorkView.Regenerate()
        theSession.SetUndoMarkName(markId1, "Text")
 
 
 
        GoTo Start1
End1:
 
 
    End Sub
 
 
 
 
    Public Sub map_view2abs(ByRef c() As Double)
        Dim vname As String = ""
        Dim abs_mx() As Double = {0, 0, 0, 1, 0, 0, 0, 1, 0}
        Dim vw() As Double = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        Dim mx() As Double = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        Dim irc As Integer = 0
        ufs.Ui.AskLastPickedView(vname)
        Dim wp As Part = theSession.Parts.Work
        Dim lastViewPicked As NXOpen.View = CType(wp.ModelingViews.FindObject(vname), ModelingView)
        Dim vmx As Matrix3x3 = lastViewPicked.Matrix()
        vw(3) = vmx.Xx
        vw(4) = vmx.Xy
        vw(5) = vmx.Xz
        vw(6) = vmx.Yx
        vw(7) = vmx.Yy
        vw(8) = vmx.Yz
        vw(9) = vmx.Zx
        vw(10) = vmx.Zy
        vw(11) = vmx.Zz
        ufs.Trns.CreateCsysMappingMatrix(vw, abs_mx, mx, irc)
        ufs.Trns.MapPosition(c, mx)
    End Sub
 
    Public Sub map_abs2view(ByRef c() As Double)
        Dim vname As String = ""
        Dim abs_mx() As Double = {0, 0, 0, 1, 0, 0, 0, 1, 0}
        Dim vw() As Double = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        Dim mx() As Double = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        Dim irc As Integer = 0
        ufs.Ui.AskLastPickedView(vname)
        Dim wp As Part = theSession.Parts.Work
        Dim lastViewPicked As NXOpen.View =
            CType(wp.ModelingViews.FindObject(vname), ModelingView)
        Dim vmx As Matrix3x3 = lastViewPicked.Matrix()
        vw(3) = vmx.Xx
        vw(4) = vmx.Xy
        vw(5) = vmx.Xz
        vw(6) = vmx.Yx
        vw(7) = vmx.Yy
        vw(8) = vmx.Yz
        vw(9) = vmx.Zx
        vw(10) = vmx.Zy
        vw(11) = vmx.Zz
        ufs.Trns.CreateCsysMappingMatrix(abs_mx, vw, mx, irc)
        ufs.Trns.MapPosition(c, mx)
 
    End Sub
 
    Public Sub ask_pos_on_obj(ByVal obj As NXOpen.Tag, ByVal loc() As Double)
        Dim aLine As NXOpen.Tag = NXOpen.Tag.Null
        Dim cp() As Double = {0, 0, 0}
        Dim dist As Double = 0
        Dim lp As UFCurve.Line
        Dim sp(2) As Double
        Dim ep(2) As Double
        lp.start_point = sp
        lp.end_point = ep
        map_abs2view(loc)
        lp.start_point(0) = loc(0)
        lp.start_point(1) = loc(1)
        lp.start_point(2) = loc(2) + 10000
        lp.end_point(0) = loc(0)
        lp.end_point(1) = loc(1)
        lp.end_point(2) = loc(2) - 10000
        map_view2abs(lp.start_point)
        map_view2abs(lp.end_point)
        ufs.Curve.CreateLine(lp, aLine)
        ufs.Modl.AskMinimumDist(obj, aLine, 0, cp, 0, cp, dist, loc, cp)
        ufs.Obj.DeleteObject(aLine)
    End Sub
 
    Public Function mask_for_face(ByVal select_ As IntPtr, ByVal userdata As IntPtr) As Integer
 
        Dim num_triples As Integer = 1
        Dim mask_triples(0) As UFUi.Mask
        mask_triples(0).object_type = UFConstants.UF_solid_type
        mask_triples(0).object_subtype = 0
        mask_triples(0).solid_type = UFConstants.UF_UI_SEL_FEATURE_ANY_FACE
        ufs.Ui.SetSelMask(select_,
                UFUi.SelMaskAction.SelMaskClearAndEnableSpecific,
                                          num_triples, mask_triples)
        Return UFConstants.UF_UI_SEL_SUCCESS
    End Function
 
    Public Function select_point_on_face(ByVal prompt As String, ByRef cp() As Double) As NXOpen.Tag
        Dim resp As Integer = 0
        Dim thing As NXOpen.Tag = NXOpen.Tag.Null
        Dim face1 As Face = Nothing
        Dim theView As NXOpen.Tag = NXOpen.Tag.Null
        Dim mask_face As UFUi.SelInitFnT = AddressOf mask_for_face
        Dim facetag As Tag = Tag.Null
        ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
        ufs.Ui.SelectWithSingleDialog("Select a face", prompt,
                    UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY,
                     mask_face, Nothing, resp, facetag, cp, theView)
        ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
        If resp = UFConstants.UF_UI_OBJECT_SELECTED Or
           resp = UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then
            ask_pos_on_obj(facetag, cp)
            ufs.Disp.SetHighlight(facetag, 0)
            Return facetag
        End If
        Return Tag.Null
    End Function
 
    Public Function PointFeatureOnFace(ByVal where As Point3d) As Point
        Dim markId1 As Session.UndoMarkId = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Create Point")
        Dim point1 As Point
        point1 = workPart.Points.CreatePoint(where)
        Dim nullFeatures_Feature As Features.Feature = Nothing
        Dim pointFeatureBuilder1 As Features.PointFeatureBuilder
        pointFeatureBuilder1 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)
        pointFeatureBuilder1.Point = point1
        Dim nXObject1 As NXObject = pointFeatureBuilder1.Commit()
        pointFeatureBuilder1.Destroy()
        Return point1
    End Function
 
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        '----Other unload options-------
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function
 
 
End Module
 
<code
 

Intersection curves using python

$
0
0

Hello there great people.
I am trying to create an intersection curve using Python and I am running into some issues that I can't figure out.

I have a given datum and a list of faces to create the curve from.
I am creating an intersection curve builder like the following:

intersectionCurveBuilder1 = workPart.Features.CreateIntersectionCurveBuilder(NXOpen.Features.Feature.Null)

Then I am converting the list of faces to tagged objects (I've red somewhere that it is required) and add them to the first set.

objects1 = [NXOpen.TaggedObject(face) for face in faces]
intersectionCurveBuilder1.FirstSet.Add(objects1)

I do the same for the datum

objects2 = NXOpen.TaggedObject(datum)
intersectionCurveBuilder1.SecondSet.Add(objects2)

Then I try to commit and destroy the builder

intersectionCurveBuilder1.Commit()
intersectionCurveBuilder1.Destroy()

Then an exception is raised at the line we are adding the faces to the first set, that saying:
Element number 0 no longer exists.
I couldn't find any information on this exception whatsoever, I could really use an advice.
Thanks in advance.

Creating point using a reference point an a planar face

$
0
0

Hello,

I am using below code to create a first point from the intersection between two user selected edges. Then creating a 2nd point with reference to the 1st point. But this 2nd point is only defined to be offsett by Y and Z direction of the workpart.

What would be the best way for this 2nd point to be created along the same planar face as the the 1st point is created? (Having hard time figuring out a way to define/ get the plane type or the vectors of the plane)

Imports System
Imports NXOpen
Imports NXOpen.Features
Imports NXOpen.UF
Imports NXOpenUI
 
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 edge1 As NXOpen.Edge = Nothing
        UserSelectEdge("Select X Direction", edge1)
        Dim edge2 As NXOpen.Edge = Nothing
        UserSelectEdge("Select Y Direction", edge2)
        Dim point1 As NXOpen.Point = Nothing
        Dim nullNXOpen_Point As NXOpen.Point = Nothing
        point1 = workPart.Points.CreatePoint(edge1, edge2, nullNXOpen_Point, nullNXOpen_Point, NXOpen.SmartObject.UpdateOption.WithinModeling)
        point1.SetVisibility(NXOpen.SmartObject.VisibilityOption.Visible)
 
        Dim unit1 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("Inch"), NXOpen.Unit)
        Dim unit2 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("Degrees"), NXOpen.Unit)
 
        Dim nullNXOpen_Unit As NXOpen.Unit = Nothing
        Dim nullNXOpen_Xform As NXOpen.Xform = Nothing
        Dim point2 As NXOpen.Point = Nothing
        point2 = workPart.Points.CreatePoint(point1, nullNXOpen_Xform, NXOpen.SmartObject.UpdateOption.WithinModeling)
        Dim expression17 As NXOpen.Expression = Nothing
        expression17 = workPart.Expressions.CreateSystemExpressionWithUnits("p374_xdelta=0.00000000000", unit1)
        Dim scalar1 As NXOpen.Scalar = Nothing
        scalar1 = workPart.Scalars.CreateScalarExpression(expression17, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.WithinModeling)
        Dim expression18 As NXOpen.Expression = Nothing
        expression18 = workPart.Expressions.CreateSystemExpressionWithUnits("p375_ydelta=5", unit1)
        Dim scalar2 As NXOpen.Scalar = Nothing
        scalar2 = workPart.Scalars.CreateScalarExpression(expression18, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.WithinModeling)
        Dim expression19 As NXOpen.Expression = Nothing
        expression19 = workPart.Expressions.CreateSystemExpressionWithUnits("p376_zdelta=6", unit1)
        Dim scalar3 As NXOpen.Scalar = Nothing
        scalar3 = workPart.Scalars.CreateScalarExpression(expression19, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.WithinModeling)
        Dim offset1 As NXOpen.Offset = Nothing
        offset1 = workPart.Offsets.CreateOffsetRectangular(scalar1, scalar2, scalar3, NXOpen.SmartObject.UpdateOption.WithinModeling)
        Dim point3 As NXOpen.Point = Nothing
        point3 = workPart.Points.CreatePoint(offset1, point2, NXOpen.SmartObject.UpdateOption.WithinModeling)
        point2.SetVisibility(NXOpen.SmartObject.VisibilityOption.Invisible)
        point3.SetVisibility(NXOpen.SmartObject.VisibilityOption.Visible)
        Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing
        Dim pointFeatureBuilder1 As NXOpen.Features.PointFeatureBuilder = Nothing
        pointFeatureBuilder1 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullNXOpen_Features_Feature)
        pointFeatureBuilder1.Point = point3
        Dim nXObject1 As NXOpen.NXObject = Nothing
        nXObject1 = pointFeatureBuilder1.Commit()
        pointFeatureBuilder1.Destroy()
 
    End Sub
 
    Function UserSelectEdge(ByVal prompt As String, ByRef SelBody As NXOpen.Edge) As Selection.Response
 
        Dim theUI As UI = UI.GetUI
        Dim title As String = prompt
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim selectionMask_array(0) As Selection.MaskTriple
        With selectionMask_array(0)
            .Type = NXOpen.UF.UFConstants.UF_solid_type
            .Subtype = NXOpen.UF.UFConstants.UF_solid_edge_subtype
            .SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE
        End With
        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt,
        title, scope, selAction,
        includeFeatures, keepHighlighted, selectionMask_array,
        SelBody, cursor)
        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
 
    End Function
 
 
End Module

passing argument to Main()

$
0
0

To all,

I had some note on the subject because I asked in the past but can't find them at the moment. I have a Nx.open (in vb) programme with the Main function defined as follows

Sub Main (ByVal arrsInMethod() As String)
 
if arrsInMethod(0) = "PA" Then
    gmiActionIdx = 1
    'other stuff
 
Else
   gmiActionIdx = 2
   'other stuff
end if	

the global variable gmiActionIdx is used by other programs to do/not not something
for example: if gmiActionIdx = 1 the GUI hide some buttons (on being displayed) and excite function #1 (if =2 show these buttons and execute function #2 when the user presses 'ok')

Question: How do I pass/set the argument to the Main(). I have 2 button in my NX custom toolbar button 1 (for option #1), button 2 (for option #2)

Thanks

------------------------------------------------------------------
EDIT
Found my notes. So obvious !!!
for 1st button
ACTION $UGII_USER_DIR\application\NXMacro.vb("PA")

for 2nd button
ACTION $UGII_USER_DIR\application\NXMacro.vb("PB")

Detect number of bodies

$
0
0

Dear all,

Thanks to you all, I created a journal some time ago to export a pdf of the drawing and a STEP of the model. I have been using this journal extensively and it is absolutely awesome. With one exception.

Sometimes parts have multiple bodies. The STEP export journal exports all bodies to the STEP file. This is not always desireble. However, the user doesn't know all the bodies are exported to STEP because some bodies are hidden and therefore not that visible. It is easy to make this mistake.

I would like to add a bit of code which can detect the amount of bodies in a part and warn the user that he is going to export a multiple body STEP.
Multiple bodies can occur within the part itself but also because the part contains another part (like an assembly). Both should be detected.

Until now I was able to write my own journals with the help of the record function. However, this is not possible with this problem.

Any help with this challenge will be greatly appreciated. Writing this code is near impossible for me to do.

Frank


Run 3rd Party DLL

$
0
0

Hello

With File/Execute/NXOpen i can choose a dll and start a routine from a siemens drawing frame program. I want to ask if it is possible to run a dll-File via a Journal. I found already a forum topic, where it is recommended to use

NXOpen.Session.Execute.

Following arguments are needed

( [string] libName, [string] className, [string] methodName, Object[] inputArgs )

https://docs.plm.automation.siemens.com/data_services/resources/nx/12/nx...

Is the execute method the right track? We don´t know how to write the syntax, because we don´t know anyhing about this program. Is it even possible to run this file via journal?

Thank you in advance and best regards

Delete selected faces (user selected)

$
0
0

Below is the recorded journal with added function for Selecteion of multiple edges, but can't figure out how the user selected edges will be linked to the delete face command. Can anyone help? Thanks in advanced...

Imports System
Imports NXOpen
Imports System.Collections.Generic
 
 
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 mySelectedObjects As NXObject()
        Dim theUI As UI = UI.GetUI()
        If SelectmultiObjects("Hey, select multiple somethings", mySelectedObjects) = Selection.Response.Ok Then
 
 
        End If
 
 
        Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing
        Dim deleteFaceBuilder1 As NXOpen.Features.DeleteFaceBuilder = Nothing
        deleteFaceBuilder1 = workPart.Features.CreateDeleteFaceBuilder(nullNXOpen_Features_Feature)
        Dim faces1(0) As NXOpen.Face
        Dim bodyFeature1 As NXOpen.Features.BodyFeature = CType(workPart.Features.FindObject("SB_MIGRATED_GROUND_PANEL(104)"), NXOpen.Features.BodyFeature)
        Dim face1 As NXOpen.Face = CType(bodyFeature1.FindObject("FACE 60 {(9.875,13.9,-0.06) SB_MIGRATED_GROUND_PANEL(104)}"), NXOpen.Face)
        faces1(0) = face1
        Dim faceDumbRule1 As NXOpen.FaceDumbRule = Nothing
        faceDumbRule1 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces1)
        Dim rules1(0) As NXOpen.SelectionIntentRule
        rules1(0) = faceDumbRule1
        deleteFaceBuilder1.FaceCollector.ReplaceRules(rules1, False)
        Dim faces2(1) As NXOpen.Face
        faces2(0) = face1
        Dim face2 As NXOpen.Face = CType(bodyFeature1.FindObject("FACE 59 {(11.9932915,12.3997989154561,-0.06) SB_MIGRATED_GROUND_PANEL(104)}"), NXOpen.Face)
        faces2(1) = face2
        Dim faceDumbRule2 As NXOpen.FaceDumbRule = Nothing
        faceDumbRule2 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces2)
        Dim rules2(0) As NXOpen.SelectionIntentRule
        rules2(0) = faceDumbRule2
        deleteFaceBuilder1.FaceCollector.ReplaceRules(rules2, False)
 
        deleteFaceBuilder1.Type = NXOpen.Features.DeleteFaceBuilder.SelectTypes.Face
        Dim nXObject1 As NXOpen.NXObject = Nothing
        nXObject1 = deleteFaceBuilder1.Commit()
        deleteFaceBuilder1.Destroy()
 
    End Sub
 
    Function SelectmultiObjects(prompt As String,
              ByRef selObj As NXObject()) As Selection.Response
 
        Dim theUI As UI = UI.GetUI
        Dim typeArray() As Selection.SelectionType =
            {Selection.SelectionType.All,
                Selection.SelectionType.Faces,
                Selection.SelectionType.Edges,
                Selection.SelectionType.Features}
 
        Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects(
                prompt, "Selection",
                Selection.SelectionScope.AnyInAssembly,
                False, typeArray, selObj)
 
        If resp = Selection.Response.ObjectSelected Or
                resp = Selection.Response.ObjectSelectedByName Or
                resp = Selection.Response.Ok Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
 
    End Function
 
End Module

NXopen.Point to Get Point3d as double

$
0
0

What is the best way to get Get Point3d as double from a Nxopen point? In my case the point was created from a centerpoint of a circular edge. Thanks for any help...

Journal for checking multiple parts with a single part

$
0
0

I have a outer assembly with which I need to check the clearance with a number of parts i.e part 1 with the outer assembly, part 2 with the outer assembly and so on i have a large no of parts to be checked. Can I get a journal to automize this process.

Extrudebuilder_ how let user to select the sketch that created programmatically

$
0
0

I've created the sketch programmatically in NX, but stuck in the extrudebuilder where I can't find a way for "Sketch selection" for Extruding.. Here is the recorded journal for Extrudebuilder below. Need help way to call the sketch I created (say "Sketch1" as I am calling it )to replace the recorded sketch

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_Feature As NXOpen.Features.Feature = Nothing
        Dim extrudeBuilder1 As NXOpen.Features.ExtrudeBuilder = Nothing
        extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature)
 
Dim section1 As NXOpen.Section = Nothing
section1 = workPart.Sections.CreateSection(0.00095, 0.001, 0.01)
 
extrudeBuilder1.Section = section1
        extrudeBuilder1.AllowSelfIntersectingSection(True)
        extrudeBuilder1.DistanceTolerance = 0.001
        extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create
 
        Dim targetBodies1(0) As NXOpen.Body
Dim nullNXOpen_Body As NXOpen.Body = Nothing
        targetBodies1(0) = nullNXOpen_Body
        extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies1)
 
extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0"
 
extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = "20.5"
 
extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract
 
Dim targetBodies2(0) As NXOpen.Body
Dim body1 As NXOpen.Body = CType(workPart.Bodies.FindObject("SB_MIGRATED_GROUND_PANEL(104)"), NXOpen.Body)
 
targetBodies2(0) = body1
extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies2)
 
extrudeBuilder1.Draft.FrontDraftAngle.RightHandSide = "2"
 
extrudeBuilder1.Draft.BackDraftAngle.RightHandSide = "2"
 
extrudeBuilder1.Offset.StartOffset.RightHandSide = "0"
 
extrudeBuilder1.Offset.EndOffset.RightHandSide = "0.25"
 
Dim smartVolumeProfileBuilder1 As NXOpen.GeometricUtilities.SmartVolumeProfileBuilder = Nothing
smartVolumeProfileBuilder1 = extrudeBuilder1.SmartVolumeProfile
 
smartVolumeProfileBuilder1.OpenProfileSmartVolumeOption = False
 
smartVolumeProfileBuilder1.CloseProfileRule = NXOpen.GeometricUtilities.SmartVolumeProfileBuilder.CloseProfileRuleType.Fci
 
theSession.SetUndoMarkName(markId1, "Extrude Dialog")
 
section1.DistanceTolerance = 0.001
 
section1.ChainingTolerance = 0.00095
 
section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves)
 
 
        Dim features1(0) As NXOpen.Features.Feature
Dim sketchFeature1 As NXOpen.Features.SketchFeature = CType(workPart.Features.FindObject("SKETCH(131)"), NXOpen.Features.SketchFeature)
 
features1(0) = sketchFeature1
Dim curveFeatureRule1 As NXOpen.CurveFeatureRule = Nothing
curveFeatureRule1 = workPart.ScRuleFactory.CreateRuleCurveFeature(features1)
 
section1.AllowSelfIntersection(True)
 
Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = curveFeatureRule1
Dim sketch1 As NXOpen.Sketch = CType(sketchFeature1.FindObject("SKETCH_000"), NXOpen.Sketch)
 
Dim arc1 As NXOpen.Arc = CType(sketch1.FindObject("Curve Arc73"), NXOpen.Arc)
 
Dim nullNXOpen_NXObject As NXOpen.NXObject = Nothing
 
Dim helpPoint1 As NXOpen.Point3d = New NXOpen.Point3d(12.727311938666357, 13.485341484614668, -5.5948246910244111e-13)
section1.AddToSection(rules1, arc1, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint1, NXOpen.Section.Mode.Create, False)
 
        Dim direction1 As NXOpen.Direction = Nothing
direction1 = workPart.Directions.CreateDirection(sketch1, NXOpen.Sense.Forward, NXOpen.SmartObject.UpdateOption.WithinModeling)
 
extrudeBuilder1.Direction = direction1
 
 
        extrudeBuilder1.Limits.StartExtend.TrimType = NXOpen.GeometricUtilities.Extend.ExtendType.ThroughAll
 
Dim nullNXOpen_DisplayableObject As NXOpen.DisplayableObject = Nothing
 
extrudeBuilder1.Limits.StartExtend.Target = nullNXOpen_DisplayableObject
 
extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = "2"
 
        extrudeBuilder1.ParentFeatureInternal = False
 
theSession.Preferences.Sketch.CreateInferredConstraints = True
 
theSession.Preferences.Sketch.ContinuousAutoDimensioning = True
 
theSession.Preferences.Sketch.DimensionLabel = NXOpen.Preferences.SketchPreferences.DimensionLabelType.Expression
 
theSession.Preferences.Sketch.TextSizeFixed = True
 
theSession.Preferences.Sketch.FixedTextSize = 0.12
 
theSession.Preferences.Sketch.DisplayParenthesesOnReferenceDimensions = True
 
theSession.Preferences.Sketch.DisplayReferenceGeometry = False
 
theSession.Preferences.Sketch.ConstraintSymbolSize = 3.0
 
theSession.Preferences.Sketch.DisplayObjectColor = False
 
theSession.Preferences.Sketch.DisplayObjectName = True
 
Dim feature1 As NXOpen.Features.Feature = Nothing
feature1 = extrudeBuilder1.CommitFeature()
 
        extrudeBuilder1.Destroy()
 
 
    End Sub
End Module

Cylindrical dimension text output

$
0
0

Hello everyone,

I have a journal that pulls all the dimensions from a drawing but I want on the diameters only to split that value in half.

I can't figure out the command to tell if it's a cylindrical dimension to split that in half.
In the dimension setting there is the Measurement tab that you chose the Method(Horizontal vertical, Cylindrical, etc).

This is the code I use to pull the text and tolerance information.

I am throwing all these pieces of information to a spreadsheet.

Thank you,

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.UpperMetricToleranceValue
objExcel.Cells(row, column+0) = myDimension.GetAppendedText().GetAfterText()
objExcel.Cells(row, column+3) = myDimension.GetAppendedText().GetBeforeText()

Add bounding box with weight output

$
0
0

I had a bounding box journal running with NX9/ Windows 7
Now I upgrade the OS to Windows 10 and this journal hangs when executed on NX9
Can someone please help me to fix this?
Thanks!

'=============================================================================
'   DutchAero
'   Patrick Delisse - 2008-05-11 - <a href="mailto:patrick.delisse@dutchaero.nl">  </a>
'   rev 2 - 2012-05-16 - Added the option to add extra material on all sides
'=============================================================================
 
 
Option Strict Off
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports System
Imports System.Math
 
 
 
Module BoxVolume
 
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim workPart As Part = s.Parts.Work
    Dim ui As UI = ui.GetUI()
    Dim body As NXObject = Nothing
 
    Dim markId1 As Session.UndoMarkId
 
    Dim nullFeatures_Feature As Features.Feature = Nothing
 
    Dim MyForm As New xxx
 
 
    Sub Main()
        markId1 = s.SetUndoMark(Session.MarkVisibility.Visible, "Start")
        Dim message As String = "Select a Block"
        Dim title1 As String = "Selection"
        Dim min_corner() As Double = {0.0, 0.0, 0.0}
        Dim directions(,) As Double = {{1.0, 0.0, 0.0}, _
                                       {0.0, 1.0, 0.0}, _
                                       {0.0, 0.0, 1.0}}
        Dim distances() As Double = {0.0, 0.0, 0.0}
        Dim csysTag As NXOpen.Tag = Tag.Null
        Dim workviewtag As NXOpen.Tag = Tag.Null
 
start1:
        SelectABody("Select Solid", body)
        On Error GoTo EndingIt
 
        If body.Tag <> Tag.Null Then
            ufs.Modl.AskBoundingBoxExact(body.Tag, csysTag, min_corner, directions, distances)
            ufs.Disp.SetHighlight(body.Tag, 0)
            DisplayBoundingBox(min_corner, directions, distances)
        End If
EndingIt:
 
    End Sub
    Public Sub SelectABody(ByVal prompt As String, ByRef obj As NXObject)
        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 cursor As Point3d = Nothing
 
 
        ui.SelectionManager.SelectTaggedObject(prompt, "Select a body", _
            Selection.SelectionScope.AnyInAssembly, _
            Selection.SelectionAction.ClearAndEnableSpecific, _
            False, False, mask, obj, cursor)
 
    End Sub
 
    Private Sub DisplayBoundingBox(ByRef min_corner As Double(), ByRef directions As Double(,), _
                                  ByRef distances As Double())
 
        Dim partUnits As Integer = 1
        ufs.Part.AskUnits(workPart.Tag, partUnits)
        Dim Unit As String
        Dim OtherUnit As String
        Dim Factor As Decimal
        Dim xp, xm, yp, ym, zp, zm As String
        If partUnits = 1 Then
            Unit = "mm"
            Factor = 1 / 25.4
            OtherUnit = "Inch"
        Else
            Unit = "inch"
            Factor = 25.4
            OtherUnit = "mm"
        End If
 
        Try
 
            If MyForm.ShowDialog = Windows.Forms.DialogResult.OK Then
                xp = Abs(CDec(Replace(MyForm.TextBox1.Text, ".", ",")))
                xm = Abs(CDec(Replace(MyForm.TextBox2.Text, ".", ",")))
                yp = Abs(CDec(Replace(MyForm.TextBox3.Text, ".", ",")))
                ym = Abs(CDec(Replace(MyForm.TextBox4.Text, ".", ",")))
                zp = Abs(CDec(Replace(MyForm.TextBox5.Text, ".", ",")))
                zm = Abs(CDec(Replace(MyForm.TextBox6.Text, ".", ",")))
            Else
                xp = 0
                yp = 0
                zp = 0
                xm = 0
                ym = 0
                zm = 0
            End If
 
 
            MyForm.Close()
            MyForm.Dispose()
            MyForm = Nothing
 
            Dim blockFeatureBuilder1 As Features.BlockFeatureBuilder
            blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullFeatures_Feature)
 
            blockFeatureBuilder1.BooleanOption.Type = GeometricUtilities.BooleanOperation.BooleanType.Create
 
            Dim targetBodies1(0) As Body
            Dim nullBody As Body = Nothing
 
            targetBodies1(0) = nullBody
            blockFeatureBuilder1.BooleanOption.SetTargetBodies(targetBodies1)
 
            s.SetUndoMarkName(markId1, "Block Dialog")
 
            Dim markId2 As Session.UndoMarkId
            markId2 = s.SetUndoMark(Session.MarkVisibility.Invisible, "Block")
 
            blockFeatureBuilder1.Type = Features.BlockFeatureBuilder.Types.OriginAndEdgeLengths
 
            Dim point1 As Point
            point1 = blockFeatureBuilder1.OriginPoint
 
            blockFeatureBuilder1.OriginPoint = point1
 
            'As the block only accepts dimensions as strings we need to convert our number to a string and replace decimal comma by decimal point.
            Dim Lengte As String
            Dim Breedte As String
            Dim Hoogte As String
            Lengte = Replace(CStr(distances(0) + xp + xm), ",", ".")
            Breedte = Replace(CStr(distances(1) + yp + ym), ",", ".")
            Hoogte = Replace(CStr(distances(2) + zp + zm), ",", ".")
 
            Dim originPoint1 As Point3d = New Point3d(min_corner(0) - xm, min_corner(1) - ym, min_corner(2) - zm)
            blockFeatureBuilder1.SetOriginAndLengths(originPoint1, Lengte, Breedte, Hoogte)
 
            blockFeatureBuilder1.SetBooleanOperationAndTarget(Features.Feature.BooleanType.Create, nullBody)
 
            Dim feature1 As Features.Feature
            feature1 = blockFeatureBuilder1.CommitFeature()
 
            Dim displayModification1 As DisplayModification
            displayModification1 = s.DisplayManager.NewDisplayModification()
            displayModification1.ApplyToAllFaces = True
            displayModification1.NewTranslucency = 70
 
            Dim objects1(0) As DisplayableObject
            Dim body1 As Body = nullBody
            Dim p As Integer = 0
            Dim i As Integer = 0
            Do While i = 0
                Try
                    body1 = CType(workPart.Bodies.FindObject("BLOCK(" & p & ")"), Body)
                    i = 1
                Catch ex As Exception
                    p = p + 1
                End Try
            Loop
            objects1(0) = body1
 
            displayModification1.Apply(objects1)
            displayModification1.Dispose()
 
            Dim cornX, cornY, cornZ As Decimal
            Dim lX, lY, lZ As Decimal
            cornX = min_corner(0) - xm
            cornY = min_corner(1) - ym
            cornZ = min_corner(2) - zm
            lX = distances(0) + xm + xp
            lY = distances(1) + ym + yp
            lZ = distances(2) + zm + zp
 
            s.ListingWindow.Open()
            s.ListingWindow.WriteLine("=================================================================")
            s.ListingWindow.WriteLine("*                     Part boundaries (Box)                     *")
            s.ListingWindow.WriteLine("=================================================================")
            s.ListingWindow.WriteLine(" ")
            s.ListingWindow.WriteLine(" Box Origin in X (" & Unit & ") = " & Math.Round(cornX, 3, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" Box Origin in Y (" & Unit & ") = " & Math.Round(cornY, 3, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" Box Origin in Z (" & Unit & ") = " & Math.Round(cornZ, 3, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" ")
            s.ListingWindow.WriteLine(" Box Length (X)  (" & Unit & ") = " & Math.Round(lX, 2, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" Box Width  (Y)  (" & Unit & ") = " & Math.Round(lY, 2, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" Box Height (Z)  (" & Unit & ") = " & Math.Round(lZ, 2, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" ")
            s.ListingWindow.WriteLine(" Box Length (X)  (" & OtherUnit & ") = " & Math.Round(lX * Factor, 3, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" Box Width  (Y)  (" & OtherUnit & ") = " & Math.Round(lY * Factor, 3, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" Box Height (Z)  (" & OtherUnit & ") = " & Math.Round(lZ * Factor, 3, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" ")
            s.ListingWindow.WriteLine(" Box Volume    (" & Unit & "^3) = " & Math.Round(lX * lY * lZ, 3, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine("               (Cm^3) = " & Math.Round(lX * lY * lZ / 1000, 2, MidpointRounding.AwayFromZero))
            s.ListingWindow.WriteLine(" ")
            s.ListingWindow.WriteLine(" ")
            If partUnits = 1 Then
                s.ListingWindow.WriteLine("=================================================================")
                s.ListingWindow.WriteLine(" Approximate Mass")
                s.ListingWindow.WriteLine(" ---------------------------------------------------------------")
                s.ListingWindow.WriteLine("    Aluminium (Kg) = " & Math.Round(lX * lY * lZ * 0.00000271, 3, MidpointRounding.AwayFromZero))
                s.ListingWindow.WriteLine("    Steel     (Kg) = " & Math.Round(lX * lY * lZ * 0.00000785, 3, MidpointRounding.AwayFromZero))
                s.ListingWindow.WriteLine("    Titanium  (Kg) = " & Math.Round(lX * lY * lZ * 0.0000045, 3, MidpointRounding.AwayFromZero))
                s.ListingWindow.WriteLine("    Inconel   (Kg) = " & Math.Round(lX * lY * lZ * 0.00000819, 3, MidpointRounding.AwayFromZero))
            End If
            s.ListingWindow.WriteLine("-----------------------------------------------------------------")
            s.ListingWindow.WriteLine(" ")
 
 
            s.DeleteUndoMark(markId2, Nothing)
 
            s.SetUndoMarkName(markId1, "Block")
 
            blockFeatureBuilder1.Destroy()
 
            workPart.FacetedBodies.DeleteTemporaryFacesAndEdges()
 
        Catch ex As Exception
            MsgBox("Check input!" & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Critical, "Cannot Calculate Bounding Box")
 
        End Try
 
    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
 
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
 
 
    End Function
    Public Function SetSolidDisplay(ByVal Kleur As Integer, ByVal Nr As Integer) As Integer
 
        On Error Resume Next
 
 
    End Function
 
End Module
 
 
Partial Class xxx
    Inherits System.Windows.Forms.Form
 
    Public Sub New()
        MyBase.New()
 
        'This call is required by the Windows Form Designer.
        InitializeComponent()
 
        'Add any initialization after the InitializeComponent() call
 
    End Sub
 
    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
 
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
 
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.TextBox1 = New System.Windows.Forms.TextBox()
        Me.TextBox2 = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.TextBox3 = New System.Windows.Forms.TextBox()
        Me.TextBox4 = New System.Windows.Forms.TextBox()
        Me.TextBox5 = New System.Windows.Forms.TextBox()
        Me.TextBox6 = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.Label7 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        ''Button1
        '
        Me.Button1.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Button1.Location = New System.Drawing.Point(12, 168)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(57, 23)
        Me.Button1.TabIndex = 6
        Me.Button1.Text = "Ok"
        Me.Button1.UseVisualStyleBackColor = True
        ''Button2
        '
        Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Button2.Location = New System.Drawing.Point(178, 168)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(57, 23)
        Me.Button2.TabIndex = 7
        Me.Button2.Text = "Cancel"
        Me.Button2.UseVisualStyleBackColor = True
        ''TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(52, 62)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(63, 20)
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "0"
        ''TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(152, 62)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(63, 20)
        Me.TextBox2.TabIndex = 1
        Me.TextBox2.Text = "0"
        ''Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(26, 65)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(20, 13)
        Me.Label1.TabIndex = 6
        Me.Label1.Text = "X+"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        ''Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(129, 65)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(17, 13)
        Me.Label2.TabIndex = 7
        Me.Label2.Text = "X-"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        ''TextBox3
        '
        Me.TextBox3.Location = New System.Drawing.Point(52, 88)
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(63, 20)
        Me.TextBox3.TabIndex = 2
        Me.TextBox3.Text = "0"
        ''TextBox4
        '
        Me.TextBox4.Location = New System.Drawing.Point(152, 88)
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(63, 20)
        Me.TextBox4.TabIndex = 3
        Me.TextBox4.Text = "0"
        ''TextBox5
        '
        Me.TextBox5.Location = New System.Drawing.Point(52, 114)
        Me.TextBox5.Name = "TextBox5"
        Me.TextBox5.Size = New System.Drawing.Size(63, 20)
        Me.TextBox5.TabIndex = 4
        Me.TextBox5.Text = "0"
        ''TextBox6
        '
        Me.TextBox6.Location = New System.Drawing.Point(152, 114)
        Me.TextBox6.Name = "TextBox6"
        Me.TextBox6.Size = New System.Drawing.Size(63, 20)
        Me.TextBox6.TabIndex = 5
        Me.TextBox6.Text = "0"
        ''Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(26, 91)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(20, 13)
        Me.Label3.TabIndex = 12
        Me.Label3.Text = "Y+"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        ''Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(26, 117)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(20, 13)
        Me.Label4.TabIndex = 13
        Me.Label4.Text = "Z+"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        ''Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(129, 91)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(17, 13)
        Me.Label5.TabIndex = 14
        Me.Label5.Text = "Y-"
        Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        ''Label6
        '
        Me.Label6.AutoSize = True
        Me.Label6.Location = New System.Drawing.Point(129, 117)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(17, 13)
        Me.Label6.TabIndex = 15
        Me.Label6.Text = "Z-"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        ''Label7
        '
        Me.Label7.AutoSize = True
        Me.Label7.Location = New System.Drawing.Point(26, 27)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(130, 13)
        Me.Label7.TabIndex = 16
        Me.Label7.Text = "Extra material to be added"
        Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        ''xxx
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center
        Me.ClientSize = New System.Drawing.Size(247, 203)
        Me.ControlBox = False
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.TextBox6)
        Me.Controls.Add(Me.TextBox5)
        Me.Controls.Add(Me.TextBox4)
        Me.Controls.Add(Me.TextBox3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "xxx"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Bounding Box"
        Me.ResumeLayout(False)
        Me.PerformLayout()
 
    End Sub
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
End Class

Issues opening VB Form that uses database to load Form

$
0
0

I am errors loading a VB form that access a database to load the information in datagridview and treeview. I can't load the load the form because of all these errors that are not recognizing the windows database terms. Is there any Reference I can add that would help recognizing the windows database terms?

Tolerance unit export

$
0
0

Hi, I have to pull tolerances from a drawing, right now I have to use two journals, one for millimeters and one for inches.
Is there a way to have a code that will pull whatever the print is in or the dimension?

For mm I use this code:
objExcel.Cells(row, column+2) = myDimension.UpperMetricToleranceValue

For inch I use this code:
objExcel.Cells(row, column+2) = myDimension.UpperToleranceValue

I can't figure out a way to pull the tolerance that is in the dimension using the dimension units.

Thank you,

Creating Angular Dimensions with NXOpen

$
0
0

I have I problem while creating Dimensions to display in my NX model. When I execute my code I get an Error saying: The object referencing was not set to an object instance (something like that, because it's translated from German). Someone an idea? Code below

NXOpen.Line line1 = workPart.Curves.CreateLine(StartPoint, EndPoint);
theSession.ActiveSketch.AddGeometry(line1, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints);
 
NXOpen.Point3d origin1 = new NXOpen.Point3d(0, 0, 0);
Point3d point2 = new Point3d(1, 0, 0);
NXOpen.Expression nullNXOpen_Expression = null;
 
NXOpen.Sketch.DimensionGeometry dimObject1_2 = new NXOpen.Sketch.DimensionGeometry(); 
dimObject1_2.Geometry = line1;
dimObject1_2.AssocType = NXOpen.Sketch.AssocType.EndPoint;
dimObject1_2.HelpPoint.X = 0;
dimObject1_2.HelpPoint.Y = 0;
dimObject1_2.HelpPoint.Z = 0;
 
NXOpen.Sketch.DimensionGeometry dimObject2_2 = new NXOpen.Sketch.DimensionGeometry(); 
NXOpen.DatumAxis ReferenceAxis = workPart.Datums.CreateFixedDatumAxis(origin1, point2);
dimObject2_2.Geometry = ReferenceAxis;
dimObject2_2.AssocType = NXOpen.Sketch.AssocType.EndPoint;
dimObject2_2.HelpPoint.X = 0;
dimObject2_2.HelpPoint.Y = 0;
dimObject2_2.HelpPoint.Z = 0;
 
NXOpen.Point3d dimOrigin2 = new NXOpen.Point3d(0, 0, 0);
NXOpen.SketchDimensionalConstraint sketchDimensionalConstraint2;
 
sketchDimensionalConstraint2 = theSession.ActiveSketch.CreateDimension(NXOpen.Sketch.ConstraintType.AngularDim, dimObject1_2, dimObject2_2, dimOrigin2, nullNXOpen_Expression, NXOpen.Sketch.DimensionOption.CreateAsAutomatic);

Is it possible to pause my running NXOpen-process and interact with NX? (e.g. move some points)

Combine all bodies

$
0
0

When I perform a body pattern, I'm usually not interested in dozens of bodies but instead one final solid.

Has anyone a journal that performs the boolean>combine process for all bodies?

Viewing all 783 articles
Browse latest View live


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