Hi everyone, this is my first post... I would really appreciate any help.
Sorry if the question is trivial, I am just starting learning API and after many hours on google I could not find a clear answer to this...
I am wiritng a macro to automatize a series of commands in solidworks, I am now stuck with 2 similar issues:
I want to scale all the selected elements of a sketch by a scale factor and later I want to extrude a closed contour into a solid by a certain depth. I want the scale factor and the depth to be variable imported from an external file or prompted by the user... I am failing this miserably.
My code works if I hardcode the values:
Part.Extension.ScaleOrCopy(False, 0, 0, 0, 0, 0.75)
...
Part.FeatureManager.FeatureExtrusion2(False, False, False, 0, 0, 1.2, 1.2, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
but it does not when I declare and pass the parameters as variables:
Dim ScaleFactor As Long
ScaleFactor = 0.75
Part.Extension.ScaleOrCopy(False, 0, 0, 0, 0, ScaleFactor)
...
Dim Depth As Long
Depth = 1.2
Part.FeatureManager.FeatureExtrusion2(False, False, False, 0, 0, Depth, Depth, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False)
what am I not getting?
Thanks!
Hi Guiuseppe,
i think that you should use double data type instead long data type. Same for parameter Depth in FeatureExtrusion2 method.
From help:
Dim instance As IModelDocExtension
Dim Copy As System.Boolean
Dim NumCopies As System.Integer
Dim BaseX As System.Double
Dim BaseY As System.Double
Dim BaseZ As System.Double
Dim Scale As System.Double
instance.ScaleOrCopy(Copy, NumCopies, BaseX, BaseY, BaseZ, Scale)