Author Topic: openDCL list box  (Read 5711 times)

0 Members and 1 Guest are viewing this topic.

Ricky S

  • Newt
  • Posts: 24
openDCL list box
« on: September 02, 2010, 04:05:05 PM »
I have a menu/lisp routine that I would like to combine into an openDCL project.  I currently use a custom menu to display a list of materials, when a material is selected it sets a variable "wgt" then calls my lisp routine like this:(setq wgt 4.90) ^C^C_WGT.  This is my first attempt at openDCL & I'm struggling with how to set my variable, then call my lisp routine.  Any help would be greatly appreciated

BazzaCAD

  • Guest
Re: openDCL list box
« Reply #1 on: September 02, 2010, 04:36:43 PM »
Hmmmm, have you gone through the “Beginners Tutorial” here: http://opendcl.com/wordpress/?page_id=10 ?

You'll need a LSP file to load & show your ODCL project.
Then you'll need to turn on the "SelChanged" Event on the List Boxes.

Then you can do something like this:

(defun c:WGTCALCULATOR_Form1_ListBox1_OnSelChanged (ItemIndexOrCount Value /)
  (setq ALUMINUM Value)
)

But I'm really not sure what you're trying to do.....

Ricky S

  • Newt
  • Posts: 24
Re: openDCL list box
« Reply #2 on: September 02, 2010, 05:10:58 PM »
Barry,
It's an honor to talk with you...yes I have read your tutorial (although I obviously didn't "get" all of it) and I have created the "Hello World" project.
I started a lisp file that opens the wgtcalculator, but that's as far as I can get without some errors.  My desire is to pick a material (name in the listbox), have that set a value for the weight per foot then pass that to my wgt.lsp (which allows me to select a line for the length and multiplies that length by the weight per foot).  I plan on adding the code from my wgt.lsp file to the wgtcalculator.lsp file as the main routine, as it is "working code".  I think where I'm missing it is setting the values for the listbox items.  Is the value (weight per foot in my scenario) stored in the "item data" and if so how do I retrieve it?

It's been a few years since I wrote any lisp code, and this is my first attempt at opendcl project outside the tutorial.  I thought it would be easy to take some "old code" and spruce it up with a slick new interface...I now think I've bitten off a little more than I can chew!  Your help is greatly appreciated.

BazzaCAD

  • Guest
Re: openDCL list box
« Reply #3 on: September 02, 2010, 05:58:38 PM »
thx, but I wouldn't say it's an honor... I'm just an average Joe, I would even call myself an expert lisp'er... :)

First off, I wouldn't hard-code the shapes into the list boxes. It's a lot harder to edit or add new shapes in the studio then in Lisp.
I'd do something like this....

Create a global list with all your shapes & weights...
Populate the list box on the forms Initialization.
Pull the weight out of the global list when a selection in the list box is changed...

Code: [Select]
(setq AluList
  (list
    (cons "L 1\" x 1\" x 1/16\" (OAX-600)" 4.90)
    (cons "L 2\" x 1\" x 1/16\" (OAX-601)" 5.10)
    (cons "L 1.1/2\" x 1.1/2\" x 3/16"  6.30)
    ;;.... ETC ........
  )
)

(defun c:WGTCALCULATOR_Form1_OnInitialize (/)
  (foreach thing AluList
    (dcl_ListBox_AddString WGTCALCULATOR_Form1_ListBox1 (car thing))
  )
)

(defun c:WGTCALCULATOR_Form1_ListBox1_OnSelChanged (ItemIndexOrCount Value /)
  (setq wgt (cdr (nth ItemIndexOrCount AluList)))
)


This is just a rough idea, I didn't test any of it...
I hope this helps you get started.

Ricky S

  • Newt
  • Posts: 24
Re: openDCL list box
« Reply #4 on: September 02, 2010, 09:03:20 PM »
 :-o Wow that's not what I was thinking, but I like the thought of keeping the list in my lisp file. Thanks for pointing me in this direction, I'll be back when I've had some time to play with the code.