A required resource was ... (not availible?) running an api program.

Aug 03, 2007 4 Replies

Hello,



I've been doing some api programming. At the time I'm making a program simulating a milling curve in space. At the beginning of the program SolidWork run normal. After a while (app. after creating 25 sketches) SolidWorks slows down, and becomes even slower every time it creates more sketches. After having created 75 sketches, (it is always 75) SolidWorks send you a messagebox saying: "A required resource was " and that's it. It doesn't say what kind of problem SolidWorks have. After clicking the OK button, SolidWorks run pretty fast again. Until sometime it just exits my program without any message. I presume some sort of cache or something like it force this problem. It is not the UNDO list. I flush it without any differences.



Have someone of you had the same problem? If so, what did you do to resolve the problem. If not, do someone have an idea?



Best regards,



Ulf



I'm no pro at this, but sounds like a memory leak. It may be SolidWorks or it may be your routine. You may want to review to make sure objects are being handled correctly, as a starting point.

Matt Lorono

formatting link
formatting link

Make sure any and all objects are set to NOTHING at the end of your program before it closes. This includes all document objects, feature opjects, application ("swApp"), etc.

Hi,

first of all I want to mention that I write my programs in C#. I do not allocate any memory other than my local variables which are only "doubles" and only 18 of them. Below you will see my code:

iSwApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swSketchAutomaticRelations, false); iSwApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swSketchInference, false);

modDoc.Extension.SelectByID2("", "FACE", 0.3, 0.1,

0.1, false, 0, null, 0); modDoc.InsertSketch2(false); modDoc.ViewZoomTo2(pU0x-Math.Abs(p0x-pU0x), pU1y +Math.Abs(p0y-pU1y), 0.05, pL1x+Math.Abs(p1x-pL1x), pL0y-Math.Abs(p1y- pL1y), 0.05);

// Centerline swLineCenter = (ISketchSegment)modDoc.CreateLine2(p0x, p0y, p0z, p1x, p1y, p1z); swLineCenter.ConstructionGeometry = true; modDoc.Extension.SelectByID2("", "SKETCHPOINT", p0x, p0y, p0z, false, 0, null, 0); modDoc.Extension.SelectByID2("", "SKETCHPOINT", p1x, p1y, p1z, true, 0, null, 0); modDoc.SketchAddConstraints("sgFIXED");

// Topline of slot swLineTop = (ISketchSegment)modDoc.CreateLine2(pU0x, pU0y, pU0z, pU1x, pU1y, pU1z); modDoc.Extension.SelectByID2("", "SKETCHPOINT", pU0x, pU0y, pU0z, false, 0, null, 0); modDoc.Extension.SelectByID2("", "SKETCHPOINT", pU1x, pU1y, pU1z, true, 0, null, 0); modDoc.SketchAddConstraints("sgFIXED");

// Bottomline of slot swLineBottom = (ISketchSegment)modDoc.CreateLine2(pL0x, pL0y, pL0z, pL1x, pL1y, pL1z); modDoc.Extension.SelectByID2("", "SKETCHPOINT", pL0x, pL0y, pL0z, false, 0, null, 0); modDoc.Extension.SelectByID2("", "SKETCHPOINT", pL1x, pL1y, pL1z, true, 0, null, 0); modDoc.SketchAddConstraints("sgFIXED");

// Enabling automatic sketch relations iSwApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swSketchInference, true); iSwApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swSketchAutomaticRelations, true);

// Inserting the Arcs modDoc.Extension.SelectByID2("", "SKETCHPOINT", pU1x, pU1y, pU1z, false, 0, null, 0); resultArc = modDoc.CreateTangentArc2(pU1x, pU1y, pU1z, pL1x, pL1y, pL1z, (int)swTangentArcTypes_e.swForward); modDoc.Extension.SelectByID2("", "SKETCHPOINT", pL0x, pL0y, pL0z, false, 0, null, 0); resultArc = modDoc.CreateTangentArc2(pL0x, pL0y, pL0z, pU0x, pU0y, pU0z, (int)swTangentArcTypes_e.swForward);

// Creating a FeatureCut. modDoc.FeatureManager.FeatureCut(true, false, false, 0, 0, 0.01, 0.1, false, false, false, false, 0.018, 0.018, false, false, false, false, false, true, true);

As you can see I make featureCut of a slot. This stops after 75 times with the message.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required