几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(VB.NET/C#)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-29, 05:42 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】类似lisp选择方式的c#选择集获取函数 - 精华帖集合

类似lisp选择方式的c#选择集获取函数 - 精华帖集合
www.dimcax.com
类似lisp选择方式的c#选择集获取函数
习惯lisp选择集的朋友可能喜欢
支持小狼!但我建议把代码帖出来,使阅读更加方便。
想贴,提示代码太长了贴不上去

public enum selectiontype
{
all = 0,
last = 1,
previous = 2,
window = 3,
windowpolygon = 4,
crossingpolygon = 5,
crossingwindow = 6,
fence = 7,
select = 8
}
public class selectionobject
{
/// <summary>
/// 获取单个对象id
/// </summary>
/// <param name="msg">选择提示</param>
/// <returns></returns>
public objectid getobjonly(string msg)
{
promptselectionoptions options = new promptselectionoptions();
options.singleonly = true;
options.singlepickinspace = true;
options.messageforadding = "select an entity:";
acadpropers.editor.writemessage(msg);
promptselectionresult result = acadpropers.editor.getselection(options);
if (result.status != promptstatus.ok)
{
acadpropers.editor.writemessage("用户取消查看!");
return objectid.null;
}
objectid[] ids = result.value.getobjectids();
return ids[0];
}
/// <summary>
/// 选择当前文档所有图形对象
/// </summary>
/// <returns></returns>
public objectid[] ssget()
{
objectid[] ids = null;
try
{
promptselectionresult result = acadpropers.editor.selectall();
if (result.status == promptstatus.ok)
ids = result.value.getobjectids();
}
catch (system.exception)
{
return null;
}
return ids;
}
/// <summary>
/// 更具方法选择对象支持
/// all 全选方式,
/// last 最后一个对象,
/// previous 最后一个选择集,
/// </summary>
/// <param name="seltype">选择方法</param>
/// <returns></returns>
public objectid[] ssget(selectiontype seltype)
{
objectid[] ids = null;
try
{
promptselectionresult result = null;
switch (seltype)
{
case selectiontype.all:
result = acadpropers.editor.selectall();
break;
case selectiontype.last:
result = acadpropers.editor.selectlast();
break;
case selectiontype.previous:
result = acadpropers.editor.selectprevious();
break;
default:
return null;
}
if (result.status == promptstatus.ok)
ids = result.value.getobjectids();
}
catch (system.exception)
{
return null;
}
return ids;
}
/// <summary>
/// 根据条件选择当前文档中图形对象
/// </summary>
/// <param name="fillist">过滤条件</param>
/// <returns></returns>
public objectid[] ssget(selectionfilter fillist)
{
objectid[] ids = null;
try
{
promptselectionresult result = acadpropers.editor.selectall(fillist);
if (result.status == promptstatus.ok)
ids = result.value.getobjectids();
}
catch (system.exception)
{
return null;
}
return ids;
}
复制代码

/// <summary>
/// 用户选择
/// 可选这单选或多选模式
/// </summary>
/// <param name="selectionmessage">选择提示</param>
/// <param name="fillist">过滤器</param>
/// <param name="selectonly">是否单选</param>
/// <returns></returns>
public objectid[] ssget(string selectionmessage, selectionfilter fillist, bool selectonly)
{
objectid[] ids = null;
try
{
promptselectionresult result = null;
promptselectionoptions options = new promptselectionoptions();
options.messageforadding = selectionmessage;
if (selectonly)
{
options.singleonly = true;
options.singlepickinspace = true;
}
result = acadpropers.editor.getselection(options, fillist);
if (result.status == promptstatus.ok)
ids = result.value.getobjectids();
else
acadpropers.editor.writemessage("用户取消选择!");
}
catch (system.exception)
{
return null;
}
return ids;
}
/// <summary>
/// 用户选择
/// 可选这单选或多选模式
/// </summary>
/// <param name="selectionmessage">选择提示</param>
/// <param name="selectonly">是否单选</param>
/// <returns></returns>
public objectid[] ssget(string selectionmessage, bool selectonly)
{
objectid[] ids = null;
try
{
promptselectionresult result = null;
promptselectionoptions options = new promptselectionoptions();
options.messageforadding = selectionmessage;
if (selectonly)
{
options.singleonly = true;
options.singlepickinspace = true;
}
result = acadpropers.editor.getselection(options);
if (result.status == promptstatus.ok)
ids = result.value.getobjectids();
else
acadpropers.editor.writemessage("用户取消选择!");
}
catch (system.exception)
{
return null;
}
return ids;
}
/// <summary>
/// 更具坐标、过滤器选择对象,支持
/// windowpolygon 多边形内, crossingpolygon多边形相交, fence 线相交
/// </summary>
/// <param name="seltype">选择类型</param>
/// <param name="pnt3dcoll">坐标集</param>
/// /// <param name="fillist">过滤器</param>
/// <returns></returns>
public objectid[] ssget(selectiontype seltype, point3dcollection pnt3dcoll, selectionfilter fillist)
{
promptselectionresult result = null;
objectid[] ids = null;
try
{
switch (seltype)
{
case selectiontype.windowpolygon:
result = acadpropers.editor.selectwindowpolygon(pnt3dcoll, fillist);
break;
case selectiontype.crossingpolygon:
result = acadpropers.editor.selectcrossingpolygon(pnt3dcoll, fillist);
break;
case selectiontype.fence:
result = acadpropers.editor.selectfence(pnt3dcoll, fillist);
break;
default:
return null;
}
}
catch (system.exception)
{
return null;
}
return ids;
}
/// <summary>
/// 更具坐标选择对象,支持
/// windowpolygon 多边形内, crossingpolygon多边形相交, fence 线相交
/// </summary>
/// <param name="seltype">选择类型</param>
/// <param name="pnt3dcoll">坐标集</param>
/// <returns></returns>
public objectid[] ssget(selectiontype seltype, point3dcollection pnt3dcoll)
{
promptselectionresult result = null;
objectid[] ids = null;
try
{
switch (seltype)
{
case selectiontype.windowpolygon:
result = acadpropers.editor.selectwindowpolygon(pnt3dcoll);
break;
case selectiontype.crossingpolygon:
result = acadpropers.editor.selectcrossingpolygon(pnt3dcoll);
break;
case selectiontype.fence:
result = acadpropers.editor.selectfence(pnt3dcoll);
break;
default:
return null;
}
}
catch (system.exception)
{
return null;
}
return ids;
}
/// <summary>
/// 根据矩形框及过滤器,选择对象,支持
/// window 矩形框内, crossingwindow 矩形框相交
/// </summary>
/// <param name="seltype">选择类型</param>
/// <param name="pt1">矩形框点1</param>
/// <param name="pt2">矩形框点2</param>
/// <returns></returns>
public objectid[] ssget(selectiontype seltype, point3d pt1, point3d pt2)
{
promptselectionresult result = null;
objectid[] ids = null;
try
{
switch (seltype)
{
case selectiontype.window:
result = acadpropers.editor.selectwindow(pt1, pt2);
break;
case selectiontype.crossingwindow:
result = acadpropers.editor.selectwindow(pt1, pt2);
break;
default:
return null;
}
}
catch (system.exception)
{
return null;
}
return ids;
}
/// <summary>
/// 根据矩形框及过滤器,选择对象,支持
/// window 矩形框内, crossingwindow 矩形框相交
/// </summary>
/// <param name="seltype">选择类型</param>
/// <param name="pt1">矩形框点1</param>
/// <param name="pt2">矩形框点2</param>
/// <param name="fillist">过滤条件</param>
/// <returns></returns>
public objectid[] ssget(selectiontype seltype, point3d pt1, point3d pt2, selectionfilter fillist)
{
promptselectionresult result = null;
objectid[] ids = null;
try
{
switch (seltype)
{
case selectiontype.window:
result = acadpropers.editor.selectwindow(pt1, pt2, fillist);
break;
case selectiontype.crossingwindow:
result = acadpropers.editor.selectwindow(pt1, pt2, fillist);
break;
default:
return null;
}
}
catch (system.exception)
{
return null;
}
return ids;
}
复制代码
代码写得不错!不过我不知道为什么一定要让c#的思维跟着lisp走!
这么复杂,直接p/invoke来的更简单
呵呵,支持,建议加精
哈哈,我是lisp转过来的习惯不一样啊比较喜欢lisp的ssget做选择集
很好
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 06:11 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多