CoCreate User Forum

CoCreate User Forum (https://www.cocreateusers.org/forum/index.php)
-   Customization (https://www.cocreateusers.org/forum/forumdisplay.php?f=12)
-   -   Lisp tool for coloring ALMOST perfect... (https://www.cocreateusers.org/forum/showthread.php?t=6572)

jkramer 12-20-2007 10:15 PM

Lisp tool for coloring ALMOST perfect...
 
Hi,

By using Tools > Customize > New.... I made a simple button in OSD that will give the Active Part a random color each time I click it. Saves some time when doing a quick and dirty modeling job :)
It works great, except for the fact that I have to click in the Viewport before anything happens. So, I press my new button AND click somewhere in the Viewport, and then my Active Part has a new color.
Is there a trick to make the button work without the 2nd click???
Here's the code that's used in the button:

Code:

(ELAN::SET_PART_COLOR (OLI::SD-INQ-CURR-PART) :RGB
    (FRAME2::GPNT3D (LISP::RANDOM 1.0) (LISP::RANDOM 1.0)
        (LISP::RANDOM 1.0))
    :DONE)

Thanks!
Regards,
Jaap

Andy Poulsen 12-21-2007 09:54 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Hi Jaap,

I believe this will do the trick for you:
Code:

(progn
  (ELAN::SET_PART_COLOR (OLI::SD-INQ-CURR-PART) :RGB
    (FRAME2::GPNT3D (LISP::RANDOM 1.0) (LISP::RANDOM 1.0)
        (LISP::RANDOM 1.0))
    :DONE)
  (update_screen))

You just need to tell OSM to update the screen (which clicking in the viewport will also do).

The other thing to note is that when you assign code to a button, it expects a single command, which is why the "progn" statement (along with its closing parenthesis) is needed -- the (progn ...) statement allows your color randomizer and the update_screen call to be passed as a single command to the customization interface. (I know you're aware of what (progn ...) does, but maybe this will help some others who are just getting started!)

I hope this helps!

Merry Christmas and Happy New Year everyone!

andy

jkramer 01-07-2008 12:30 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Hi,

YES!! This is working perfectly :-)
Thanks!
Regards,
Jaap

tom kirkman 01-16-2008 08:00 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Jaap

Out of curiosity, what is Elan: used for? What does it mean.


Thanks

Tom

clausb 01-16-2008 10:22 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Quote:

Originally Posted by tom kirkman (Post 19010)
Jaap
Out of curiosity, what is Elan: used for? What does it mean.

These are package specifications, the Lisp equivalent to "namespaces" in other programming languages. And package names such as "ELAN" or "FRAME2", as in the example above, mean that undocumented and unsupported functionality is used, which I'd definitely recommend to stay away from.

Claus

Wolfgang 01-16-2008 10:25 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Quote:

Originally Posted by tom kirkman (Post 19010)
Out of curiosity, what is Elan: used for? What does it mean.

It is a lisp package. Same as OLI or LISP or my-package. But in most of the cases the package specification is not needed, because the functions are exported.

so:
PHP Code:

(in-package :my-tools)
(use-
package :oli)
(
progn
  
(SET_PART_COLOR (SD-INQ-CURR-PART) :RGB
    
(GPNT3D (RANDOM 1.0) (RANDOM 1.0) (RANDOM 1.0)) :DONE)
  (
update_screen)) 

would be the same. But then you need a lisp file.. or so. But jaap put it into a new available command, created interactively. Then all the lisp-packages are added explicit.

tom kirkman 01-16-2008 10:35 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Thanks

This clears up several other lisp programs I had questions with.

Tom

jkramer 01-16-2008 11:04 PM

Re: Lisp tool for coloring ALMOST perfect...
 
Hi,

thanks Wolfgang, now I understand it myself ;)
It was recorded in the Tools > Customize menu, indeed, because I knew from earlier experiments that some of the package specifications seem to be necessary.
Kind regards,
Jaap

Wolfgang 03-04-2008 11:46 AM

Re: Lisp tool for coloring ALMOST perfect...
 
To colorize all parts within an assembly, or a selected set of parts, by using a random color (or one set) there an old and a new tool available at http://osd.cad.de/index.en.htm

Have a look to

jkramer 03-05-2008 03:48 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Hi,

that's a nice tool! We use a tool that's very similar, but your tool has more options.
Thanks for the hint!
Kind regards,
Jaap

Kaji 11-26-2020 02:05 PM

Re: Lisp tool for coloring ALMOST perfect...
 
1 Attachment(s)
I need a lisp for giving the same color to all parts of an assembly; I think it's easy to edit this lisp, but I don't know how to do.

Thanks for the answers and the help

Attachment 2014

jkramer 11-26-2020 11:22 PM

Re: Lisp tool for coloring ALMOST perfect...
 
Hi,

on osd.cad.de there's another tool:
http://osd.cad.de/downloads/sd_teileumfaerben.lsp
That does the trick.
Beware that a color can be either an instance color or base color (instances color), where instance color overrules base color. This can be confusing...
The reason behind it is that you may have a part that is normally green, but in some cases it will be painted red. In that case the base color should be green, and you can give the red part an instance color red. This color will actually be saved in the parent assembly, whereas the bas color is saved with the part itself.

Kaji 11-27-2020 10:29 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Thanks a lot.
I don't speak German and I believed that all the english pages were no longer supported by PROMT.One, so I didn't get there were the lisp I was looking for.

The only flaw is that the lisp doesn't work when it find a locked part, even if I chose istance and no group is locked.

Wolfgang 11-27-2020 10:56 AM

Re: Lisp tool for coloring ALMOST perfect...
 
Quote:

Originally Posted by Kaji (Post 26239)
I don't speak German and I believed that all the english pages were no longer supported by PROMT.One

I did not find the tool in the english pages Jaap (jkramer) found so quickly .. but, over all . may be http://osd.cad.de/index.en.htm is an entry page for you, Kaji?


All times are GMT -8. The time now is 05:56 PM.

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