PDA

View Full Version : Lisp Code - content ID = part name


MikeBoswell
09-11-2003, 05:05 AM
I am trying to make a dialog that will facilitate making the Contents ID the same as the part name.

The below code works, but needs refinement.

Would someone help me w/:

How do I execute the "(sd-call-cmds (change_pa_id a-part new-name)" w/ my 'Next' button and keep the dialog up?

I have never written LISP before, so any other suggestions are welcomed.

Thanks,

(in-package :vicor)
(use-package :OLI)


(sd-defdialog 'Change_CID
:variables
'((A-PART :title "Part"
:value-type :part-incl-new
:after-input (setq new-name (sd-inq-obj-basename a-part)))
(NEW-NAME :title "New CID"
:value-type :string
:initial-value (sd-inq-obj-basename a-part))
(NEXT :toggle-type :grouped-toggle
:title "Next"
:push-action (display "do IT again")))

:ok-action
'(sd-call-cmds (change_pa_id a-part new-name)))

Wolfgang
09-19-2003, 04:02 AM
Hi, I put the main action into a local function, which is called when pressing NEXT and OK. I only *wrote* it. It's not tested!

MikeBoswell
09-19-2003, 04:43 AM
:)

Thanks Wolfgang!

This works great.

Anyone interested in making this thing loop thru all of the parts in an assembly????


MikeB
VIcor corp
Andover, MA
USA

MikeBoswell
09-22-2003, 05:43 AM
I have modified it further and made it do a list of renames from a selection recursively top down.

I stole 90% of the code from this forum.

The problem w/ it now is it won't handle a list of 1. I cannot select a single part.

Also, no error checking.

Anyone????

Wolfgang
09-23-2003, 01:18 PM
Hi Mike,

use:

:value-type :part-incl-new
:multiple-items t

and then a dolist as you did.

use the normal UI for selection then..
instead of first select an assembly and then doing a second selection of the parts itself.

If you have selected a single part your (get_selection ... :in_assembly a-part) is empty.. therefore nothing happens.

Wolfgang
09-23-2003, 01:22 PM
(some-parts
:value-type :part
:multiple-items t
:modifies :contents
..
)

would help to avoid select read-only parts

MikeBoswell
09-24-2003, 06:13 AM
Wolfgang,

Thanks for looking at this again !

When I try to implement your suggestions I get an error when I OK the dialog.

"input contains element of wront type"

I get this erro w/ a single part or a list.

Prior to these last changes the script would allow me to select an assy (push the dialog part button and double click the assy in the struct browser) and it would put the parts of the assy into a list and modify each.

The proplem there was I could not only select a single part or select a list of parts, it needed to be an assy.

I would like to be able to pick an assy or make a list of parts or pick 1 part.

Is that possible? Is that what you have suggested? Am I confused? probably yes to all of these.

Thanks,

Mikeb

John van Doorn
10-08-2003, 10:26 AM
Hi,

I've changed it again, it now allows you to select an assembly or a single part.
Also when a part is read-only it is being skipped.

Goodluck with it

John van Doorn
10-08-2003, 10:33 AM
Hi,

When uploading the my first change to your lisp file. I start reading what you wrote. I should have done that first :-)

So, I forgot to build in that you would like to select multiple assemblies and/or parts. So the attached lisp file is now taking care of this.

Goodluck again.

John

MikeBoswell
10-09-2003, 04:33 AM
Thanks John,

I'll give it a try.

MikeBoswell
10-09-2003, 05:38 AM
YUP thats it.

Thanks Wolfgang / John.

That was a lot of help.

Mike Boswell
Vicor Corp
Andover MA

ps
John do you remember doing some consult here?
~4 yrs ago, BIG snow storm?

John van Doorn
10-09-2003, 05:55 AM
Hi Mike,

How could I forget?
No power for more than a day, dark cold and candles in the Hotel.

This was one of the trips a tell about at parties ;-)

Any way, I hope the lisp file is of any use for you and if you need more help just drop me an email.


Cheers,
John