NX Open,怎样取到面的环LOOP
在封装的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的更多相关文章
- wineshark分析抓取本地回环包
wineshark分析抓取本地回环包 摘要 由于windows系统没有提供本地回环网络的接口,用Wireshark监控网络的话看不到localhost的流量.想要获取本地的网络数据包,可以通过一款小巧 ...
- wireshark抓取本地回环及其问题
一:The NPF driver isn't running 这个错误是因为没有开启NPF服务造成的. NPF即网络数据包过滤器(Netgroup Packet Filter,NPF)是Winpcap ...
- List<List<model>>如何更快捷的取里面的model?
访问接口返回数据类型为List<List<model>>,现在想将其中的model插入数据库,感觉一点点循环有点傻,0.0...,各位有没有其他的方法? List<Lis ...
- Wireshark抓取本地回环接口数据包 RawCap.exe
Wireshark提供了winpcap可以抓取远程网卡数据包...但我尝试了不成功.后来发现RawCap.exe不仅可以抓取回环接口数据包,远程跑了拿到pcap文件再打开用起来比winpcap更方便最 ...
- wireshark抓取本地回环及其问题 转摘:http://www.cnblogs.com/luminji/p/3503464.html
一:The NPF driver isn’t running 这个错误是因为没有开启NPF服务造成的. NPF即网络数据包过滤器(Netgroup Packet Filter,NPF)是Winpcap ...
- windows下使用wineshark分析抓取本地回环包
## 摘要 由于windows系统没有提供本地回环网络的接口,用Wireshark监控网络的话看不到localhost的流量. 想要获取本地的网络数据包,可以通过一款小巧的开源软件RawCap来进行抓 ...
- 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: ...
- NX二次开发-获取面的法向向量UF_MODL_ask_face_data
NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_obj.h> #include <u ...
- NX二次开发-获取面的外围边和孔槽边
函数: UF_MODL_ask_face_loops() 获取面的所有封闭边组合(多组edge) UF_MODL_ask_loop_list_count() 获取loop的数量(面上孔.槽的数量+1 ...
随机推荐
- Kickstart部署多系统
原文转自:https://www.cnblogs.com/itzgr/p/10029587.html作者:木二 目录 一 准备 1.1 完整架构:Kickstart+DHCP+HTTP+TFTP+PX ...
- sublime text 3 中文排序插件
ST3 的排序不支持中文按拼音排序,所以需要搞一个插件来支持这一特性 pypinyin 这个库可以把中文转成拼音,可惜不支持 python3.3,而 ST3 内置的 python 就是 3.3 我系统 ...
- GoLang设计模式02 - 工厂模式
工厂模式是一种创建型模式,也是最常用的设计模式之一.调用方通过工厂产出并获取对象,可以不必关注对象创建的细节和构建逻辑. 在工厂模式下,调用方只和工厂进行交互,并告诉工厂具体获取哪种类型的对象.工厂负 ...
- shutdown 命令
# shutdown -h #停止系统服务并关机 -r #停止系统服务后重启 shutdown -h now #立即关机 shutdown -h 10:53 #到10:53关机,如果该时间小于当前时间 ...
- Java基础(三)——内部类
一.内部类 内部类(Inner Class)就是定义在一个类里面的类.与之对应,包含内部类的类被称为外部类.内部类可以用private修饰. 1.为什么要定义内部类?或者内部类的作用是什么? 内部类提 ...
- C#动态构建表达式树(三)——表达式的组合
C#动态构建表达式树(三)--表达式的组合 前言 在筛选数据的过程中,可能会有这样的情况:有一些查询条件是公共的,但是根据具体的传入参数可能需要再额外增加一个条件.对于这种问题一般有两种方法: a. ...
- POJ 2828 Buy Tickets(线段树单点)
https://vjudge.net/problem/POJ-2828 题目意思:有n个数,进行n次操作,每次操作有两个数pos, ans.pos的意思是把ans放到第pos 位置的后面,pos后面的 ...
- Django学习day12随堂笔记
每日测验 """ 1.什么是cookie和session,你能描述一下它们的由来和工作机制吗(切勿糊弄,敷衍了事) 2.django中如何操作cookie和session ...
- 一起搞懂PHP的错误和异常(三)
关于错误与异常的最后一篇文章,我们来进行一些总结. PHP中错误和异常的区别 通过前面两篇文章的学习,我们来直接将错误和异常摆上来进行对比,看看他们的区别与联系: 错误的出现通常是语法或编译运行时错误 ...
- mysql更新数据时:当想mysql某插入有某字段设置了unique且和之前相同时,会报错,并停止运行
这个在mysql5.7会报错: 如openid设为unique: 1062 - Duplicate entry 'oTfYq6PKne00IrcTqphmKqKnsahM' for key 'qx_w ...