Kubotek Forum

KeyCreator CAD & CKD Viewer Technical discussion of CAD/CAM and integrated partner products
Customer Forum > KeyCreator CAD & CKD Viewer > kxl notestate issue View modes: 
User avatar
Advanced member
Advanced member
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:


:start
INT hundo
NoteState hundo

MASKCLEAR
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
MASKCLEAR

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

MASKCLEAR

CLEAR hDim
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

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

:end
MASKCLEAR


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.

User avatar
Advanced member
Advanced member
Hans_Winkler - 9/10/2021 9:15:14 PM
   
RE:kxl notestate issue
Dana,
use the Redraw function (eliminate the notestate) after the DelEnt hDim or the purgeto hundo line, and it will do what you want, I believe. Though the Redraw is for view manipulation, it does seem to get rid of the temp display of the dimension.

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

User avatar
Advanced member
Advanced member
Dana - 9/15/2021 10:32:46 AM
   
RE:kxl notestate issue
Thanks Hans, that did it.  I didn't realize redraw was even still a thing since it was dropped from the user interface as unnecessary years ago.

User avatar
Advanced member
Advanced member
Dana - 9/15/2021 11:19:41 AM
   
RE:kxl notestate issue
OK, now I have one more minor issue.  Updated version here:

:start
INT hundo
NoteState hundo

MASKCLEAR
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
MASKCLEAR

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] = {0, arcdia/10, 1, .6, 0, 1, 0, 0, 0, 0, 0, 0, 1}

CIRDIM 2, , ,arcx ,arcy ,arcz ,hArc,,,0,,,,,diminfo1,,txtatt
Redraw

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

MASKCLEAR

CLEAR hDim
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

:finish
DelEnt hDim
Redraw
purgeto hundo

:end
MASKCLEAR


When the dimension is created, it should use the values in diminfo1 and txtatt... but it doesn't; the dimension is created using the current system values.  Any ideas on why it doesn't work?

User avatar
Advanced member
Advanced member
Hans_Winkler - 9/15/2021 12:43:58 PM
   
RE:kxl notestate issue
Dana, a few things I found
1) Your commas are a little off
CIRDIM 2, , ,arcx ,arcy ,arcz ,hArc,,,0,,,,,diminfo1,,txtatt (your line)
CIRDIM 2, , ,arcx ,arcy ,arcz ,hArc,,,, 0,,, diminfo1, diminfo2, txtatt
2) The following two parameters can't be 0 according to the docs
diminfo1[17] = 1
diminfo1[25] = 1

3) According to the docs for the CIRDIM, if you define diminfo1, then diminfo2 must also be defined!
(from the docs) [iaDimInfo1] .... If this array is given daDimInfo2 must also be given.

You are going to have to define the diminfo2 to your liking. The code below works, though I'm sure you have to tweak the diminfo2 array.


:start
INT hundo
NoteState hundo

MASKCLEAR
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
MASKCLEAR

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

diminfo1[17] = 1
diminfo1[25] = 1

double txtatt[13] = {0, arcdia/10, 1, .6, 0, 1, 0, 0, 0, 0, 0, 0, 1}

CLEAR diminfo2
DOUBLE diminfo2[0]
ARRAY diminfo2[11] = {1,1,1,1,1,1,0,1,1,1,1}

 CIRDIM 2, , ,arcx ,arcy ,arcz ,hArc,,,, 0,,, diminfo1, diminfo2, txtatt
Redraw

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

MASKCLEAR

CLEAR hDim
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

:finish
DelEnt hDim
Redraw
purgeto hundo

:end
MASKCLEAR


User avatar
Advanced member
Advanced member
Dana - 9/15/2021 3:03:20 PM
   
RE:kxl notestate issue
Doh!  You're right, of course... I was going nuts counting those stupid commas.  I cleaned it up quite a bit and now except for some weirdness with the text alignment and leaders which I'm going to ignore, it's working to my satisfaction now.


//AutoDDE hole diameter changer
//DMH 210915-1

:start
MASKCLEAR
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
MASKCLEAR

INT hundo
NoteState hundo

arcdia = @dbldat[0] * 2
location hcenter, 4,,,,hArc

CLEAR diminfo1
INT diminfo1[40]
diminfo1[0] = 1 // diameter
diminfo1[3] = 2 // auto arrow direction
diminfo1[8] = 46 // "." decimal separator
diminfo1[9] = 1 // text aligned with leader lines
diminfo1[10] = 1 // autocenter text
diminfo1[14] = 1 // trailing zeros
diminfo1[16] = 7 // decimal places
diminfo1[17] = 1 // roundoff
diminfo1[25] = 1 // roundoff for dual dims, doesn't apply but zero is invalid

CLEAR diminfo2
Double diminfo2[11] = {.1,.1,1,1,0,0,0,1,0,0,.1}
double txtatt[13] = {0, arcdia/10, 1, .6, 0, 1, 0, 1, 2, 0, 0, 0, 0}

CIRDIM 2,,hcenter,,,,hArc,,,,0,,,diminfo1, diminfo2,txtatt
CLEAR hDim
HEntity hDim
LastEnt hDim
Redraw

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

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

:finish
DelEnt hDim
Redraw
purgeto hundo

GOTO start

:end
MASKCLEAR

1
Login