AnsweredAssumed Answered

Changing Cosmetic thread settings VIA API

Question asked by Sanya Shmidt on Oct 5, 2014
Latest reply on Mar 17, 2017 by Julian Thoresson

Hello guys!

 

I`m looking for a way to change Size and thread Callout via API. I have a simple model of the pipe with threads on both ends. User can configure it using dropdown menus and select size NPT and if it needs to be threaded or not. I have no problems changing size, thread engagement and minor diameter as well as suppressing or unsuppressing threads.

 

I`m not sure how via code to change the following: ( I assume if I change Size - thread callout will automatically be changed)

 

cosmetic thread.PNG

 

I guess the steps are to find the cosmetic feature 1st and than change the parameter: -

 

BlindDepth AKA thread engagement and MinorDiameter not a problem as I mentioned above.  What is DiameterType ? Is this what I have to change?

I tried to change callout by using this but nothing changes:

swCosThread.ThreadCallout = "text here"

 

Should I use swCosThread = swSubFeat.ModifyDefinition (????)  What would be the right way to do this? Syntax?

cosmetithreadTree.PNG

 

 

What I have so far is:

 

    Dim swApp As SldWorks.SldWorks

    Dim Part As SldWorks.PartDoc

    Dim swModel As SldWorks.ModelDoc2

    Dim swFeat As SldWorks.Feature

 

    Dim swCosThread As SldWorks.CosmeticThreadFeatureData

    Dim swSubFeat As SldWorks.Feature

    Dim sFeatType As String

 

 

                          swFeat = swModel.FirstFeature

                        Do While Not swFeat Is Nothing

                            swSubFeat = swFeat.GetFirstSubFeature

                            Do While Not swSubFeat Is Nothing

                                sFeatType = swSubFeat.GetTypeName

                                'MsgBox(sFeatType)

 

                                Select Case sFeatType

 

                                    Case "CosmeticThread"

                                      swCosThread = swSubFeat.GetDefinition

 

                                        Debug.Print("      BlindDepth       = " & swCosThread.BlindDepth / 0.0254# & " in")

                                        Debug.Print("      Diameter         = " & swCosThread.Diameter / 0.0254# & " in")

                                        Debug.Print("      DiameterType     = " & swCosThread.DiameterType)

                                        Debug.Print("      ThreadCallout    = " & swCosThread.ThreadCallout)

                                End Select

                                swSubFeat = swSubFeat.GetNextSubFeature

                            Loop

                            swFeat = swFeat.GetNextFeature

                        Loop

 

 

Any help appreciated.

Thank you.

Outcomes