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

Discussion in 'SolidWorks' started by syshieley, Aug 29, 2006.

  1. syshieley

    syshieley Guest

    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
     
    syshieley, Aug 29, 2006
    #1
  2. syshieley

    Frank Möbus Guest

    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öbus, Aug 29, 2006
    #2
  3. syshieley

    syshieley Guest

    Frank Möbus 寫é“:
    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
     
    syshieley, Aug 30, 2006
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.