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

  1. Public Function AskFaceLoops(ByVal faceTag As NXOpen.Tag) As loop_list()
  2. Dim loop_t As IntPtr
  3. NXOpen.Utilities.JAM.StartUFCall()
  4. Dim errorCode As Integer = UF_MODL_ask_face_loops(faceTag, loop_t)
  5. NXOpen.Utilities.JAM.EndUFCall()
  6. If errorCode <> 0 Then
  7. Throw NXOpen.NXException.Create(errorCode)
  8. End If
  9. Dim ptr As IntPtr = loop_t
  10. Dim loopList As New List(Of loop_list)
  11. While ptr <> IntPtr.Zero
  12. Dim loop_list_t As _loop_list = CType(Marshal.PtrToStructure(ptr, GetType(_loop_list)), _loop_list)
  13. Dim count As Integer
  14. errorCode = UF_MODL_ask_list_count(loop_list_t.edge_list, count)
  15. Dim edgeArray(count - 1) As NXOpen.Tag
  16. For i As Integer = 0 To count - 1
  17. UF_MODL_ask_list_item(loop_list_t.edge_list, i, edgeArray(i))
  18. Next
  19. 'UF_MODL_delete_list(loop_list_t.edge_list)
  20. loopList.Add(New loop_list With {
  21. .type = loop_list_t.type,
  22. .edge_list = edgeArray})
  23. ptr = loop_list_t.next
  24. End While
  25. UF_MODL_delete_loop_list(loop_t)
  26. Return loopList.ToArray()
  27. End Function
  28.  
  29. <DllImport("libufun.dll", EntryPoint:="UF_MODL_ask_face_loops", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
  30. Friend Shared Function UF_MODL_ask_face_loops(ByVal face As Tag, <Out> ByRef loop_list As IntPtr) As Integer
  31. End Function
  32.  
  33. <DllImport("libufun.dll", EntryPoint:="UF_MODL_ask_list_count", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
  34. Friend Shared Function UF_MODL_ask_list_count(ByVal list As IntPtr, <Out> ByRef count As Integer) As Integer
  35. End Function
  36.  
  37. <DllImport("libufun.dll", EntryPoint:="UF_MODL_ask_list_item", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
  38. Friend Shared Function UF_MODL_ask_list_item(ByVal list As IntPtr, ByVal index As Integer, <Out> ByRef [object] As Tag) As Integer
  39. End Function
  40. <DllImport("libufun.dll", EntryPoint:="UF_MODL_delete_list", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
  41. Public Shared Function UF_MODL_delete_list(ByRef list As IntPtr) As Integer
  42. End Function
  43.  
  44. <DllImport("libufun.dll", EntryPoint:="UF_MODL_delete_loop_list", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
  45. Friend Shared Function UF_MODL_delete_loop_list(ByRef list As IntPtr) As Integer
  46. End Function
  47.  
  48. Friend Structure _loop_list
  49. Public type As Integer
  50. Public edge_list As IntPtr
  51. Public [next] As IntPtr
  52. End Structure
  53.  
  54. Public Structure loop_list
  55. Public type As Integer 'Peripheral=1, Hole=2, Other=3
  56. Public edge_list() As NXOpen.Tag
  57. End Structure
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4.  
  5. public class AskFaceLoop
  6. {
  7. public LoopList[] AskFaceLoops(NXOpen.Tag faceTag)
  8. {
  9. System.IntPtr loopT;
  10. NXOpen.Utilities.JAM.StartUFCall();
  11. int errorCode = UF_MODL_ask_face_loops(faceTag,out loopT);
  12. NXOpen.Utilities.JAM.EndUFCall();
  13. if (errorCode != 0)
  14. {
  15. throw NXOpen.NXException.Create(errorCode);
  16. }
  17. System.IntPtr ptr = loopT;
  18. List<LoopList> loopList = new List<LoopList>();
  19. while (ptr != IntPtr.Zero)
  20. {
  21. _loop_list loopListT = (_loop_list)Marshal.PtrToStructure(ptr, typeof(_loop_list));
  22. int count;
  23. errorCode = UF_MODL_ask_list_count(loopListT.edge_list,out count);
  24. NXOpen.Tag[] edgeArray = new NXOpen.Tag[count];
  25. for (int i = 0; i < count; i++)
  26. {
  27. UF_MODL_ask_list_item(loopListT.edge_list, i,out edgeArray[i]);
  28. }
  29. //UF_MODL_delete_list(out loopListT.edge_list);
  30. loopList.Add(new LoopList{Type = loopListT.type,EdgeList = edgeArray});
  31. ptr = loopListT.next;
  32. }
  33. UF_MODL_delete_loop_list(out loopT);
  34. return loopList.ToArray();
  35. }
  36.  
  37. [DllImport("libufun.dll", EntryPoint = "UF_MODL_ask_face_loops", CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
  38. internal static extern int UF_MODL_ask_face_loops(NXOpen.Tag face, out IntPtr loopList);
  39.  
  40. [DllImport("libufun.dll", EntryPoint = "UF_MODL_ask_list_count", CallingConvention = CallingConvention.Cdecl,
  41. CharSet = CharSet.Ansi)]
  42. internal static extern int UF_MODL_ask_list_count(IntPtr list, out int count);
  43.  
  44. [DllImport("libufun.dll", EntryPoint = "UF_MODL_ask_list_item", CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
  45. internal static extern int UF_MODL_ask_list_item(IntPtr list, int index, out NXOpen.Tag @object);
  46.  
  47. [DllImport("libufun.dll", EntryPoint = "UF_MODL_delete_list", CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
  48. internal static extern int UF_MODL_delete_list(out IntPtr list);
  49.  
  50. [DllImport("libufun.dll", EntryPoint = "UF_MODL_delete_loop_list", CallingConvention = CallingConvention.Cdecl,CharSet = CharSet.Ansi)]
  51. internal static extern int UF_MODL_delete_loop_list(out IntPtr list);
  52.  
  53. internal struct _loop_list
  54. {
  55. public int type;
  56. public IntPtr edge_list;
  57. public IntPtr next;
  58. }
  59.  
  60. public struct LoopList
  61. {
  62. /// <summary>
  63. /// Peripheral=1, Hole=2, Other=3
  64. /// </summary>
  65. public int Type;
  66. public NXOpen.Tag[] EdgeList;
  67. }
  68. }

  

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. C#多线程开发-线程基础 01

    最近由于工作的需要,一直在使用C#的多线程进行开发,其中也遇到了很多问题,但也都解决了.后来发觉自己对于线程的知识和运用不是很熟悉,所以将利用几篇文章来系统性的学习汇总下C#中的多线程开发. 线程基础 ...

  2. 微信小程序基础知识笔记

    微信小程序笔记 文件构成 全局文件 app.json 小程序全局配置文件,必要,自动生成 app.js 小程序入口JS文件,一般只需申明全局变量.处理生命周期以及版本升级即可,必要 app.wxss ...

  3. Docker | 入门 & 基础操作

    Dcoker 入门 确保docker 已经安装好了,如没有装好的可以参考:Docker | 安装 运行第一个容器 docker run -it ubuntu /bin/bash docker run ...

  4. freemodbus移植、实例及其测试方法

    Modbus简介 参考:Modbus​协议​深入​讲解 https://www.ni.com/zh-cn/innovations/white-papers/14/the-modbus-protocol ...

  5. 依赖注入Bean属性——手动装配Bean

    一.构造方法注入 其中,可以根据不同的参数列表调用不同的重载的构造方法: 其中,基本数据类型没有包,引用类型都有包路径,基本类型对应封装类: 二.通过property标签调用类的set方法注入 三.通 ...

  6. [第十六篇]——Docker 安装 CentOS之Spring Cloud直播商城 b2b2c电子商务技术总结

    Docker 安装 CentOS CentOS(Community Enterprise Operating System)是 Linux 发行版之一,它是来自于 Red Hat Enterprise ...

  7. 通过mstsc复制粘贴失败需要重新启动RDP剪切板监视程序rdpclip.exe

    先结束程序 再重新启动程序

  8. Dockerfile常见命令

    Dockerfile结构 Dockerfile的结构分成了若干部分,每个部分之间的先后顺序有明确的要求: 部分 命令 基础镜像信息 FROM 维护者信息 MAINTAINER 镜像操作指令 RUN.C ...

  9. Hadoop-3.1.3安装

    0.创建用户并付权限 sudo useradd iwbdsudo passwd iwbd 配置iwbd用户具有root权限 修改/etc/sudoers文件,找到下面一行(91行),在root下面添加 ...

  10. Spotlight监控工具的使用

    Spotlight下载地址:http://spotlight-on-unix.software.informer.com/download/#downloading Spotlight是Quest公司 ...