CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 12-10-2009, 07:54 PM
wathavy's Avatar
wathavy wathavy is offline
Registered User
 
Join Date: Jul 2007
Location: Japan Nagano
Posts: 537
Red face Automate loading command reference?

Hi.

I found this command useful for making customized command.
Code:
(oli:sd-online-reference)
Is there a way I can load this command whenever OSM is started?

Thank you.
__________________
Toshi
Reply With Quote
  #2  
Old 12-11-2009, 05:12 AM
tom kirkman's Avatar
tom kirkman tom kirkman is offline
Registered User
 
Join Date: Oct 2002
Location: Perrysburg, Ohio
Posts: 397
Re: Automate loading command reference?

Place the line in your sd_customize file and it will load everytime

Tom
__________________
Tom Kirkman

Creo Elements/Direct 20.1
Dell Precision 3581
https://www.o-i.com
Reply With Quote
  #3  
Old 12-12-2009, 04:03 PM
wathavy's Avatar
wathavy wathavy is offline
Registered User
 
Join Date: Jul 2007
Location: Japan Nagano
Posts: 537
Re: Automate loading command reference?

Thank you, Tom.

Best regards.
__________________
Toshi
Reply With Quote
  #4  
Old 12-22-2009, 03:52 PM
wathavy's Avatar
wathavy wathavy is offline
Registered User
 
Join Date: Jul 2007
Location: Japan Nagano
Posts: 537
Re: Automate loading command reference?

The loading was done as follow;

Code:
;; The Label be turned off at start up
(set_show (oli:sd-inq-current-vp) :3dgeo_label :off)  
;; Show lisp on line reference
(oli:sd-online-reference)

;; for sd_customize:  have a rigthmouse button context menu for sharing/copying parts

(oli::sd-set-cmd-specific-context-menu-entries 
------etc------
Then the message box pops up as shown.
And this was the default action for the same command anyway.
But is there any way I can disallow the pop-up dialogue box?

Thank you for your attention.
Attached Thumbnails
Click image for larger version

Name:	PopupComment.png
Views:	315
Size:	36.7 KB
ID:	1625  
__________________
Toshi
Reply With Quote
  #5  
Old 12-22-2009, 04:19 PM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Automate loading command reference?

Quote:
Originally Posted by wathavy View Post
Then the message box pops up as shown.
And this was the default action for the same command anyway.
But is there any way I can disallow the pop-up dialogue box?
I'm not aware of a supported and documented way to disallow the pop-up, but you can immediately hide the display box by adding the command
Code:
(display :hide)
right after the line to load the online reference.

You can also clear the display box by using the command
Code:
display :clear
I hope this helps!

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!
Reply With Quote
  #6  
Old 12-22-2009, 05:51 PM
wathavy's Avatar
wathavy wathavy is offline
Registered User
 
Join Date: Jul 2007
Location: Japan Nagano
Posts: 537
Re: Automate loading command reference?

Thank you, Andy.

I recoded what I do with the message box, then I got a line of this.
(display :clear-hide )
Which is equivalent of pressing clear and close button.

But by writing this even at the end of the sd_customize file, it does not erase the message box.

I seem to need to lag the timing slightly behind than this sd_customize excursion.

Any idea available?

Thank you.
__________________
Toshi
Reply With Quote
  #7  
Old 12-23-2009, 06:42 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Automate loading command reference?

Quote:
Originally Posted by wathavy View Post
I recoded what I do with the message box, then I got a line of this.
(display :clear-hide )
Which is equivalent of pressing clear and close button.

But by writing this even at the end of the sd_customize file, it does not erase the message box.

I seem to need to lag the timing slightly behind than this sd_customize excursion.
Ah, yes -- I forgot to mention the :clear-hide option as well (but you found it using the recorder -- nice job!)

As far as delaying the closing of the box, one way is to use events (which is really quite a bit beyond the scope of beginning programming... but I guess we can tale a look at it!)

What you want is for Modeling to do something when it finishes loading, or in other words, when it is waiting for the user to enter a command. Modeling allows you to do this using events (actually, events are triggered for a bunch of different things, but we'll only worry about this one for now).

The event that we are interested in is the *SD-ENTER-COMMAND-EVENT* which is triggered when Modeling returns to the "Enter Command" state i.e. waiting for the user to do something (at the top level -- no other commands are active).

First, we'll need a function to call when this event is triggered, and then we'll need to subscribe that function to the correct event. Something like this should do the job:
Code:
(defun my-clear-hide (&rest args)
  ;; unsubscribe this function from the enter-command event
  ;;    so that the output box doesn't get hidden EVERY time a
  ;;    a command finishes -- there may be useful information there!
  (display "test for you from function")
  (oli:sd-unsubscribe-event *SD-ENTER-COMMAND-EVENT* 'my-clear-hide)
  ;; now clear the display box and close it
  (display :clear-hide)
  )

;; now subscribe the above function to the enter command event
(oli:sd-subscribe-event *SD-ENTER-COMMAND-EVENT* 'my-clear-hide)
This should do the trick if you put those lines in your sd_customize file (you'd probably want them at the end, though it really doesn't matter)...

This is getting into more advanced stuff, but if you keep it simple you should be fine!

I hope this helps!

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!
Reply With Quote
  #8  
Old 12-24-2009, 04:05 PM
wathavy's Avatar
wathavy wathavy is offline
Registered User
 
Join Date: Jul 2007
Location: Japan Nagano
Posts: 537
Re: Automate loading command reference?

Hi, Andy.
Thank you for the effort.

I saw the help and try to understand it at the section of SD-SUBSCRIBE-EVENT, but no avail.

In fact your code pops up new error, and I could not solve it by myself.


Any clue?
Attached Thumbnails
Click image for larger version

Name:	NewErrorIsUp.png
Views:	273
Size:	40.2 KB
ID:	1626  
__________________
Toshi
Reply With Quote
  #9  
Old 12-24-2009, 04:20 PM
wathavy's Avatar
wathavy wathavy is offline
Registered User
 
Join Date: Jul 2007
Location: Japan Nagano
Posts: 537
Re: Automate loading command reference?

I used these instead and the above mentioned error message disappeared but the original issue persists.
Code:
;; Show lisp on line reference
(oli:sd-online-reference)

(defun my-clear-hide (&rest args)
  ;; unsubscribe this function from the enter-command event
  ;;    so that the output box doesn't get hidden EVERY time a
  ;;    a command finishes -- there may be useful information there!
  (display "test for you from function")
  (oli:sd-unsubscribe-event "*SD-ENTER-COMMAND-EVENT*" 'my-clear-hide)
  ;; now clear the display box and close it
  (display :clear-hide)
  )

;; now subscribe the above function to the enter command event
(oli:sd-subscribe-event "*SD-ENTER-COMMAND-EVENT*" 'my-clear-hide)
I wonder if there is devil if I automatically enter the reference for the command.

Thank you.
__________________
Toshi
Reply With Quote
  #10  
Old 12-24-2009, 06:24 PM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Automate loading command reference?

Quote:
Originally Posted by wathavy View Post
I used these instead and the above mentioned error message disappeared but the original issue persists.
Code:
;; Show lisp on line reference
(oli:sd-online-reference)

(defun my-clear-hide (&rest args)
  ;; unsubscribe this function from the enter-command event
  ;;    so that the output box doesn't get hidden EVERY time a
  ;;    a command finishes -- there may be useful information there!
  (display "test for you from function")
  (oli:sd-unsubscribe-event "*SD-ENTER-COMMAND-EVENT*" 'my-clear-hide)
  ;; now clear the display box and close it
  (display :clear-hide)
  )

;; now subscribe the above function to the enter command event
(oli:sd-subscribe-event "*SD-ENTER-COMMAND-EVENT*" 'my-clear-hide)
I wonder if there is devil if I automatically enter the reference for the command.
I just saw this and wanted to send a quick reply before heading off for Christmas eve activities...

My apologies! When I posted the above (untested!) code, I forgot to reference the event definitions -- they are (I believe) in the oli package, which is why they threw an error.

The reason quoting the event doesn't work is that when you do that, you've subscribed to a string value rather than to a defined event! So no error occurs, but the "event" (i.e. string you quoted) never occurs, so the function is never called.

So, the way to fix this issue is: rather than quoting the event when subscribing/unsubscribing, you just need to reference the correct (i.e. oli) package where the event is defined:
Code:
;; Show lisp on line reference
(oli:sd-online-reference)

(defun my-clear-hide (&rest args)
  ;; unsubscribe this function from the enter-command event
  ;;    so that the output box doesn't get hidden EVERY time a
  ;;    a command finishes -- there may be useful information there!
  (oli:sd-unsubscribe-event oli:*SD-ENTER-COMMAND-EVENT* 'my-clear-hide)
  ;; now clear the display box and close it
  (display :clear-hide)
  )

;; now subscribe the above function to the enter command event
(oli:sd-subscribe-event oli:*SD-ENTER-COMMAND-EVENT* 'my-clear-hide)
This is also untested, but I believe it should work...

By the way, if you're writing code using your own lisp package, if you have the line (use-package :oli) at the top of your file, you don't need to put the "oli:" in front of your function and variable references. With what we're doing here, we need to reference the oli: package because the sd_customize file is executed using the default lisp package...

Merry Christmas one and all!

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!
Reply With Quote
  #11  
Old 12-25-2009, 03:02 AM
wathavy's Avatar
wathavy wathavy is offline
Registered User
 
Join Date: Jul 2007
Location: Japan Nagano
Posts: 537
Re: Automate loading command reference?

Merry Christmas!

Hi, thanks for your last response.
But it seems it does not erase the dialog box, yet.

How about changing the approach to time lag command launch?
Is there any way I can time bomb the command after certain time is elapsed?

If it does, all I need to do is to shorten the time so it won't let user to see the dialog.

Any idea...?

Perhaps, next year....
__________________
Toshi
Reply With Quote
  #12  
Old 12-25-2009, 03:28 AM
wathavy's Avatar
wathavy wathavy is offline
Registered User
 
Join Date: Jul 2007
Location: Japan Nagano
Posts: 537
Re: Automate loading command reference?

One more thing which destroy my time bomb idea...
I put (display :clear-hide) in am_customized with which I hoped to erase the output dialog.
But it was in vain.

It seems that your code also is working fine, but writing this (display :clear-hide) in any where may not be working toward hiding the dialog at all.

Am I not at the right track?

__________________
Toshi
Reply With Quote
  #13  
Old 12-28-2009, 12:00 AM
ChrisE's Avatar
ChrisE ChrisE is offline
OneSpace Member
 
Join Date: Oct 2002
Location: Grünstadt, Pfalz, Germany
Posts: 121
Re: Automate loading command reference?

Hi there,

a different, though probably *unsupported* approach could be to directly insert the action command into the toolbox, without a display message:

Code:
(ADD_TOOLBOX_BUTTON :ACTION "online_reference" :LABEL "Online Reference ...")
Please note:
This might not be supported.

Last edited by ChrisE; 12-28-2009 at 05:06 PM. Reason: Solution "might" not be supported (rather than "it is")
Reply With Quote
  #14  
Old 12-28-2009, 12:24 AM
ChrisE's Avatar
ChrisE ChrisE is offline
OneSpace Member
 
Join Date: Oct 2002
Location: Grünstadt, Pfalz, Germany
Posts: 121
Re: Automate loading command reference?

Regarding the event trigger approach by Andy:

In my case,

oli:*SD-ENTER-COMMAND-EVENT*

gets called 10 times, after loading my personal sd_customize !


The online reference display message gets shown after the n-th event, not directly after the first event triggered.

Trying to inquire the status of the display box using e.g.
Code:
(when (oli:sd-dialog-shell-visible-p "OUTPUT-BOX") 
   (oli:sd-unsubscribe-event oli:*SD-ENTER-COMMAND-EVENT* 'my-clear-hide)
	(display :clear-hide)
)
didn't seem to help. But I haven't investigated further into deep
Reply With Quote
  #15  
Old 12-28-2009, 01:15 PM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Automate loading command reference?

Quote:
Originally Posted by ChrisE View Post
Regarding the event trigger approach by Andy:

In my case,

oli:*SD-ENTER-COMMAND-EVENT*

gets called 10 times, after loading my personal sd_customize !


The online reference display message gets shown after the n-th event, not directly after the first event triggered.

Trying to inquire the status of the display box using e.g.
Code:
(when (oli:sd-dialog-shell-visible-p "OUTPUT-BOX") 
   (oli:sd-unsubscribe-event oli:*SD-ENTER-COMMAND-EVENT* 'my-clear-hide)
    (display :clear-hide)
)
didn't seem to help. But I haven't investigated further into deep
I found the same thing -- somehow loading the online reference doesn't happen (or at least doesn't insert anything into the output box) until after everything else happens...

In fact, I put the call to load the online reference as the first thing in my sd_customize file, then loaded a bunch of other things (some of which added output to the display box). Sure enough, the online reference was the very last thing done, even though it was called first...

So this is indeed a very curious situation...

At this point, I think Chris' solution just to add the button directly to the toolbox is your best bet, and shouldn't create any problems... (though I thought that "add_toolbox_button" was a supported function, even though I didn't see it in a quick glance through the help files...)
__________________
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!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 03:49 PM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.