#1
|
|||
|
|||
Change dimension value via dialog
I want to add a command to Annotation that will change the size, color and main value of a highlighted (currently selected) dimension. We use charted drawings and I want a dialog to come up and prompt the user for an alpha character (e.g. "A") that will be the main value for the dimension.
I can get the currently selected dimension (the one that is highlighted) by using this code PHP Code:
PHP Code:
But….. I can not seem to put the two together, such as in a lisp file. Such as this in a lisp file that I load. PHP Code:
I tried the precondition parameter in the dialog e.g. PHP Code:
Perhaps there are other methods to get user feed back, such as the read command in Me10. Thanks for any suggestions. Dave Nowak |
#2
|
||||
|
||||
Re: Change dimension value via dialog
I did not try, but it should work similar to this:
PHP Code:
With the code above you don't need the (setf temp_val ..) at all. For test/Debug purpose, make the sto_dim variable visible again or/and do a print in its :after-input.
__________________
|
#3
|
|||
|
|||
Re: Change dimension value via dialog
Thanks for the reply Wolfgang
Your code does work. I’m having problems posting a reply on this forum; don’t know why but as soon as I can I’ll give more details. Thanks Dave Nowak |
#4
|
|||
|
|||
Re: Change dimension value via dialog
I'm back
So.. Wolfgang, your code does work, if I first select a dimension and then select Sto_charted_dim from the toolbox area. This is good, now I’ve made a slight change to the dialog, here is the code PHP Code:
the code for Change Dim to Alpha button is PHP Code:
You supplied the crucial piece of code (getting the highlighted dimension), and thanks for the explanation supplied with your code. Thanks again Dave Nowak |
#5
|
||||
|
||||
Re: Change dimension value via dialog
Hi Dave,
thanks for your feedback! :-) 2 points: If you would have written a straight forward dialog, **with** select dimension, the string for the charted value and the ok action, the pre selection would have worked immediately. But the magic function name get-matching-preselected-objects you have found in a recorder file I guess pushed you to the wrong direction. So your curiousness got punished keep in mind: a have normal selection in dialog (so you can use it interactively as usual) and the preselection method will try to do it's best by filling this variable if possible. YOU don't have to take care on pre selection itself. Making the select variable invisible is just cosmetic for UI. your :Ok-action a) wrap a sd-call-cmds arround (I forgot it) b) the cancel at the end.. remove it! (funny that it doesn't hurt)
__________________
|
#6
|
|||
|
|||
Re: Change dimension value via dialog
Hi Dave,
Here's yet another version that might help you: PHP Code:
1) I'm sure you're already doing this, but it's always a good idea to put your customizations in their own lisp package (helps to prevent unexpected errors!) -- that's what (:in-package :mypackage) line does, and (:use-package :oli) tells the lisp reader that you may be using exported functions from the :oli package (such as sd-defdialog, etc). 2) As Wolfgang mentioned, making the field for the selected dimension invisible is just cosmetic, and making it just a normal selection variable as above will allow it to work with any preselection, if applicable. Also, if you make it visible, you can then process multiple dimensions one after another (using the "Next" button that is in the code above). This was easily done by moving the ok-action code (wrapped in sd-call-cmds, as Wolfgang suggested) into a separate function that can be called either by the ok-action or by pressing the "Next" button. Also note the use of the :next-variable that tells the dialog which variable to make active after the currect selection or action is complete. I hope this helps! Please post back if you have any further questions. Good luck! andy
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! |
#7
|
|||
|
|||
Re: Change dimension value via dialog
Thanks to both of you
A few comments If I wrap the OK in the sd-call-cmds then I do need to remove the cancel at the end, Wolfgang your suspicion was right. The color white, Andy you put a number instead, which I guess is the same as white (whether a RGB value or a Hue-Saturation-Luminosity value); is this the preferred method to indicate color ? Lastly, an odd thing; wrapping the OK in the sd-call-cmds makes the size (text_abs_size) of the dimension very small 0.003937 We use inches as our unit of measure, I suspect that there is a conversion issue. If I make the size of the dimension (text_abs_size) 2.54 instead of 0.1 then the Abs Size of the dimension ends up being 0.1 which is what I want. This is alright as long as I know what’s happening Dave Nowak |
#8
|
|||
|
|||
Re: Change dimension value via dialog
Quote:
Quote:
One other note: in your :variables section, if you create a variable of type :length, it will automatically convert the values for you, allowing you to type in the value in whatever units you are using. In this particular case, it's not likely to be worth the trouble, but for future use, you might find it to be very useful. I hope this helps -- if there's anything that's not clear, just ask! andy
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! |
#9
|
||||
|
||||
Re: Change dimension value via dialog
Hi Andy,
nice code. Fine. Quote:
[ detailed user guidance ] But another issue on your code with the local-function. What will happen now if user opens the dialog (via icon on toolbar, via toolbox, via command line) and simply press APPLY? We will get a lisp error now! What will happen when just entering the string and pressing apply. -> LISP error. a) disable the apply on dialog open b) enable apply button ONLY if dim and string are defined. or c) a little bit easier: wrap arround the sd-call-cmd with a when PHP Code:
Well these are the trivia making the dialog/user interface more safe and the code bigger.
__________________
|
#10
|
||||
|
||||
Re: Change dimension value via dialog
PHP Code:
PHP Code:
__________________
|
#11
|
|||
|
|||
Re: Change dimension value via dialog
Quote:
Quote:
andy
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! |
#12
|
||||
|
||||
Re: Change dimension value via dialog
Quote:
"My Third LISP" It's a good example for LISP learners IMHO. Doing one step after the other, learning one thing after the previous.
__________________
|
#13
|
|||
|
|||
Re: Change dimension value via dialog
Quote:
Indeed! Since we're in the training mode, one other thing that is probably worth pointing out is that the code shown wouldn't actually generate a lisp error when the OK button is pressed -- rather it would not even get to the ok-action since the two variables are both required. Instead, an error message that one or both of the variables is not specified will be displayed (thanks to the nice error checking of the dialog generator). However, clicking the Next button has no such safety net, and will definitely cause unexpected results (in this case, it doesn't actually cause a lisp error either since the error happens in the call to am_dim_props, which appears to have some built-in error checking rather than just throwing an error). So you're *definitely* better off being safe and wrapping the (when ...) around your execution function as Wolfgang described. Alternatively, the execution function could be left as-is, and you could provide the safety in the push-action of the next button as follows: PHP Code:
PHP Code:
andy
__________________
Andy Poulsen AI MAXTools: Dream. Design. Done. It's that easy! Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+! See them in action at www.ai-maxtools.com and then try them for yourself -- FREE! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | Rate This Thread |
|
|