C# Solidworks二次开发:识别solidworks中导入实体体上的特征相关API详解

大家好,今天要介绍的是关于特征相关的API。

下面是要介绍的相关API:

(1)第一个为CreateFeatures,这个API的含义为在solidworks中创建可识别的导入特性,下面是官方的具体解释:

输入参数为fwFeatureCreationOptions_e

Member Description
fwAddConstraintsToSketch 0x1 = When you specify this option, the software adds a Fix relation to each entity in a sketch, fully defining the sketch; if this option is not specified, then the sketch entities remain underdefined
fwAllowFailFeatureCreation 0x2 = When you specify this option, the software allows the creation of a feature even if the feature has a rebuild error

返回值为bool,成功创建特征返回值为true,失败返回值为false。

下面是官方使用的例子,没有C#,只有VBA:

This sample application illustrates recognizing a feature interactively in a SOLIDWORKS part document, and then creating that feature.

Sub main()

Dim swApp As Object

Dim sample As Object

Dim Part As Object

Dim boolstatus As Boolean

Dim str As String

Set swApp = Application.SldWorks

swApp.SetUserPreferenceIntegerValue swAutoSaveInterval, 0

Set sample = swApp.GetAddInObject("FeatureWorks.FeatureWorksApp")

Dim varOut As Variant

Dim var1 As Boolean

Set Part = swApp.ActiveDoc

Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID("", "FACE", 0.1165311335518, -0.006695921966639, 0.03257260156937, False, 0, Nothing)

Dim InterOption As Integer

str = "Fillet" 'Option to recognize interactive fillet

InterOption = fwChainFeatures 'Turn on the chaining option.

varOut = sample.RecognizeFeatureInteractive(str, InterOption)

If (False = varOut) Then MsgBox ("ERROR")

createOption = fwAllowFailFeatureCreation 'Option to allow creation of features with rebuild errors

var1 = sample.CreateFeatures(createOption)

If (False = var1) Then MsgBox ("ERROR")

End Sub

(2)第二个为RecognizeFeatureAutoMatic,这个API的含义为自动识别solidworks中导入的特性,下面是官方的具体解释:

输入参数为fwAutomaticRecognitionOptions_e

Member Description
fwAutoEdgeFlange 0x100 = Recognize edge flange features automatically
fwAutoHemFlange 0x200 = Recognize hem features automatically
fwBaseFlange 0x40 = Recognize base flange features automatically
fwChamfils 0x10 = Recognize fillets and chamfers automatically
fwExtrudeOption 0x1 = Recognize extrude features automatically
fwHoles 0x8 = Recognize hole features automatically
fwRevolve 0x4 = Recognize revolve features automatically
fwRibs 0x20 = Recognize rib features automatically
fwSketchedBend 0x80 = Recognize sketched bend features automatically
fwVolume 0x2 = Recognize volume features automatically

返回值为识别特征的数量。

(3)第三个为RecognizeFeatureINteractive,这个API的含义为在solidworks中以交互方式识别导入的特性,下面是官方的解释:

输入值有两个,第一个为要识别的类型,第二个为定义的交互选项fwInteractiveRecognitionOptions_e

Member Description
fwChainFeatures 0x1 = Chain feature faces. Applies to these features: * Fillets * Chamfers * Boss revolve * Cut revolve * Holes
fwNormalToSketch 0x2 = Turn on or turn off normal to sketch

本篇文章要介绍的就是这么多,我们下篇文章再见。

相关推荐
qq_406176148 小时前
关于JavaScript中的filter方法
开发语言·前端·javascript·ajax·原型模式
醇氧8 小时前
Ping 127.0.0.1 具有 32 字节的数据:一般故障。【二】
运维·服务器·开发语言
码农水水8 小时前
中国邮政Java面试:热点Key的探测和本地缓存方案
java·开发语言·windows·缓存·面试·职场和发展·kafka
CCPC不拿奖不改名8 小时前
python基础:python语言中的控制结构+面试习题
开发语言·python·学习
MM_MS8 小时前
Halcon基础知识点及其算子用法
开发语言·人工智能·python·算法·计算机视觉·视觉检测
a程序小傲9 小时前
小红书Java面试被问:TCC事务的悬挂、空回滚问题解决方案
java·开发语言·人工智能·后端·python·面试·职场和发展
朝九晚五ฺ9 小时前
从零到实战:鲲鹏平台 HPC 技术栈与并行计算
java·开发语言
CUIYD_19899 小时前
Freemarker 无法转译 & 字符
java·开发语言·spring
superman超哥9 小时前
Rust Vec的内存布局与扩容策略:动态数组的高效实现
开发语言·后端·rust·动态数组·内存布局·rust vec·扩容策略
Evand J9 小时前
【MATLAB例程,附代码下载链接】基于累积概率的三维轨迹,概率计算与定位,由轨迹匹配和滤波带来高精度位置,带测试结果演示
开发语言·算法·matlab·csdn·轨迹匹配·候选轨迹·完整代码