Kubotek Forum

KeyCreator CAD & CKD Viewer Technical discussion of CAD/CAM and integrated partner products
Subscribe to post
User avatar
Dana - (9/9/2021 3:45:04 PM)
kxl notestate issue
I have a kxl to create a circular dimension, prompt the user for a new value, use DDE to change the solid feature, then delete the dimension:

INT hundo
NoteState hundo

MASKENTITY 3  //arcs and circles

// Prompt the user to select an entity
GetEnt "Select arc to modify", hArc, hArci, 0, 0, 1, 0
if (@error != 0)
    GOTO end

arcdia = @dbldat[0] * 2
arcx = @matrix[9]
arcy = @matrix[10]
arcz = @matrix[11]

CLEAR diminfo1
INT diminfo1[0]
ARRAY diminfo1[40] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
diminfo1[0] = 1
diminfo1[1] = 3
diminfo1[8] = 46
diminfo1[9] = 1
diminfo1[10] = 1
diminfo1[14] = 1
diminfo1[16] = 7
diminfo1[29] = 14
diminfo1[30] = 8
diminfo1[31] = 14
diminfo1[32] = 8

double txtatt[13] // text height
txtatt[1] = arcdia / 10
CIRDIM 2, , ,arcx ,arcy ,arcz ,hArc,,,0,,,//diminfo1,,//txtatt

GETDBL "Enter new diameter (%f)", arcdia, newdia
on (@key + 3) goto finish, finish,
//SET DEPTH, dCPlaneDepth


HEntity hDim
LastEnt hDim

CLEAR adPickPt
Double adPickPt[3] = { 0, 0, 0 }
CLEAR aAddFaces
HEntity aAddFaces[0]
CLEAR aRemoveFaces
HEntity aRemoveFaces[0]
DIMENSIONDRIVENEDIT hDim, adPickPt, newdia, aAddFaces, aRemoveFaces

DelEnt hDim
purgeto hundo //attempt to let single undo go back, but no joy


If I understand the command, the purgeto command at the end should remove all the intervening states so that a single undo will go back to where it was at the start, but I have to undo twice to get there (first undo brings the dimension back and the second one both removes the dimension and restores the solid back to the original).  Shouldn't it go straight back with a single undo?  If I remove the notestate immediately before the purgeto, undo works, but the dimension doesn't disappear until the mouse is moved.