I have set up a part so that the geometry is driven by values defined in equations (e.g. "beam_height" = 3, "base_extent" = 1, etc). I would like to reference those values through the API. Is there a better way to do it than iterating through the equations defined in a part and comparing string values to see whether it matches the names of my variables?
The following snippet (of Python) works, but seems kludgey:
def helloworld(): swApp = sldworks.SldWorks() swApp.Visible = True model = swApp.ActiveDoc eqm = model.GetEquationMgr d = {'beam_length': None, 'beam_width': None, 'beam_height': None, 'base_extent': None} for i in xrange(eqm.GetCount): for key in d: if eqm.equation(i).startswith('"%s"=' % key): d[key] = eqm.value(i) return dI was imaginging that there might be a way to ask SolidWorks to evaluate an expression passed in as a string -- is there such a thing?
Thanks!
tim
SolidworksApi macros