Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to update K-Factor through API

391 views
Skip to first unread message

Steve Fye

unread,
Aug 18, 2004, 3:20:28 PM8/18/04
to
Ok, I'm pulling my hair out over this one. This subroutine was
modified from the "Get all sheetmetal feature data" example. I got
the example running fine, but I'm trying to get it to change the
K-Factor for a part. It simply won't do it. The value for
swCustBend.KFactor is updated, but not the model.

Any help is greatly appreciated. Here is the subroutine in question
(the code in question has been commented for convenience):

'Begin Code

Sub Process_SheetMetal(swApp As SldWorks.SldWorks, swModel As
SldWorks.ModelDoc2, swFeat As SldWorks.Feature)

Dim swSheetMetal As SldWorks.SheetMetalFeatureData
Dim swCustBend As SldWorks.CustomBendAllowance

Set swSheetMetal = swFeat.GetDefinition
Set swCustBend = swSheetMetal.GetCustomBendAllowance

Debug.Print "PROCESS SHEET METAL"
Debug.Print " +" & swFeat.Name & " [" & swFeat.GetTypeName & "]"
Debug.Print " BendRadius = " & swSheetMetal.BendRadius * 1000#
& " mm"

'Change Default Bend Radius
Dim bRet As Boolean
Dim NewBendRadius As Double

' Rollback to change default bend radius
bRet = swSheetMetal.AccessSelections(swModel, Nothing):
Debug.Assert bRet

' Set new bend radius value
NewBendRadius = (0.083 * 25.4 / 1000)
swSheetMetal.BendRadius = NewBendRadius


' Apply changes to model
bRet = swFeat.ModifyDefinition(swSheetMetal, swModel,
Nothing): Debug.Assert bRet

'Display Results
Debug.Print " New BendRadius = " & swSheetMetal.BendRadius
* 1000# & " mm"
Debug.Print " K-Factor (old) = " & swCustBend.KFactor



'===========================================================================
'===========================================================================
'===========================================================================
'Change Default KFactor
Dim NewKFactor As Double

Set swSheetMetal = swFeat.GetDefinition
Set swCustBend = swSheetMetal.GetCustomBendAllowance

' Set new KFactor value
NewKFactor = 0.456
swCustBend.KFactor = NewKFactor

'Apply changes
'THIS LINE DOES NOT APPEAR TO UPDATE THE ACTUAL MODEL
bRet = swFeat.ModifyDefinition(swSheetMetal, swModel,
Nothing): Debug.Assert bRet

'Display Results
Debug.Print " K-Factor (new) = " & swCustBend.KFactor

'THe above line displays the correct new K-Factor. The model
still does not get updated.
'===========================================================================
'===========================================================================
'===========================================================================


Process_CustomBendAllowance swApp, swModel, swCustBend

End Sub
'End Code

Corey Scheich

unread,
Aug 18, 2004, 3:39:02 PM8/18/04
to
Did you try rebuilding

Corey

"Steve Fye" <in...@rhapsodydesignsolutions.com> wrote in message
news:2e772407.04081...@posting.google.com...

Steve Fye

unread,
Aug 19, 2004, 11:47:39 AM8/19/04
to
"Corey Scheich" <cERoNeou...@garlockequiP.com> wrote in message news:<2ohp9rF...@uni-berlin.de>...
> Did you try rebuilding


Not through the API, but after the macro has run, I manually rebuild,
and check the K-Factor (REdefine Feature for Sheet MEtal) it's still
the original value. Nothing changes.

Help!

0 new messages