I have a macro that works about 60% of the time and I have no idea why. I will run it with the same data three times and get three different results, please help. The line which fails is:
Set skSegment = Part.SketchManager.CreateCircleByRadius(xValue, yValue, zValue, Range("D" & i).Value / 1000)
where I am just trying to create a circle using variables that are storing the center's data. What is strange is that sometimes if I add a break point at this line and do NOTHING except click the continue button the code will work...at least on my computer. I am now on a better computer but it is failing more frequently. I have watched the variables used in the expression and they always are valid numbers. Unfortunately the upload video feature is currently down, but what happens is the blue circle and orange coordinate axes will flash on the screen for a moment and then disappear and no circle will have been created despite the sketch having attempted to create one. Sorry if this doesn't really make sense, I do not know how to explain it...
add this code to see if it fixes it.
add it to where you put the breakpoint
the code is DoEvents add it right before Set SkSegment = Part.SketchManager.CreateCircleByRadius(xValue, yValue, zValue, Range("D" & i).Value / 1000)
like this
DoEvents
Set skSegment = Part.SketchManager.CreateCircleByRadius(xValue, yValue, zValue, Range("D" & i).Value / 1000)
post the code if you need further help
also use the new API
https://help.solidworks.com/2019/english/api/sldworksapi/SOLIDWORKS.Interop.sldworks~SOLIDWORKS.Interop.sldworks.IModelDoc2~ICreateCircleByRadius2.html
also read the information in this link