Showing results for 
Search instead for 
Do you mean 
Reply

Section Cut

Hello,

 

I want to create section cut for any part through Stand-alone Section Line.

So the user will first define it.

 

Anyone have an idea how to start?

 

Or if anybody has startup code then it will helpful to start...

 

I am using NX11.

 

2 REPLIES

Re: Section Cut

The usual answer ... try recording a journal. You'll get a huge pile of irrelevant stuff, but at least it will show you what functions to call.

山田
yamada

Re: Section Cut

Hi,

 

I did that and made some progress.

 

I have created 4 points in the Part model and by using those points coordinates, I am creating stand-alone section line and through that creating Sections.

First I am placing section view at some specified location on drawing and then by calculating section view height and length and sheet height, I am placing it in the specified location.

 

Below is the code which I have used.

 

Please let me know the where I have to improve in my code...

 

   Sub CreateSection(SPnt As Point3d, EPnt As Point3d, DisX As Double, DisY As Double)


        '-----------Create Section Line From SecVirewPoint List----------------------------------------------------------------------------------
        objSectionLine = Nothing
        Sec_LineBuilder = Nothing
        Sketch_InDraftingBuilder = Nothing

        Sec_LineBuilder = workPart.Drafting.SectionLines.CreateSketchSectionLineBuilder(objSectionLine)


        Dim baseView1 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject(ActViewName), NXOpen.Drawings.BaseView)
        Sec_LineBuilder.ParentView.View.Value = baseView1

        theSession.BeginTaskEnvironment()

        Sketch_InDraftingBuilder = workPart.Sketches.CreateSketchInDraftingBuilder()

        Dim selectView1 As NXOpen.SelectView = Nothing
        selectView1 = Sketch_InDraftingBuilder.View

        selectView1.Value = baseView1

        theSession.Preferences.Sketch.CreateInferredConstraints = True
        theSession.Preferences.Sketch.ContinuousAutoDimensioning = False
        theSession.Preferences.Sketch.DimensionLabel = NXOpen.Preferences.SketchPreferences.DimensionLabelType.Value
        theSession.Preferences.Sketch.ConstraintSymbolSize = 3.0
        theSession.Preferences.Sketch.DisplayObjectColor = False
        theSession.Preferences.Sketch.DisplayObjectName = True

        Dim nXObject1 As NXOpen.NXObject = Nothing
        nXObject1 = Sketch_InDraftingBuilder.Commit()

        Sketch_InDraftingBuilder.Destroy()

        Dim sketch1 As NXOpen.Sketch = CType(nXObject1, NXOpen.Sketch)

        sketch1.Activate(NXOpen.Sketch.ViewReorient.True)


        Dim startPoint1 As NXOpen.Point3d = New NXOpen.Point3d(SPnt.X, SPnt.Y, SPnt.Z)
        Dim endPoint1 As NXOpen.Point3d = New NXOpen.Point3d(EPnt.X, EPnt.Y, EPnt.Z)
        Dim SecLine As NXOpen.Line = Nothing
        SecLine = workPart.Curves.CreateLine(startPoint1, endPoint1)

        theSession.ActiveSketch.AddGeometry(SecLine, NXOpen.Sketch.InferConstraintsOption.InferNoConstraints)
        theSession.ActiveSketch.Update()

        theSession.ActiveSketch.Deactivate(NXOpen.Sketch.ViewReorient.True, NXOpen.Sketch.UpdateLevel.SketchOnly)
        theSession.DeleteUndoMarksSetInTaskEnvironment()
        theSession.EndTaskEnvironment()


        Dim curves1(0) As NXOpen.IBaseCurve

        curves1(0) = SecLine
        Dim curveDumbRule1 As NXOpen.CurveDumbRule = Nothing
        curveDumbRule1 = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves1)

        Sec_LineBuilder.SketchSection.AllowSelfIntersection(True)

        Dim rules1(0) As NXOpen.SelectionIntentRule
        rules1(0) = curveDumbRule1
        Dim nullNXOpen_NXObject As NXOpen.NXObject = Nothing

        Dim helpPoint2 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
        Sec_LineBuilder.SketchSection.AddToSection(rules1, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint2, NXOpen.Section.Mode.Create, False)

        Dim refs1() As NXOpen.NXObject
        Sec_LineBuilder.SketchSection.EvaluateAndAskOutputEntities(refs1)

        Sec_LineBuilder.SetSketch(sketch1)

        Dim nXObject2 As NXOpen.NXObject = Nothing
        nXObject2 = Sec_LineBuilder.Commit()

        Sec_LineBuilder.Destroy()
        '------------------------------------------------------------------------------------------------------------------------------------------


        '------------Create SectionView throught Created Section Line---------------------------------------------------------------------------------
        Dim sectionViewBuilder1 As NXOpen.Drawings.SectionViewBuilder = Nothing
        sectionViewBuilder1 = workPart.DraftingViews.CreateSectionViewBuilder(nullNXOpen_NXObject)

        sectionViewBuilder1.ViewPlacement.Associative = True
        sectionViewBuilder1.ViewPlacement.AlignmentMethod = NXOpen.Drawings.ViewPlacementBuilder.Method.PerpendicularToHingeLine
        Dim nullNXOpen_Direction As NXOpen.Direction = Nothing

        'sectionViewBuilder1.ViewPlacement.AlignmentOption = NXOpen.Drawings.ViewPlacementBuilder.Option.ModelPo
        sectionViewBuilder1.SectionViewMode = NXOpen.Drawings.SectionViewBuilder.SectionViewModeType.StandAlone
        sectionViewBuilder1.ViewStyle.ViewStyleOrientation.HingeLine.VectorOption = NXOpen.Drawings.HingeLineBuilder.Hingeline.Defined
        sectionViewBuilder1.CreateFolded = False
        sectionViewBuilder1.SecondaryComponents.ObjectType = NXOpen.Drawings.DraftingComponentSelectionBuilder.Geometry.PrimaryGeometry

        Dim unit1 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), NXOpen.Unit)

        Dim expression1 As NXOpen.Expression = Nothing
        expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

        Dim sketchedSteppedSectionLine1 As NXOpen.Drawings.SketchedSteppedSectionLine = CType(nXObject2, NXOpen.Drawings.SketchedSteppedSectionLine)
        sectionViewBuilder1.SectionLine.SectionLine.Value = sketchedSteppedSectionLine1
        sectionViewBuilder1.ParentView.View.Value = baseView1
       
        'sectionViewBuilder1.ViewStyle.ViewStyleBase.PartName = "C:\Users\ashethb\Documents\svn\nxCreate\Section_Layout_V01\partTemplates\Trial.prt"

        sectionViewBuilder1.ViewStyle.ViewStyleDetail.Orient = True
        sectionViewBuilder1.ViewStyle.ViewStyleGeneral.ToleranceValue = 0.092256856187290959


        sectionViewBuilder1.ViewPlacement.AlignmentMethod = NXOpen.Drawings.ViewPlacementBuilder.Method.Infer
        sectionViewBuilder1.ViewPlacement.AlignmentVector = nullNXOpen_Direction


        '  sectionViewBuilder1.ViewPlacement.AlignmentView.Value = Nothing

        sectionViewBuilder1.ViewPlacement.AlignmentOption = NXOpen.Drawings.ViewPlacementBuilder.Option.ToView

        ' Dim point5 As NXOpen.Point3d = New NXOpen.Point3d(200.0, 300.0, 0.0)

        Dim point5 As NXOpen.Point3d = New NXOpen.Point3d(100, 100, 0.0)
        sectionViewBuilder1.ViewPlacement.Placement.SetValue(Nothing, workPart.Views.WorkView, point5)


        sectionViewBuilder1.ViewPlacement.AlignmentView.Value = Nothing
        'sectionViewBuilder1.ViewPlacement.AlignmentView.Value = baseView1

        Dim nXObject3 As NXOpen.NXObject = Nothing
        nXObject3 = sectionViewBuilder1.Commit()


        sectionViewBuilder1.Destroy()
        workPart.Expressions.Delete(expression1)


        Dim objects1(0) As NXOpen.NXObject
        Dim sectionView1 As NXOpen.Drawings.SectionView = CType(nXObject3, NXOpen.Drawings.SectionView)

        objects1(0) = sectionView1
        Dim objectGeneralPropertiesBuilder1 As NXOpen.ObjectGeneralPropertiesBuilder = Nothing
        objectGeneralPropertiesBuilder1 = workPart.PropertiesManager.CreateObjectGeneralPropertiesBuilder(objects1)


        'Dim selectNXObjectList1 As NXOpen.SelectNXObjectList = Nothing
        'selectNXObjectList1 = objectGeneralPropertiesBuilder1.SelectedObjects

        'objectGeneralPropertiesBuilder1.Name = ""

        'objectGeneralPropertiesBuilder1.NameLocationSpecified = False

        'objectGeneralPropertiesBuilder1.Index = 1

        'Dim nXObject5 As NXOpen.NXObject = Nothing
        'nXObject5 = objectGeneralPropertiesBuilder1.Commit()
        'objectGeneralPropertiesBuilder1.Destroy()


        dwgShtBld = workPart.DrawingSheets.DrawingSheetBuilder(workPart.DrawingSheets.CurrentDrawingSheet)

        'OH = dwgShtBld.Length
        OV = dwgShtBld.Height
        '   DisY = 50

        dwgShtBld.Commit()
        dwgShtBld.Destroy()

        SecViewSize(0) = 0
        SecViewSize(1) = 0
        SecViewSize(2) = 0
        SecViewSize(3) = 0
        theUfSession.Draw.AskViewBorders(sectionView1.Tag, SecViewSize)

        SecViewLength = Math.Round(SecViewSize(2) - SecViewSize(0)) / 2
        SecViewHeight = Math.Round(SecViewSize(3) - SecViewSize(1)) / 2

        ' Add View Height into List to compare 
        ' LastViewHeight.Add(SecViewHeight)

        'askDraftingViewDrawingRefPt(sectionView1)


        SecViewCordX = MainViewCordX + MainViewLength + DisX + SecViewLength
        SecViewCOrdY = OV - DisY - SecViewHeight ' - Math.Round(out_pt.Y) ' - MainViewCordY - SecViewHeight



        Dim drawingReferencePoint1 As Point3d

        drawingReferencePoint1 = New Point3d(SecViewCordX, SecViewCOrdY, 0.0)

        sectionView1.MoveView(drawingReferencePoint1)
        sectionView1.Update()
        sectionView1 = Nothing

    End Sub