在封装的ufun .NET库里面,对UF_MODL_ask_face_loops这个函数并没有封装,导致我们很多不便,那我们在.NET下怎样才能使用这个函数呢??当然是手动处理一下

 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
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices; public class AskFaceLoop
{
public LoopList[] AskFaceLoops(NXOpen.Tag faceTag)
{
System.IntPtr loopT;
NXOpen.Utilities.JAM.StartUFCall();
int errorCode = UF_MODL_ask_face_loops(faceTag,out loopT);
NXOpen.Utilities.JAM.EndUFCall();
if (errorCode != 0)
{
throw NXOpen.NXException.Create(errorCode);
}
System.IntPtr ptr = loopT;
List<LoopList> loopList = new List<LoopList>();
while (ptr != IntPtr.Zero)
{
_loop_list loopListT = (_loop_list)Marshal.PtrToStructure(ptr, typeof(_loop_list));
int count;
errorCode = UF_MODL_ask_list_count(loopListT.edge_list,out count);
NXOpen.Tag[] edgeArray = new NXOpen.Tag[count];
for (int i = 0; i < count; i++)
{
UF_MODL_ask_list_item(loopListT.edge_list, i,out edgeArray[i]);
}
//UF_MODL_delete_list(out loopListT.edge_list);
loopList.Add(new LoopList{Type = loopListT.type,EdgeList = edgeArray});
ptr = loopListT.next;
}
UF_MODL_delete_loop_list(out loopT);
return loopList.ToArray();
} [DllImport("libufun.dll", EntryPoint = "UF_MODL_ask_face_loops", CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
internal static extern int UF_MODL_ask_face_loops(NXOpen.Tag face, out IntPtr loopList); [DllImport("libufun.dll", EntryPoint = "UF_MODL_ask_list_count", CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi)]
internal static extern int UF_MODL_ask_list_count(IntPtr list, out int count); [DllImport("libufun.dll", EntryPoint = "UF_MODL_ask_list_item", CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
internal static extern int UF_MODL_ask_list_item(IntPtr list, int index, out NXOpen.Tag @object); [DllImport("libufun.dll", EntryPoint = "UF_MODL_delete_list", CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
internal static extern int UF_MODL_delete_list(out IntPtr list); [DllImport("libufun.dll", EntryPoint = "UF_MODL_delete_loop_list", CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
internal static extern int UF_MODL_delete_loop_list(out IntPtr list); internal struct _loop_list
{
public int type;
public IntPtr edge_list;
public IntPtr next;
} public struct LoopList
{
/// <summary>
/// Peripheral=1, Hole=2, Other=3
/// </summary>
public int Type;
public NXOpen.Tag[] EdgeList;
}
}

  

NX Open,怎样取到面的环LOOP的更多相关文章

  1. wineshark分析抓取本地回环包

    wineshark分析抓取本地回环包 摘要 由于windows系统没有提供本地回环网络的接口,用Wireshark监控网络的话看不到localhost的流量.想要获取本地的网络数据包,可以通过一款小巧 ...

  2. wireshark抓取本地回环及其问题

    一:The NPF driver isn't running 这个错误是因为没有开启NPF服务造成的. NPF即网络数据包过滤器(Netgroup Packet Filter,NPF)是Winpcap ...

  3. List<List<model>>如何更快捷的取里面的model?

    访问接口返回数据类型为List<List<model>>,现在想将其中的model插入数据库,感觉一点点循环有点傻,0.0...,各位有没有其他的方法? List<Lis ...

  4. Wireshark抓取本地回环接口数据包 RawCap.exe

    Wireshark提供了winpcap可以抓取远程网卡数据包...但我尝试了不成功.后来发现RawCap.exe不仅可以抓取回环接口数据包,远程跑了拿到pcap文件再打开用起来比winpcap更方便最 ...

  5. wireshark抓取本地回环及其问题 转摘:http://www.cnblogs.com/luminji/p/3503464.html

    一:The NPF driver isn’t running 这个错误是因为没有开启NPF服务造成的. NPF即网络数据包过滤器(Netgroup Packet Filter,NPF)是Winpcap ...

  6. windows下使用wineshark分析抓取本地回环包

    ## 摘要 由于windows系统没有提供本地回环网络的接口,用Wireshark监控网络的话看不到localhost的流量. 想要获取本地的网络数据包,可以通过一款小巧的开源软件RawCap来进行抓 ...

  7. RawCap抓取本地回环接口数据包

    RawCap.exe --help ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 D: ...

  8. NX二次开发-获取面的法向向量UF_MODL_ask_face_data

    NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_obj.h> #include <u ...

  9. NX二次开发-获取面的外围边和孔槽边

    函数: UF_MODL_ask_face_loops()  获取面的所有封闭边组合(多组edge) UF_MODL_ask_loop_list_count() 获取loop的数量(面上孔.槽的数量+1 ...

随机推荐

  1. 使用 & 进行高效率取余运算

    Java的HashMap源码中用到的(n-1)&hash这样的运算,这是一种高效的求余数的方法 结论:假设被除数是x,对于除数是2n的取余操作x%2n,都可以写成x&(2n-1),位运 ...

  2. vue系统总结2

    注册组件 组件其他补充 组件数据存放 父子组件通信 父级向子级传递信息 子级向父级传递信息 插槽slot 1.1什么是组件化 1.2 注册组件的基本步骤 创建组件构造器 注册组件 使用组件 <d ...

  3. GUI容器之布局管理器

    布局管理器 布局管理器:frame.setLayout(); 默认值为new flowLayout() 流式布局 frame.setLayout(new FlowLayout(FlowLayout.R ...

  4. You have mail in /var/mail/xxx

    因为配置 DDNS, 我添加了个 crontab 定时任务,每隔 1 分钟执行一段 python 脚本 然后就发现 terminal 经常提示 'You have mail in /var/mail/ ...

  5. (五)羽夏看C语言——结构体与类

    写在前面   由于此系列是本人一个字一个字码出来的,包括示例和实验截图.本人非计算机专业,可能对本教程涉及的事物没有了解的足够深入,如有错误,欢迎批评指正. 如有好的建议,欢迎反馈.码字不易,如果本篇 ...

  6. BFD协议简介

    1. 背景 双向转发检测BFD(Bidirectional Forwarding Detection)是一种全网统一的检测机制,用于快速检测.监控网络中链路或者IP路由的转发连通状况. 为了保护关键应 ...

  7. python模块--pathlib

    类/属性/方法 返回值 参数 说明 .Path() p 创建Path对象 path 路径         p.parent Path 返回上一级路径 p.parents iter 上一级路径, 上上级 ...

  8. java版gRPC实战之五:双向流

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  9. 详解Java中==和equals()的区别

    众所周知,在 Java 编程中,程序员通常会使用==或equals()来简单的比较地址,内容是否相等.而这两者之间的使用区别,对于初学 Java 的同学来说可能会比较迷糊.我将根据下面的几段示例程序, ...

  10. 【JDK】分析 String str=““ 与 new String()

    一.基础概念 为了讲清楚他们的差异,这里先介绍几个概念. 1.1 常量池 所谓常量池:顾名思义就是用来存放一些常量的.该常量是在编译期被确定,并被保存在已编译的.class文件中,其中包括了类,方法, ...