中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > .NET > 临时文章
solidworks二次开发-02-用来访问特征的两个API
作者:未知 时间:2005-07-27 21:42 出处:CSDN 责编:chinaitpower
              摘要:solidworks二次开发-02-用来访问特征的两个API

solidworks二次开发-02-用来访问特征的两个API

来学习两个api:

SelectByID2和GetSelectedObject5。这两个函数,第一个通过给出对象的name选择对象。第二个通过启用程序前已经选择的索引得到对象。

看下面程序:

Option Explicit

Dim swApp As SldWorks.SldWorks

Dim Model As ModelDoc2

Dim feature As feature

Dim boolstatus As Variant

 

Sub main()

 

Set swApp = Application.SldWorks

Set Model = swApp.ActiveDoc

 

' 选择叫"拉伸1"的特征

boolstatus = Model.Extension.SelectByID2("拉伸1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, swSelectOptionDefault)

 

'主要就是这一句话,在写Option Explicit后函数的最后一个参数swSelectOptionDefault可以使用0来代替

' If the selection was successful, that is, "Extrude1" was

' selected and it is a "BODYFEATURE", then get that feature; otherwise,

' indicate failure

If boolstatus = True Then  '如果有“拉伸1”这个特征下面的代码将其选中

    Dim SelMgr As SelectionMgr

    Set SelMgr = Model.SelectionManager

    Set feature = SelMgr.GetSelectedObject5(1) '此处使用一个索引来得到特征

    Debug.Print feature.Name

Else

    Debug.Print "Error"

End If

 End Sub

最后列出这两个函数的VB语法:

ModelDocExtension::SelectByID2

 

Description

This method selects the specified entity.

 

Syntax (OLE Automation)

retval = ModelDocExtension.SelectByID2 ( Name, Type, X, Y, Z, Append, Mark, Callout. SelectOption )

Input:

(BSTR) Name

Name of object to select or an empty string

Input:

(BSTR) Type

Type of object (uppercase) as defined in swSelectType_e or an empty string

Input:

(double) X

X selection location or 0

Input:

(double) Y

Y selection location or 0

Input:

(double) Z

Z selection location or 0

Input:

(VARIANT_BOOL) Append

If...

And if entity is...

Then...

TRUE

Not already selected

 

The entity is appended to the current selection list

Already selected

The entity is removed from the current selection list

FALSE

Not already selected

The current selection list is cleared, and then the entity is put on the list

Already selected

The current selection list remains the same

 

Input:

(long) Mark

Value that you want to use as a mark; this value is used by other functions that require ordered selection

Input:

(LPCALLOUT) Callout

Pointer to the associated callout

Input:

(long) SelectOption

Selection option as defined in swSelectOption_e (see Remarks)

Output:

(VARIANT_BOOL) retval

TRUE if item was successfully selected, FALSE if not

SelectionMgr::GetSelectedObject5

  

Description

This method gets the selected object.

 

Syntax (OLE Automation)

retval = SelectionMgr.GetSelectedObject5 ( AtIndex )

Input:

(long) AtIndex

Index position within the current list of selected items, where AtIndex ranges from 1 to SelectionMgr::GetSelectedObjectCount

Output:

(LPDISPATCH) retval

Pointer to the Dispatch object as defined in swSelType_e; NULL may be returned if type is not supported or if nothing is selected

也可以通过COM使用vc来访问。


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有