Hi Marshal
To share the entire model is a bit difficult but I hope screenshots and explanations will help.
What I have noticed this morning is that Fusion 360 never release the memory after the parameter change has been performed by the python code. It can be seen in the activity manager that the maximum amount of RAM is still allocated. When when the code is run again, fusion starts allocating the maximum amount of RAM from the previous run. It now starts with that previous amount and during the execution it allocates ever more RAM on top of the previous amount.
If I let it run to the end (this is only possible if I limit the parameter range), even larger amount of RAM has been allocated. Every time I restart the code fusion starts with the previous amout every time until all off the computers RAM is allocated and fusion 360 stops working.
If I after each run "Clear User Cache Data" Fusion releases the allocated RAM and come back to normal values to start the execution with.
However, when the program of cause also allocates more and more RAM during execution of the python code I am not able to "Clear User Cache Data", in that case I first have to interrupt the execution before I can restart it.
The structure is a folded cylinder which I can fold up and down with the attached code. In my case I change the innerdiameter to control the folding. The structure also have additional folded tubes that can be folded up and down by changing an angle. The model is a bit special but it works perfectly during the parameter change procedure but the problem is the memory issue. My computer has 16 GB of RAM and that should be enougth. The issue seems to be that the memory will not be released.
This is the cross section.

I use Revolve and Extrude to arrive at the geometry below.

The Python code below is used. I am not a professional programmer so the code is probably not the most efficient but it works fine for this purpose.
#Author-Peter__B
#
#Description-The code changes parameters, take a snapshot of each state and
# saves the pictures-files in .png format. A textfile will be
# generated for each parameter. The textfile documents all
# parameterchanges and is useful when the restarting the process in
# the case the program of some reason has been interrupted.
#
#
# GENERAL INPUT DATA:
#
# ResultFolder - This folder has to be created on the computers harddrive.
# (To be set by the user).
# ImageWidth - The pictures width - resolution.
# (To be set by the user).
# ImageHeight - The pictures height - resolution.
# (To be set by the user).
#
# PARAMETER SPECIFIC INPUT DATA for ParamA:
#
# parametersParamA - Objects variabel storing and communicating with
# Fusion 360 model. Only the attribute inside the
# paranthesis shall be set by the user.
# StartParamA - Startvalue for the parametersParamA.value.
# (To be set by the user).
# IncrParamA - The incremental change in parametersParamA.value.
# (To be set by the user).
# EndParamA - The endvalue of parametersParamA.value.
# (To be set by the user).
# PictNameParamA - Name that identifies the pictures. The code automatically
# adds a counting index for numbering of the pictures).
# (To be set by the user).
# InfoNameParamA - Name that identifies the textfile containing information
# of the generated pictures.
# (To be set by the user).
# CntStartParamA - Parameters that sets start of the pictures counting index.
# (To be set by the user).
# ActivateParamA - Tells the code in the parametersParamA shall be changed by
# the "for loop".
# (To be set by the user).
#
# ETC. for PARAMETER SPECIFIC INPUT DATA for ParamB and ParamC:
#
#
# Very small modification of the code have to be done to handle additional
# parameters, see below:
#
# 1) Add another "box" for e.g. ParamD, "# Specific Data for the ParamD".
#
# 2) Add another object under "Creation of objects for inputs parameters of
# interest" for e.g .ParamD.
#
# 3) Add another object for e.g. ParamD to the lists under
# "Creates resultfolders for the parameters A, B, C",
# "Ensures that the parameters are in their initial positions" and
# "Call of subroutines for parameterchanges".
import adsk.core, adsk.fusion, adsk.cam, os
app = adsk.core.Application.get()
ui = app.userInterface
des = app.activeProduct
# General Input Data.
ResultFolder = 'D:/EX/'
ImageWidth = 2560
ImageHeight = 1440
# Specific Data for the ParamA.
parametersParamA = des.userParameters.itemByName('DiameterFolding')
StartParamA = 80.0
IncrParamA = 0.05
EndParamA = 80.2
PictNameParamA = 'ParamA'
InfoNameParamA = 'InfoParamA'
CntStartParamA = 1
ActivateParamA = 'True'
# Specific Data for the ParamB.
parametersParamB = des.userParameters.itemByName('ElevationAngleFront')
StartAngleParamB = 0.001
IncrAngleParamB = 0.001
EndAngleParamB = 0.005
PictNameParamB = 'ParamB'
InfoNameParamB = 'InfoParamB'
CntStartParamB = 1
ActivateParamB = 'False'
# Specific Data for the ParamC.
parametersAntRear = des.userParameters.itemByName('ElevationAngleRear')
StartAngleAntRear = 0.001
IncrAngleAntRear = 0.001
EndAngleAntRear = 0.005
PictNameAntRear = 'ParamC'
InfoNameAntRear = 'InfoParamC'
CntStartParamC = 1
ActivateParamC = 'False'
# Function for creation of input objects.
class inp_val:
def __init__(self,a,b,c,d,e,f,g,h,i,j,k):
self.param = a
self.startPar = b
self.incPar = c
self.endPar = d
self.incStartPar = e
self.pictName = f
self.infoName = g
self.resDirGlobal = h
self.imgWidth = i
self.imgHeight = j
self.active = k
# Subroutine for saving pictures in png-format.
def chg_par(prop_obj):
InfoFile = prop_obj.resDirGlobal + prop_obj.pictName + '/' + prop_obj.infoName + '.txt'
while prop_obj.startPar <= prop_obj.endPar:
prop_obj.param.value = prop_obj.startPar
# adsk.doEvents()
fileName = prop_obj.resDirGlobal + prop_obj.pictName + '/' + prop_obj.pictName + str(prop_obj.incStartPar).zfill(4)
app.activeViewport.saveAsImageFile(fileName, prop_obj.imgWidth, prop_obj.imgHeight)
InfoText = open(InfoFile,'a')
InfoText.write("%.20s,%.i\n" %("cnt:", prop_obj.incStartPar))
InfoText.write("%.25s,%.4f\n" %(prop_obj.param.name, prop_obj.startPar))
InfoText.write('\n')
InfoText.close()
prop_obj.startPar += prop_obj.incPar
prop_obj.incStartPar += 1
InfoText = open(InfoFile,'a')
InfoText.write('\n')
InfoText.write('Ready')
InfoText.close()
# Creation of objects for inputs parameters of interest.
ParamA = inp_val(parametersParamA, StartParamA, IncrParamA, EndParamA,\
CntStartParamA, PictNameParamA, InfoNameParamA, ResultFolder,\
ImageWidth, ImageHeight, ActivateParamA)
ParamB = inp_val(parametersParamB, StartAngleParamB, IncrAngleParamB,\
EndAngleParamB, CntStartParamB, PictNameParamB,\
InfoNameParamB, ResultFolder, ImageWidth, ImageHeight,\
ActivateParamB)
ParamC = inp_val(parametersAntRear, StartAngleAntRear, IncrAngleAntRear,\
EndAngleAntRear, CntStartParamC, PictNameAntRear,\
InfoNameAntRear, ResultFolder, ImageWidth, ImageHeight,\
ActivateParamC)
# Sets the current directory to "ResultsFolder".
os.chdir(ResultFolder)
# Creates resultfolders for the parameters A, B, C.
for resFold in [ParamA, ParamB, ParamC]:
resPath = resFold.resDirGlobal + resFold.pictName + '/'
if not os.path.exists(resPath):
os.mkdir(resPath)
# Ensures that the parameters are in their initial positions.
for initState in [ParamA, ParamB, ParamC]:
if initState.active == 'True':
initState.param.value = initState.startPar
adsk.doEvents()
# Call of subroutines for parameterchanges.
for comp in [ParamA, ParamB, ParamC]:
if comp.active == 'True':
chg_par(comp)
Regards
Peter