PDA

View Full Version : How to set all faces transpar full?


Harry
02-16-2004, 07:32 AM
I am a noob in LISP, but everyone has to start at the beginning... :)

I like to have a small routine which ask for a part to select. Then all faces of this part must be swapped to transpar full.

I made this:

(in-package :BG-PP)
(use-package :OLI)

(defun bg-get-facelist ( n )
(bg-get-facelist-sel-item (sd-pathname-to-obj n))
)
(defun bg-get-facelist-sel-item ( apart )
(let (
(fl)
)
(setf fl (sd-call-cmds
(get_selection
:focus_type *sd-face-seltype*
:select
:in_part apart)))
fl ;; return value
)
)



(defun bg-clear-faces ( li (defun bg-get-facelist "/p1") )
(let (sel_item)
(dolist (sel_item li)
(progn
(values)
:OPAQUE ;(:SEMI,:FULL)
)
)
)
)


Is this the right way to solve the problem?

After a (load "c:\temp\bg-faces.lsp") and (bg-clear-faces) I got an error:
LISP error: The function BG-CLEAR-FACES is undefined.

Can anyone give me a hint?

Wolfgang
02-16-2004, 12:01 PM
((Welcome-to (* N parentheses)) :kings) ;)


Let's start at the end:

you defined your own lisp-package (quit good!!) and then you wanted to call your function from OSD's command line.

The current package for the cmd-line is the :mei package. Inside this package the function you defined is not 'visible'. But you could call it with

(BG-PP::bg-clear-faces)

... so with preceeding the package name in front of it.

Neverthe less.. as you did it it will not work. :( But one step after the other!

I assume you want to select the part interactivly. When ever you would like to do it that way the only (and highly recommended!) way is using the IKIT function sd-defdialog.

Get familiar with that function. There a several examples liste in the help files. sd-defdialog is *the* tool for writing add on.

You'll get an user interface where you can select your part. You'll find a new entry in your toolbox. Then in the : ok-action (pressing the green 'OK') you can call you (defun... ) to do the 'work'.

Start with some simple 'prints' instead until the dialog is fine.

After you have gone a little bit further, post your current stuff. and we'll continue.

Have fun! :)

Harry
02-18-2004, 07:41 AM
Thanks for the tips concerning progamming in LISP for SD.
I studied he pointed docs and made the following code:


(in-package :BETA-PP)
(use-package :OLI)


(defun bg-get-facelist ( n )
(bg-get-facelist-sel-item (sd-pathname-to-obj n))
)

(defun bg-get-facelist-sel-item ( apart )
(let (
(facelist)
)
(setf face (sd-call-cmds
(get_selection
:focus_type *sd-face-seltype*
:select
:in_part apart)))
facelist ;; rc
)
)


(defun bg-clear-faces ( facelist )
(let (sel_item)
(dolist (sel_item facelist)
(progn
(values)
:OPAQUE ;(:SEMI,:FULL)
)
)
)
)


(sd-defdialog 'clear_all_faces_dialog
:dialog-title "Clear_All_Faces"
:variables
'(
(VALID_PART
:value-type :part
:title "Part"
:initial-value nil)
)
:ok-action
'(bg-clear-faces
(bg-get-facelist (sd-inq-obj-basename VALID_PART))
)
)


No errormessage? Huray! :)
Does it work? NO :(
Is there a way I can see if the program scans all faces of the part?
I think that problems lays there...

dorothea
02-18-2004, 08:34 AM
Hi Harry,

Just from locking into the code I see a problem in function bg-get-facelist-sel-item

You declare a local variable facelist but assign the result of the selection to variable face. And at the end you return facelist again. This cannot work.

Dorothea

Wolfgang
02-19-2004, 12:53 PM
Dorothea pointed you to one thing.

Here are 2 other:

in bg-get-facelist you are calling a function which want to get a string.. and it receives a string.. but why do you first generate a string???
The dialog DISPLAY only the name of the part, but internally it's still a sel-item.
In bg-clear-faces there is written
(dolist (sel-item facelist)
the name of the loop variable is 'sel-item'. Don't do it. Choose another name. Just to make reading simpler and to avoid conflicts with the sel-item which is a often used name inside OSD lisp. (e.g. -> A-item / a-face)


One more tip:
next time you post your script you might use an attachment. That's better to read (after download) and the indentation is kept.

I also fixed the thing Dorothea pointed you to.

And last tip for today:
use the (trace fname) / (untrace fname) to see what your function is doing (in console). You can do it in OSD-cmd-line or directly in your lisp code (as you can see in attached file)

That's for now.. it's still not working (as I attached it for you). But it's near by.. ;-))

Harry
03-09-2004, 08:30 AM
I studied your code and made this out of it! :) (see attachment)
How do you think of it?

Wolfgang
03-09-2004, 02:01 PM
well well... continue..

(not( equal UI_TRANS_OPAQUE nil)
this is the same
UI_TRANS_OPAQUE
everything what is NOT nil is T.


the way you get the numerical value for transparency is a little bit funny..

In fact you have *ONE* condition statement with *3 different conditions*. What you wrote are 3 cond's with one condition each.

;; get trans value
(cond
(UI_TRANS_OPAQUE
(setf trans_fac 0) )
(UI_TRANS_SEMI
(setf trans_fac 0.5) )
(UI_TRANS_FULL
(setf trans_fac 1) )
) ;; end cond
So.... one more little step forward.. ;)

Another possibility would be to have ONE range variable with 3 possibilities (having a numercial value and a 'speaking' label each). This might be next exercise...

Wolfgang