Author Topic: HELP WITH A PROGRAM FOR CAD..PLEASE.  (Read 21914 times)

0 Members and 1 Guest are viewing this topic.

AVCAD

  • Guest
HELP WITH A PROGRAM FOR CAD..PLEASE.
« on: December 03, 2004, 12:56:53 PM »
Ok..got a good one here.

I have only done Lisp before but I want to create a program within Autocad that will insert blocks..based on given user input.

It will consist of Drop down menus (with selections), and User input text.

now I know it will be harder then it sounds, cause the blocks I am refering to are for Equipment Rack design.

SO there will be a User input on: (DM = Drop down Menu)

Code: [Select]

Rack Height --> Multiple heights (DM)
Caster --------> Yes/No (DM)
Side Panels --> Yes/No (needs to coordinate with the Rack Height) (DM)
Scale ---------> Yes/no (need to coordinare with rack height) (DM)

*********************************************************

Then in a panel below the one above I would like an other section to become avaible...

For the Rack Panels...

Basically just

Code: [Select]

Rack Panels (from bottom to top)

Panel 1 ---->user text input       Panel Height ---->Multiple selections (DM)


Need Multiple of these depending on what Height is selected a differant amount will be available.

Now the the thing with the Panels are that some may be 1,2,3,4 panels in height. I already have blocks for all these but in a program it will need to know that if......

Panel 1 is 4 units high it will need to gray out panels 2,3,4 and panel 5 will be the next one availble.

I would also like an

OK Cancle and a Reset button

I am more than happy to create this but I will need help...and lots of it!

Who ever helps me will get credit and will be in the code and a get a copy of  the program...I will probably end up posting it on the site unless the people who help me do not want it to be.

I am a novice at the programming for, lower then that even...I know how to write Lisp and I have written some Drop down menus for cad but that is about it.

A starting point would be great!!

Email me or post in this forum.

Thanks.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #1 on: December 03, 2004, 01:03:47 PM »
So you want one big dialog using DCL?
TheSwamp.org  (serving the CAD community since 2003)

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #2 on: December 03, 2004, 01:12:51 PM »
swapping menus would work too....forces the user to the next page based on his previous input...those work very well...

AVCAD

  • Guest
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #3 on: December 03, 2004, 02:22:01 PM »
Quote from: Mark Thomas
So you want one big dialog using DCL?


I think DCL is correct..that it the codeing where you can use a GUI right...like a popup screen with menus and selections in it.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #4 on: December 03, 2004, 02:39:09 PM »
Ok then, design your dialog in acad or some such showing how you want it laid out. Then we can start creating our dialog based on that.
TheSwamp.org  (serving the CAD community since 2003)

CADaver

  • Guest
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #5 on: December 03, 2004, 02:50:41 PM »
Quote from: Mark Thomas
Ok then, design your dialog in acad or some such showing how you want it laid out. Then we can start creating our dialog based on that.
This is one I want to watch.  I've hammered existing DCL fiules into submission before, but never tackled one from scratch.

AVCAD

  • Guest
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #6 on: December 03, 2004, 03:25:32 PM »
Quote from: Mark Thomas
Ok then, design your dialog in acad or some such showing how you want it laid out. Then we can start creating our dialog based on that.


On IT!!

AVCAD

  • Guest
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #7 on: December 03, 2004, 04:38:25 PM »
ok i hopfully this works....

http://www.theswamp.org/screens/AVCAD/Drawing1-Model.plt.jpg


NUMBER OF PANELS SHOWN SHOULD BE LINKED TO HEIGHT OF RACK IN FIRST SELECTION.
51" RACK IS SELECTED ONLY 25 PANELS ARE AVAILBLE
60" RACK IS SELECTED ONLY 30 PANELS ARE AVAILBLE
68" RACK IS SELECTED ONLY 35 PANELS ARE AVAILBLE
77" RACK IS SELECTED ONLY 40 PANELS ARE AVAILBLE
84" RACK IS SELECTED ONLY 45 PANELS ARE AVAILBLE

HEIGHT OF PANEL SELECTIONS:
1 TO 30
1 TO 9 - 2 WAY SPLIT
1 TO 9 - 3 WAY SPLIT

TEXT INPUT SELECTIONS:
IF PANEL HEIGHT IS = 1 THEN 1 TEXT LINE AVAILBLE
IF PANEL HEIGHT IS = OR > 2 THEN 2 TEXT LINE AVAILBLE
IF PANEL HEIGHT IS = OR > 3 THEN 3 TEXT LINE AVAILBLE
IF PANEL HEIGHT IS = OR > 4 THEN 4 TEXT LINE AVAILBLE

TEXT INPUT SELECTIONS: FOR 2 WAY SPLIT PANELS
IF PANEL HEIGHT IS = 1 THEN 1 TEXT LINE AVAILBLE (LEFT,RIGHT)
IF PANEL HEIGHT IS = OR > 2 THEN 2 TEXT LINE AVAILBLE (LEFT,RIGHT)
IF PANEL HEIGHT IS = OR > 3 THEN 3 TEXT LINE AVAILBLE (LEFT,RIGHT)
IF PANEL HEIGHT IS = OR > 4 THEN 4 TEXT LINE AVAILBLE (LEFT,RIGHT)

TEXT INPUT SELECTIONS: FOR 3 WAY SPLIT PANELS
IF PANEL HEIGHT IS = 1 THEN 1 TEXT LINE AVAILBLE (LEFT,CENTER,RIGHT)
IF PANEL HEIGHT IS = OR > 2 THEN 2 TEXT LINE AVAILBLE (LEFT,CENTER,RIGHT)
IF PANEL HEIGHT IS = OR > 3 THEN 3 TEXT LINE AVAILBLE (LEFT,CENTER,RIGHT)
IF PANEL HEIGHT IS = OR > 4 THEN 4 TEXT LINE AVAILBLE (LEFT,CENTER,RIGHT)

Actual height of 1 panel is 1.75" for each panel >1 just multiply 1.75 by that number.

That may not matter cause I have blocks that are set up to be inserted for each of these heights. These Blocks have Attributes to them for the text. So each user input in the slot would have to be applied to the attribute in the block..unless there is another way.

This might be too much in now but I will be happy to repeat my self later.

I guess right now we need to get the GUI in place.

Thanks for the Help and Sorry for the CAPs it wrote it in ACAD first.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #8 on: December 03, 2004, 05:00:48 PM »
Nice job!! that's a great starting point.
TheSwamp.org  (serving the CAD community since 2003)

AVCAD

  • Guest
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #9 on: December 03, 2004, 05:05:08 PM »
Ok...so what is the next step...I really am new to this.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #10 on: December 03, 2004, 05:14:05 PM »
The next step is writing the DCL code that makes up your dialog. Unfortunately, I'm off for the rest of the night. :D If you want browse throught the example code that comes with acad and checkout afralisp, Kenny has some nice examples and code that deals with dialog boxes.
TheSwamp.org  (serving the CAD community since 2003)

Crank

  • Water Moccasin
  • Posts: 1503
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #11 on: December 04, 2004, 08:51:23 AM »
Quote from: AVCAD
Ok...so what is the next step...I really am new to this.

When I just started making dialogboxes, I used DCG.

It's very easy to use.
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #12 on: December 04, 2004, 10:38:06 AM »
AVCAD,
Because Mark is busy let me ask you a few questions and see if you Could you
upload a drawing with examples of each type of cabinet?
Not all of the possibilities but a 1,2,3 wide & 51" & 84".
Just to get an idea as to what they look like when done.
That would be very helpful so see where you are headed.

AS I looked at your drawing of the Dialog box I had these questions.

Code: [Select]
Rack Height
......... Choices [51 60 68 77 77 84] -> actual height of Rack

Casters
......... Option for casters  [Yes No]

Side Panels
......... Choice of split panels ?  [Yes No]
Is this option available for each if you have 2 or 3 panels?

Scale
.........  Allow user to scale the block [Yes No]
Do you enter a scale or have selections to pick from?

Height of Panel
......... Choices [1 2 3]

Text Input 1 panel
......... Text Label  *Center*  [Text input]  ??Max Length??  Caps Only??

Text Input 2 panel
......... Text Label  *Left*    [Text input]  ??Max Length??  Caps Only??
......... Text Label  *Right*   [Text input]  ??Max Length??  Caps Only??

Text Input 3 panel
......... Text Label  *Left*    [Text input]  ??Max Length??  Caps Only??
......... Text Label  *Center*  [Text input]  ??Max Length??  Caps Only??
......... Text Label  *Right*   [Text input]  ??Max Length??  Caps Only??


If you choose 68" Rack, do you enter 35 choices for Split Panel?
Or if you choose split panels, are they all split?

If you choose 2 panel, are they all 2 panel?

Sorry for the intrusion Mark, I'll get out of the way and follow along.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #13 on: December 04, 2004, 11:20:56 AM »
>Sorry for the intrusion Mark, I'll get out of the way and follow along.
Not a problem CAB, feel free to join in. :D
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
HELP WITH A PROGRAM FOR CAD..PLEASE.
« Reply #14 on: December 06, 2004, 07:59:45 AM »
Since this is going to be a large project let's create a directory just for it, then add that directory to the acad search file path. I called my new dir 'panels' and I stored it under c:\temp.

The first file I made in our new dir is called 'dialog_p.dcl', this will be the file that defines our dialog box, or GUI to the application. I should also mention that I'm working in the vlide to design the dialog, it's makes it very easy to view your dialog as you work on it.

The contents of our .dcl file looks like this;

Code: [Select]

dialog_p : dialog
{
label = "This our label (top of the dialog)";
ok_cancel;
}


let's take a look at it using the built-in viewer in the vlide. If you're in acad type in 'vlisp' or 'vlide', then open 'dialog_p.dcl', and finally, from the the 'tools' menu go to 'interface tools' then 'preview dcl in editor', you should see a dialog asking for a name to view. Ours is called 'dialog_p'. Assuming the code doesn't have any errors in it you should see a simple dialog with a title and two buttons, 'ok' and 'cancel'.

Now let's create the 'rack height' menu part of the dialog.
Code: [Select]

dialog_p : dialog
{
label = "This our label (top of the dialog)";
: popup_list {
             label = "Rack Height:";
             key = "rack_h";          // what the user selected
             value = "0" ;            // initial value
             edit_width = 30;         // fix the width (optional)
             }
ok_cancel;
}


Assuming the dcl code is error free you should see one drop down dialog that's empty. We now need to fill the list with rack heights, to do this we need some autolisp code.

I created a new file and called it popup_rack.lsp.
Code: [Select]

(defun popup_rack (/ rack_h_lst dcl_id hght click)

  ; the list the user sees
  (setq rack_h_lst
    (list
      "51 inch rack"
      "60 inch rack"
      "68 inch rack"
      "77 inch rack"
      "84 inch rack"
      )
    )

  ;;----------------------dcl stuff-----------------------------
  ;load dialog
  (setq dcl_id (load_dialog "dialog_p.dcl"))

  ;test for dialog
  (if (not (new_dialog "dialog_p" dcl_id))
    (exit)
    );if

  (start_list "rack_h") (mapcar 'add_list rack_h_lst) (end_list)

  (action_tile "accept"

               (strcat
                 "(progn
                    (setq hght (get_tile \"rack_h\"))"
                    "(done_dialog) (setq click T)
                    )"
                 );strcat
               );action tile

  (action_tile "cancel"

           "(done_dialog)
           (setq click nil)"  
           );action_tile

  (start_dialog)(unload_dialog dcl_id)

  (if click
      (setq hght (nth (atoi hght) rack_h_lst))
    ; else
    (exit)
    );if userclick

  ;;-------------------dcl stuff--------------------------------
  )


Open this file in the vlide if it's not already, and load it into the current acad session by using the 'tools' menu go to 'load text in editor'. To run the code and test our dialog, from the 'visual lisp console' enter the following.

Code: [Select]

(setq return (popup_rack))


If all goes well you should now see a populated drop down menu. Now make a selection from that menu and click 'ok'. Our variable 'return' should equal the selected menu item. Mine looks like this.

Code: [Select]

(setq return (popup_rack))
"68 inch rack"



Next we'll take a look at the 'popup_rack.lsp' file and explore what it does.







Notes:
Please feel free to participate, correct or comment on any thing you see here.
TheSwamp.org  (serving the CAD community since 2003)