iCAx开思工具箱

标题: vb.net调用ufun函数遇到的问题,求解! [打印本页]

作者: hello_icax    时间: 2010-8-13 11:14
标题: vb.net调用ufun函数遇到的问题,求解!
请看下面的子程序.
目的是对全局变量arrCurves()内的曲线对象进行两次变换.
然后,建立回转体.

问题是,建立第一次变换矩阵成功后(status1=0),不可建立第二次变换矩阵.
否则就出错.奇怪?
若将第二次变换代码删除,程序可顺利运行到下面的变换代码,但提示出错.
看一下UG界面内的运行结果.是变换成功的.那为何还要提示错误呢?
建立回转体是不可能了.

请高手指点,不甚感激!

Private Sub CreateRevolveSolid(ByVal Ang As Double, ByVal sp As Point3d, ByVal ep As Point3d)
        Dim objTags(100) As NXOpen.Tag
        Dim i As Integer
        For i = 0 To arrCurves.Length - 1
            objTags(i) = arrCurves(i).Tag
        Next
        Dim origin(2) As Double
        Dim origin1(2) As Double
        Dim origin2(2) As Double
        origin(0) = 0 : origin(1) = 0 : origin(2) = 0
        origin1(0) = 0 : origin1(1) = 0 : origin1(2) = 0
        origin2(0) = 0 : origin2(1) = 0 : origin2(2) = 0
        Dim direction(2) As Double
        Dim direction1(2) As Double
        Dim direction2(2) As Double
        Dim mat As Double
        Dim mat1 As Double
        Dim mat2 As Double
        Dim status As Integer
        Dim status1 As Integer
        Dim status2 As Integer
        Dim Features(100) As NXOpen.Tag
        Dim copies(100) As NXOpen.Tag
        Dim ang1 As Double = 90
        Dim ang2 As Double = 90
        direction1(0) = 1 : direction1(1) = 0 : direction1(2) = 0
        direction2(0) = 0 : direction2(1) = 0 : direction2(2) = 1
        '构建第一变换矩阵
        MsgBox("Matrix1" & status1.ToString)
        ufse.Trns.CreateRotationMatrix(origin1, direction1, ang1, mat1, status1)
        MsgBox("Matrix1 status" & status1.ToString)
        '构建第二变换矩阵
        ufse.Trns.CreateRotationMatrix(origin2, direction2, ang2, mat2, status2)
        MsgBox("Matrix2 status" & status2.ToString)
        
        'ufse.Trns.MultiplyMatrices(mat1, mat2, mat)
        '变换
        MsgBox("transform1")
        ufse.Trns.TransformObjects(mat1, objTags, arrCurves.Length, 2, 0, 2, copies, Nothing, status)
        MsgBox("transform1 ok")
        Dim limit(1) As String
        limit(0) = CStr(-Ang) : limit(1) = CStr(Ang)
        Dim offset(1) As String
        offset(0) = "0.0" : offset(1) = "0.0"
        '生成回转体
        Dim cou As Integer
        MsgBox("revolution")
        direction(1) = 0 : direction(2) = 1 : direction(3) = 0
        ufse.Modl.CreateRevolution(copies, arrCurves.Length, Nothing, limit, offset, origin, False, True, origin, direction, FeatureSigns.Nullsign, Features, cou)
    End Sub




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3