Big David

How to Create a  Yes/No Customproperty?

Discussion created by Big David on Apr 19, 2020
Latest reply on Apr 20, 2020 by Big David

Hello,my friends.I am David,and I am a beginner of Solidworks API and also a beginner of English.

I have some problems when I want to create a Yes/No  custom property.

In order to describe the problem clearly. I create a simple test project.

Code as below:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim swApp As SldWorks.SldWorks
      Dim swModel As SldWorks.ModelDoc2
      Dim swCustomProMgr As SldWorks.CustomPropertyManager
      swApp = New SldWorks.SldWorks
      swModel = swApp.ActiveDoc()
      swCustomProMgr = swModel.Extension.CustomPropertyManager("")
      swCustomProMgr.Add3("Is welding part", SwConst.swCustomInfoType_e.swCustomInfoYesOrNo,       ComboBox1.Text, 1)
End Sub

Windows form as below:

The problem is:

When I choose "Yes" in the combobox control. The custom property added successfully. But it is failed when I choose "No" in the combobox control. I don't know where the problem? 

Is there anybody can help me?

By the way, my Solidworks version is 2016.

 

Outcomes