首页 > 编程学习 > ufun 面边界内外函数的 使用 ug8.5

ufun 面边界内外函数的 使用 ug8.5

发布时间:2022/9/9 19:11:39
Imports System.Runtime.InteropServices
Imports System.Collections.Generic
'前面这两条要引用


Public Function AskFaceLoops(ByVal faceTag As NXOpen.Tag) As loop_list()
        Dim loop_t As IntPtr
        NXOpen.Utilities.JAM.StartUFCall()
        Dim errorCode As Integer = UF_MODL_ask_face_loops(faceTag, loop_t)
        NXOpen.Utilities.JAM.EndUFCall()
        If errorCode <> 0 Then
            Throw NXOpen.NXException.Create(errorCode)
        End If
        Dim ptr As IntPtr = loop_t
        Dim loopList As New List(Of loop_list)
        While ptr <> IntPtr.Zero
            Dim loop_list_t As _loop_list = CType(Marshal.PtrToStructure(ptr, GetType(_loop_list)), _loop_list)
            Dim count As Integer
            errorCode = UF_MODL_ask_list_count(loop_list_t.edge_list, count)
            Dim edgeArray(count - 1) As NXOpen.Tag
            For i As Integer = 0 To count - 1
                UF_MODL_ask_list_item(loop_list_t.edge_list, i, edgeArray(i))
            Next
            'UF_MODL_delete_list(loop_list_t.edge_list)
            loopList.Add(New loop_list With {
                         .type = loop_list_t.type,
                         .edge_list = edgeArray})
            ptr = loop_list_t.next
        End While
        UF_MODL_delete_loop_list(loop_t)
        Return loopList.ToArray()
    End Function

    <DllImport("libufun.dll", EntryPoint:="UF_MODL_ask_face_loops", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Friend Shared Function UF_MODL_ask_face_loops(ByVal face As Tag, <Out()> ByRef loop_list As IntPtr) As Integer
    End Function

    <DllImport("libufun.dll", EntryPoint:="UF_MODL_ask_list_count", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Friend Shared Function UF_MODL_ask_list_count(ByVal list As IntPtr, <Out()> ByRef count As Integer) As Integer
    End Function

    <DllImport("libufun.dll", EntryPoint:="UF_MODL_ask_list_item", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Friend Shared Function UF_MODL_ask_list_item(ByVal list As IntPtr, ByVal index As Integer, <Out()> ByRef [object] As Tag) As Integer
    End Function
    <DllImport("libufun.dll", EntryPoint:="UF_MODL_delete_list", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Public Shared Function UF_MODL_delete_list(ByRef list As IntPtr) As Integer
    End Function

    <DllImport("libufun.dll", EntryPoint:="UF_MODL_delete_loop_list", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Friend Shared Function UF_MODL_delete_loop_list(ByRef list As IntPtr) As Integer
    End Function

    Friend Structure _loop_list
        Public type As Integer
        Public edge_list As IntPtr
        Public [next] As IntPtr
    End Structure

    Public Structure loop_list
        Public type As Integer 'Peripheral=1, Hole=2, Other=3
        Public edge_list() As NXOpen.Tag
    End Structure

转载:NX Open,怎样取到面的环LOOP - Bizca - 博客园 (cnblogs.com)

Copyright © 2010-2022 mfbz.cn 版权所有 |关于我们| 联系方式|豫ICP备15888888号