iCAx开思工具箱

标题: VB.NET FOR UG 二次开发之 平移 [打印本页]

作者: 昆山人    时间: 2006-11-6 11:12
标题: VB.NET FOR UG 二次开发之 平移
请问如果我要在UG中移动一个实体到某一点,应该用那个函数??找了很久,没找到
作者: 昆山人    时间: 2006-11-6 13:12
沙发。。
自己顶一个先
作者: zhjb113    时间: 2006-11-6 15:29
UF_MODL_move_feature
作者: 昆山人    时间: 2006-11-6 15:57
明白...谢谢..
再问一个问题..我现在做了一个求曲线长度的小程序,可是当第一次运行的时候(选中所要测量的曲线,点OK,就退出了),可是第二次运行的时候(测完了一次,还必须的再测一次,而且测完后UG就死了,不知道是不是要释放什么变量)
作者: 昆山人    时间: 2006-11-6 16:42
不会用 UF_MODL_move_feature ,能不能给个小例子,谢谢
作者: zhjb113    时间: 2006-11-6 18:42
贴程序,让高手们帮你分析一下。(我很少做UF开发)
作者: 昆山人    时间: 2006-11-7 08:48
Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities

Module measurecurelength

    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim workpart As Part = s.Parts.Display

    Sub Main()

        Dim curves() As NXOpen.Tag
        Dim num_curves As Integer
        Dim n As String = vbCrLf
        Dim cnt As Integer = 0
        Dim response As Integer
        Dim inx As Integer = 0
        Dim prompt As String = "select curve or edge"
        Dim mask_crvs As UFUi.SelInitFnT = AddressOf mask_for_curves

        Dim nullUnit As Unit = Nothing
        Dim objects1(100) As DisplayableObject

        ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

        Try
            ufs.Ui.SelectWithClassDialog(prompt, "Curves:", _
                UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, _
                mask_crvs, Nothing, response, cnt, curves)
        Finally
            ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
        End Try

        For inx = 0 To curves.Length - 1
            Dim edges As Edge = CType(NXObjectManager.Get(curves(inx)), Edge)
            objects1(cnt) = edges
            cnt = cnt + 1

            Dim measureLength1 As MeasureLength
            measureLength1 = workpart.MeasureManager.NewLength(nullUnit, objects1)

            'MsgBox("value:" & measureLength1)

            measureLength1.Information()

            measureLength1.Dispose()
        Next
        For inx = 0 To curves.Length - 1

            ufs.Disp.SetHighlight(curves(inx), 0)
        Next


    End Sub
===============================

    Function mask_for_curves(ByVal select_ As IntPtr, _
                           ByVal userdata As IntPtr) As Integer

        Dim num_triples As Integer = 6
        Dim mask_triples(5) As UFUi.Mask

        mask_triples(0).object_type = UFConstants.UF_line_type
        mask_triples(0).object_subtype = 0
        mask_triples(0).solid_type = 0

        mask_triples(1).object_type = UFConstants.UF_circle_type
        mask_triples(1).object_subtype = 0
        mask_triples(1).solid_type = 0

        mask_triples(2).object_type = UFConstants.UF_conic_type
        mask_triples(2).object_subtype = 0
        mask_triples(2).solid_type = 0

        mask_triples(3).object_type = UFConstants.UF_spline_type
        mask_triples(3).object_subtype = 0
        mask_triples(3).solid_type = 0

        mask_triples(4).object_type = UFConstants.UF_point_type
        mask_triples(4).object_subtype = 0
        mask_triples(4).solid_type = 0

        mask_triples(5).object_type = UFConstants.UF_solid_type
        mask_triples(5).object_subtype = 0
        mask_triples(5).solid_type = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE

        ufs.Ui.SetSelMask(select_, _
                           UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _
                           num_triples, mask_triples)

        Return UFConstants.UF_UI_SEL_SUCCESS

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY

    End Function

End Module




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