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

本文详细介绍了SolidWorks中的三个关键API:CreateFeatures用于创建可识别的特征,RecognizeFeatureAutomatic自动识别导入特性,以及RecognizeFeatureInteractive交互式识别。通过VBA示例展示了如何使用这些API进行操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

下面是要介绍的相关API:

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

输入参数为fwFeatureCreationOptions_e

MemberDescription
fwAddConstraintsToSketch0x1 = 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
fwAllowFailFeatureCreation0x2 = 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

MemberDescription
fwAutoEdgeFlange

0x100 = Recognize edge flange features automatically

fwAutoHemFlange

0x200 = Recognize hem features automatically

fwBaseFlange0x40 = Recognize base flange features automatically
fwChamfils0x10 = Recognize fillets and chamfers automatically
fwExtrudeOption0x1 = Recognize extrude features automatically
fwHoles0x8 = Recognize hole features automatically
fwRevolve0x4 = Recognize revolve features automatically
fwRibs0x20 = Recognize rib features automatically
fwSketchedBend0x80 = Recognize sketched bend features automatically
fwVolume0x2 = Recognize volume features automatically

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

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

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

MemberDescription
fwChainFeatures0x1 = Chain feature faces. Applies to these features:
  • Fillets

  • Chamfers

  • Boss revolve

  • Cut revolve

  • Holes

fwNormalToSketch0x2 = Turn on or turn off normal to sketch

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喵桑さん

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值