' NX 3.0.1.1
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
' ----------------------------------------------
' Menu: Insert->Fillet...
' ----------------------------------------------
Dim session_UndoMarkId1 As Session.UndoMarkId
session_UndoMarkId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Profile short list")
Dim session_UndoMarkId2 As Session.UndoMarkId
session_UndoMarkId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Sketch Fillet")
Dim curve1 As Curve = CType(theSession.ActiveSketch.FindObject("Curve Arc2"), Curve)
Dim curve2 As Curve = CType(theSession.ActiveSketch.FindObject("Curve Line1"), Curve)
Dim curve3 As Curve = CType(theSession.ActiveSketch.FindObject("Curve Arc1"), Curve)
Dim point3d1 As Point3d = New Point3d(-16.3587812762339, 12.1731575031805, 0.0)
Dim point3d2 As Point3d = New Point3d(21.5496698208353, 12.2482013341624, 0.0)
Dim point3d3 As Point3d = New Point3d(-10.1078964615615, -17.8791243960493, 0.0)
Dim arcArray1() As Arc
Dim sketchConstraintArray1() As SketchConstraint
arcArray1 = theSession.ActiveSketch.Fillet(curve1, curve2, curve3, point3d1, point3d2, point3d3, 362.079613989109, Sketch.TrimInputOption.False, Sketch.DeleteThirdCurveOption.False, Sketch.CreateDimensionOption.False, Sketch.AlternateSolutionOption.False, sketchConstraintArray1)
Dim arcArray1() As Arc
arcArray1 = theSession.ActiveSketch.Fillet(curve1, curve2, curve3, point3d1,...............1)
做了一条圆弧
Life is easy作者: vodka 时间: 2005-10-11 15:20 标题: 选取管理 Selection manager 调用以上函数就会做出一条圆弧。需要先喂给它三条曲线对象(NXObject)和三个参照点(helpPoint).在捕捉下来的VB代码里它们是死代码(Hardcoded). 为了在别的场合重复这个过程来创建一条三切圆弧,我们需要一段选取用的子程序。这里是一段简单的子程序代码
Sub SelectCurve(ByRef selectedObject As NXObject, ByRef helpPoint As Point3d)
Dim ui As UI = ui.GetUI
Dim message As String = "Select curve"
Dim title As String = "Selection"
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim keepHighlighted As Boolean = True
Dim includeFeatures As Boolean = True
Dim response As Selection.Response
Dim selectionAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
response = ui.SelectionManager.SelectObject(message, title, scope, false, false, selectedObject, helpPoint)
If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
Return
End If
End Sub
Dim point3d1 As Point3d = New Point3d(-9.93871664596234, 9.27613553623151, 0.0)
Dim nXMatrix1 As NXMatrix = CType(theSession.Parts.Work.NXMatrices.FindObject("WCS"), NXMatrix)
Dim arc1 As Arc
arc1 = theSession.Parts.Work.Curves.CreateArc(point3d1, nXMatrix1, 18.753796202917, 0.0, ( 360.0 * Math.Pi/180.0))
圆心和半径在这段代码里面是hardcode.用上面的两行代码替换就行叻作者: vodka 时间: 2005-10-13 04:39 标题: 两段代码合起来就成了 Dim centerpoint1 As Point3d = arcArray1(0).CenterPoint
Dim radius1 As Double = arcArray(0).Radius
Dim nXMatrix1 As NXMatrix = CType(theSession.Parts.Work.NXMatrices.FindObject("WCS"), NXMatrix)
Dim arc1 As Arc
arc1 = theSession.Parts.Work.Curves.CreateArc(centerpoint1, nXMatrix1, radius1, 0.0, ( 360.0 * Math.Pi/180.0))