how to edit the sketch and hence edit the extruded feature using API?

Aug 29, 2006 2 Replies

Dear all,



Now i am working on Solidworks API. What i want to do is to modify the feature dimension. In solidworks interface, we can see that if the user want to edit the dimensions except for the depth information of the feature, the user have to access the sketch and edit the sketch to update the feature finally.



So i think it should work in the same way in Solidworks API, is it?



Now what i do is want to modify the coordinates for the sketch points of the sketch to edit the sketch. But a problem emerged, now i can access the chosen feature's sketch and read every sketch point in it. After getting the sketch point, i want to use the funciton of pSketchPoint->SetCoords(modifiedcoord[0], modifiedcoord[1], modifiedcoord[2], &retval); to modify its coordinates, but unfortunately it did not work, the value for retval is FALSE. don't know why. for the coordinates i read from the sketch point and the coordinates which is revalued to the sketch point are transfered between the sketch coordinates system and model system and i have checked these values which are correct. Do i need to add functions such as pModelDoc2->editsketch()...and pModelDoc2->pModelDoc->EditRebuild3 (&retval); before and after the codes to access the sketch and reset its coordinates?



thanks so much



cheers SY



Hi,

I hope the following will help you.

Before you can set new coords to the sketchpoint, the sketch must be in editsketch mode (AFAIK). I am also working with the Solidworks API and I do it in the following way:

//first select the sketch by its name, if not selected yet pModelDocExtension->SelectByID2( ... )

//put the sketch in "edit mode" pModelDoc2->EditSketch();

//make your point changes pSketchPoint->SetCoords ( ...);

//leave the "edit mode" pModelDoc2->InsertSketch2(VARIANT_TRUE);

Frank.

Frank M=C3=B6bus =E5=AF=AB=E9=81=93=EF=BC=9A

Dear Frank

It works, thanks so much my codes cannot work, mainly because i did not select the sketch before setting its editing status thanks again Have a good day ahead

Cheers SY

Join the Discussion

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

Didn't find your answer?

Ask the community — no account required