RSilva
Mechanical
- Jun 23, 2017
- 35
I'm a beginer with NX but i trying create a journal that, after i select 1 body, open the drafting with template A4
I already have the code below to select the body
But now, i have tried do the part to change to drafting but i dont find so much info about that.
I found 1 code and changed to this code below but still dont work.
Can any one help me?
I already have the code below to select the body
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Select_Point_on_Face
Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = theSession.ListingWindow()
Sub Main()
Dim Name As String =""
Dim MyBody As Body = Nothing
Dim a_body As NXOpen.Tag = NXOpen.Tag.Null
If SelectBody("select a body", MyBody) = Selection.Response.Cancel Then
Return
End If
a_body = MyBody.Tag
For Each myFeature As Features.Feature In theSession.Parts.Work.Features.GetFeatures()
If myFeature is MyBody.getfeatures(0) Then
Name = myFeature.Name
End If
Next
Lw.Open()
lw.WriteLine("Name:" & Name)
End Sub
Function SelectBody(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select a solid body"
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 = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj, 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
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
But now, i have tried do the part to change to drafting but i dont find so much info about that.
I found 1 code and changed to this code below but still dont work.
Can any one help me?
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
lw.Open()
Dim nullDrawings_DrawingSheet As Drawings.DrawingSheet = Nothing
Dim drawingSheetBuilder2 As Drawings.DrawingSheetBuilder = theSession.Parts.Work.DrawingSheets.DrawingSheetBuilder(nullDrawings_DrawingSheet)
With drawingSheetBuilder2
.Option = 0'curSheetOption
.AutoStartViewCreation = TRUE'curSheetViewCreation
.Height = 210'curSheetHeight
.Length = 297'curSheetLength
.StandardMetricScale = 5'curSheetMetricScale
.StandardEnglishScale = 3'curSheetEnglishScale
.Units = 0'curSheetUnits
.ProjectionAngle = 1'curSheetProjectionAngle
.Name = "new sheet"
End With
Dim newSheet As Drawings.DrawingSheet
newSheet = drawingSheetBuilder2.Commit()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module