HyperSizer Support Forum

Software Use => Scripting => Topic started by: Ingenieur81 on June 28, 2017, 01:42:07 AM

Title: Setting fastener diameter with python
Post by: Ingenieur81 on June 28, 2017, 01:42:07 AM
Hello,

I am trying to set component sizing variables (bounds and step size for Detailed Sizing) and the fastener diameter through a python script.
Setting the sizing variables works fine but I am not able to set the fastener diameter.
I am able to get the fastener diameter by simply running:

Code: [Select]
def get_fastener(project, component, variable_ID):
   
# Get the fastener diameter variable.
JointComponent = component.Hole(1)
D_fast = JointComponent.FastenerDiameter*(0.0254)
return D_fast

My code to set the sizing variables and the diameter is as follows:

Code: [Select]
def set_sizing_variable(project, component, variable_ID, min, max, step_size):

    # Given the project, component, and variable ID, set the min thickness, max thickness, and step_size.

    # Get the group associated with the component
    group = project.Groups.GetGroup(component.GroupId)

    # Get the group concept IDs.
    concept_IDs = group.GetConcepts()

    # For each concept, set the variable (if applicable).
    variables = group.Variables
    variable = variables.GetVariable(1, 8)
    variable.MinBound = min/(0.0254) # Convert to inches
    variable.MaxBound = max/(0.0254) # Convert to inches
    variable.StepSize = step_size/(0.0254) # Convert to inches
    group.Save()

def set_fastener(project, component, variable_ID, D_fast, id):
   
# Set the fastener diameter variable.
JointComponent = component.Hole(1)
JointComponent.HasHole = True # In fact this is already set to True because I can get the fastener diameter
JointComponent.FastenerDiameter = D_fast/(0.0254)
component.Save()

As stated the set_sizing_variable function works correctly but the set_fastener function does not update the Bolted Joint Analysis.

Is there also a way to set the Head Diameter and Countersunk Depth of the fastener, I cannot find any reference to those in the manual.

Can anybody help me to get this working?

Regards,
Gertjan
Title: Re: Setting fastener diameter with python
Post by: August on July 05, 2017, 10:16:34 AM
Hi Gertjan,

I looked into your issue and there appears to be a bug that is preventing the API from updating fields in the bolted joint form. We will work on resolving this issue.

-August