Jump to content

Help With DCL?


BLOACH85

Recommended Posts

Hey guys,

:? ok so here is my new project Im not super familiar with dcl but im trying it anyways. I have this lisp routine it is only informational but here is my thing, The information i want posted in a dialog box but in feet and inches instead of decimal form any ideas? I kinda wrote a dcl and i will post both the lisp and dcl. If any ideas of what my problems are then please help. feel free to cus at the creator if it doesnt work!! This is strictly to make my and others life easier while at work (if your a misc structual detailer)..

 

Here is the pickets lisp.

 

(defun c:picket (/ aa ab ac ad ae af ag dst1 pip1 bar1 dst2 num1 d num2 spa1 y y1 y2 y3 y4 spa2 dst3 endb endr1 endr2)
 ((setq dst1 (getdist "\nEnter Post to Post spacing : <>"))       ;DIMENSION FROM POST TO POST
 (setq pip1 (getdist "\nEnter Pipe Size in inches : <1.66>"))     ;DIAMETER OF POST (DEFAULT 1.66)
 (setq bar1 (getdist "\nEnter thickness of pickets : <0.5>"))     ;PICKET SIZE (DEFAULT 0.5)
 (setq dst2 (+ (- dst1 pip1) bar1))  ;dst2 is the spacing of pickets less the pipe post
 (setq num1 (/ dst2 4))   ;num1 is the number of picket spaces @ exactly 4"
 (setq d (fix (+ num1 0.99)))      ;d is the number of spaces needed to round up
 (setq num2 (- d 2))    ;num2 is the number of spacing for the middle of the rail
 (setq spa1 (/ dst2 d))
 (setq y (+ spa1 0.03125))
 (setq y1 (* y 32))
 (setq y2 (- y1 (rem y1 1)))
 (setq y3 (/ y2 2))
 (setq y4 (- y3 (rem y3 1)))
 (setq spa2 (/ y4 16))    ;spa2 is the picket space in the middle in 16ths.
 (setq dst3 (* spa2 num2))   ;dst3 is the middle dimension.
                                       ;This is the number of spaces times the picket
     ;spacing for the middle section.
 (setq endb (- dst1 dst3)) 
 (setq endr1 (/ (* endb 16) 2))
 (setq endr2 (- endr1 (rem endr1 1)))
 (setq endr (/ endr2 16))
 (setq endl (- endb endr))   ;endl is the left end dimension minus
     ;the right end dimension.
)  ;    INPUT
    ; Post to Post spacing  =  dst1
    ; Pipe size = pip1
    ; Picket size = bar1
    ;
    ;     OUTPUT
    ;Left space = endl
    ;Right space = endr
    ;Number of middle spaces = d
    ;Dimension of middle space spaces = spa2
    ;Dimension of middle space total = dst3
    
 (princ)
) 
 
 
 

 

ok so here is my dcl (if you would call it that)

 

PICKETS : dialog {
label = "The Picket Spacing Machine!" ;
: row {
:boxed_column {
label = "ENTER DIMENSIONS EXACTLY";
:edit_box {
key="X";
label="What is your Dimension from Center to Center of Post?" ;
value=dst1;
edit_width=14;
alignment=centered;
}
:edit_box {
key="y" ;
label = "What is your Post Diameter";
value=pip1;
edit_width=14;
}                    
:edit_box {
key="z" ;
label = "What is your Picket size";
value=bar1;
edit_width=14;
}
:row {
:column {
width=10;
alignment=centered;
label="End Space 1";
:edit_box {
edit_width=6;
key="end1" ;
value=endr1;
}
}

:column {
width=3;}
:column {
width=10;
label="# of Spaces";
:edit_box {
edit_width=6;
key="sp";
value=num2;
}
}
:row {
:column{
width=15;
:text {key="tt" ; value="SPACES @";
alignment=centered;}}
}
:column {
width=10;
label="Space Size";
:edit_box {
edit_width=6;
key="sp2";
value=spa2;
}
}

:column {
width=3;}

:column {
width=10;
alignment=centered;
label="End Space 2";
:edit_box {
key="end2" ;
edit_width=6;
value=endr1
}
}
}
:row {
:boxed_column {
label="Written by Joe Barrett and Brandon DeLoach     <2009>" ;}
}
}
}
ok_cancel ;
}

 

Any help or guidance would be appreciated:?

Link to comment
Share on other sites

Please correct me if I’m wrong.

You want to start the program

Have the dialog box appear

Have the user fill out the 3 questions

And show the results in the 4 boxes at the bottom of the dialog box.

Link to comment
Share on other sites

First you have an error in the dcl file on line 74: value = endr1

This needs to have a semicolon at the end: value = endr1;

When writing a program that requires a dialog box you should write an in/out file to act as a go between the lisp file(s) and the dcl file.

The in/out file can set the values of the tiles in the dcl then return the results to the lisp for processing.

Here is what I think you should do.

Instead of having the user answer questions on the command line, have the dialog box appear and the user fills in the questions there. Then instead of an ok_cancel use 2 buttons 1 for calculate and then one for cancel.

When the user fills out the 3 questions they hit the calculate button and the 3 answers are sent to the lisp file for processing then returned to the dialog box for display. This will be done using a loop in the in/out file

This will require you to edit the original lisp file, dcl file and create an in/out file

But the outcome will be cool.

If you are interested in learning how to do this I’ll be happy to walk you through the process step by step. I would write it myself but you would not learn anything.

Link to comment
Share on other sites

I would really appreciate you helping me do this. so the in/out file just acts as a transfer between the two....ok so how is it formatted?:?

and where do we start lsp, dcl, in/out

Link to comment
Share on other sites

First lets start by cleaning and setting up your lsp and dcl files.

In your dcl file there was an error on line 74. in my previous post I pointed this out

Correct it

In the dcl file comment out all value lines with the 2 forward slashes // before the word value. We will be using the in/out file to set these values later.

 

Where you have the ok_cancel you need to create 2 buttons with code like this

: row { // defines the OK/Cancel button row

: spacer { width = 20; }

: button { // defines the OK or calculate button

label = "Calculate";

is_default = true;

key = "accept";

width = 8;

fixed_width = true;

}

: button { // defines the Cancel button

label = "Cancel";

is_cancel = true;

key = "cancel";

width = 8;

fixed_width = true; }

 

: spacer { width = 20;}

}

 

Once you have this done check out the dialog box to make sure everything is where it should to be.

Do you know how to use the visp environment to look at dialog boxes?

If not let me know and I’ll show you.

 

Now we clean up your lisp:

 

Do you know how to pass arguments to another defun?

Do you know how to return variable from a defun?

 

When you write a lisp file you start with (defun c:XXX ( / var1 var2 …….)

The C: is used to tell autocad that this is called from the command line, so if you type XXX on the command line the program in started.

 

After the c:xxx you have the declarations parentheses ( / var1 var2 …….). this is where you accept arguments to be used in the program and also where you declare all the variables you use in the program so they will be set to nil when the program is finished.

Anything to the left of the forward slash / is an argument being passed to the program and everything to the right of / is the variables in the program.

Typical if a program is using arguments passed to it the C: is omitted like this:

(defun XXX (aug1 aug2 / var1 var2 …..)

 

Say you have a program C:YYY that ask the user for 2 points

 

And you use the variables pt1 and pt2 to get the points using the getpoint function

 

Then you have another program (defun XXX (aug1 aug2 / var1 var2 ….) that will accept 2 arguments them process them to get the distance from point to point.

 

Inside the c:yy program after collecting the points you would make a call to the XXX program passing it the 2 points and have it return the processed value like this:

 

(setq ret (XXX pt1 pt2) this call the xxx program and passes the 2 values of pt1 and pt2 to it and are held in the XXX program by the aug1 and aug2 arguments.

So the xxx program would process it like this

(setq dist (distance aug1 aug2)

 

Just a quick crash course in passing variables. It can get a lot more complicated but lets just stick to the basics for now.

 

Ok, now on to cleaning up yout lisp file.

In your lisp file we need to comment out the 3 questions using the ; before the question

We will be passing these values back to the lisp file via the in/out file later

Also get rid if the first open parentheses on the first question

((setq dst1 (getdist "\nEnter Post to Post spacing : "))

and get rid of the closing parentheses where it says input.

 

Next set the defun up to accept arguments by getting rid of the C: and adding 3 arguments. Instead of using aug1 aug2 aug3 lets name the arguments dist1 pip1 bar1

(defun pickens (dist1 pip1 bar1 / your variable stay the same here)

Where you have the variable after the / delete dist1 pip1 bar1 because these are now arguments wan will be nill after the program finishes.

 

Time for you to ask questions then we’ll move on to the in/out file and bring everything together.

 

 

 

 

 

 

Link to comment
Share on other sites

ok so now dcl and lisp are cleaned up now we assign a cond? to the lisp? which will allow the in/out to switch to the dcl and allow the user to enter input and swap back to the lisp to perform calculations according to the users input?

Link to comment
Share on other sites

I threw this together & did not check the accuracy but it does show you how to get the DCL going.

 

Perhaps John will walk you through it. Hope I didn't step on your toes John.:)

 

Save as Pickets.dcl & must be in the ACAD search path.

PICKETS : dialog { label = "The Picket Spacing Machine!"; initial_focus = "c2c";
:boxed_column { label = "ENTER DIMENSIONS EXACTLY";
  :edit_box { key = "c2c"; edit_width = 14 ; 
     label="What is your Dimension from Center to Center of Post?" ;}
  :edit_box { key = "pdia"; edit_width = 14;
     label = "What is your Post Diameter"; }                    
  :edit_box { key = "psize"; edit_width = 14;
     label = "What is your Picket size"; }
}   
:row {
  :column { width=8; alignment=centered; label="End Space 1";
    :text {key="end1"; width=6; value="XXXXXX"; alignment=centered;}
     }
  :column { width=8; label="# of Spaces"; 
    :text {key="sp"; width=6; value="XXXXXX"; alignment=centered;}
  }
  :column { width=8; label="Space Size";
    :text { key="sp2"; width=6; value="XXXXXX"; alignment=centered;}
  }
  :column {width=8; label="End Space 2";
    :text { key="end2"; width=6; value="XXXXXX"; alignment=centered;}
  }
}
:boxed_row { label="STATUS";
  :text {key= "msg"; value="Status message";}
}
:text{key="xxx";  label="Written by Joe Barrett and Brandon DeLoach     <2009>  & CAB :)" ;}
: ok_button { is_cancel = true; }
}

 

Lisp file, warts & all. No attempt to localize vars at this time.

(defun c:pickets (/ aa ab ac ad ae af ag cen2cen PostDia PickSize dst2 num1 d num2 spa1 y y1 y2 y3 y4
                spa2 dst3 endb endr1 endr2
               )


 ;; convert to a number & return (number & type)
 (defun GetNum (numstr / num typ)
   ;;  Returns a list of (<type of number> <number>) or nil
   ;;  must be tested in this order (4 2 1 5 3)
   ;;  if you use (1 2 3 4 5) you will not get any 2 4 or 5 results
   ;;  further test result in inconsistancies with 3&4 and 5 types
   ;;  Note that if the system units are set to Arch then Arch entries will return
   ;;  as type 2 numbers, else they will be type 4 numbers
   ;;  so I put type 4 ahead of type 2
   (cond ((setq num (distof numstr 2)) (setq typ 2))
         ((setq num (distof numstr 4)) (setq typ 4))
         ((setq num (distof numstr 1)) (setq typ 1))
         ((setq num (distof numstr 5)) (setq typ 5))
         ((setq num (distof numstr 3)) (setq typ 3))
   )
   (list typ num)
 )

 (defun GetTiles ()
   (and
     (setq cen2cen (cadr (GetNum (get_tile "c2c")))) ; DIMENSION FROM POST TO POST
     (setq PostDia (cadr (GetNum (get_tile "pdia")))) ; DIAMETER OF POST
     (setq PickSize (cadr (GetNum (get_tile "psize")))) ; PICKET SIZE
   )
 )


 ;;  calc & update
 (defun calc ()
   (if (and (GetTiles) cen2cen PostDia PickSize)
     (progn

       ;;(setq cen2cen (getdist "\nEnter Post to Post spacing : <>")) ;DIMENSION FROM POST TO POST
       ;;(setq PostDia (getdist "\nEnter Pipe Size in inches : <1.66>")) ;DIAMETER OF POST (DEFAULT 1.66)
       ;;(setq PickSize (getdist "\nEnter thickness of pickets : <0.5>")) ;PICKET SIZE (DEFAULT 0.5)
       (setq dst2 (+ (- cen2cen PostDia) PickSize))
         ;dst2 is the spacing of pickets less the pipe post
       (setq num1 (/ dst2 4)) ;num1 is the number of picket spaces @ exactly 4"
       (setq d (fix (+ num1 0.99))) ;d is the number of spaces needed to round up
       (setq num2 (- d 2)) ;num2 is the number of spacing for the middle of the rail
       (setq spa1 (/ dst2 d))
       (setq y (+ spa1 0.03125))
       (setq y1 (* y 32))
       (setq y2 (- y1 (rem y1 1)))
       (setq y3 (/ y2 2))
       (setq y4 (- y3 (rem y3 1)))
       (setq spa2 (/ y4 16)) ;spa2 is the picket space in the middle in 16ths.
       (setq dst3 (* spa2 num2)) ;dst3 is the middle dimension.
       ;;This is the number of spaces times the picket
       ;;spacing for the middle section.
       (setq endb (- cen2cen dst3))
       (setq endr1 (/ (* endb 16) 2))
       (setq endr2 (- endr1 (rem endr1 1)))
       (setq endr (/ endr2 16))
       (setq endl (- endb endr)) ;endl is the left end dimension minus
       ;;the right end dimension.
       ;;    INPUT
       ;; Post to Post spacing  =  cen2cen
       ;; Pipe size = PostDia
       ;; Picket size = PickSize
       ;;
       ;;     OUTPUT
       ;;Left space = endl
       ;;Right space = endr
       ;;Number of middle spaces = d
       ;;Dimension of middle space spaces = spa2
       ;;Dimension of middle space total = dst3

       ;;  Update the dialog box
       (set_tile "msg" "Data evaluation complete.")
       (set_tile "end1" (rtos endl 4 )
       (set_tile "end2" (rtos endr 4 )
       (set_tile "sp" (rtos d 2 0)) ; # of Spaces
       (set_tile "sp2" (rtos spa2 4 ) ; Space Size
     )
     (set_tile "msg" "Incomplete input or bad number.")
   )
 )

 (defun doit (dn)
   ;;  set actions to do when exiting these tiles
   (action_tile "c2c" "(calc)")
   (action_tile "pdia" "(calc)")
   (action_tile "psize" "(calc)")
   ;;  default values for these tiles
   (set_tile "pdia" "1.66")
   (set_tile "psize" "0.5")

   (start_dialog)
   (unload_dialog dn)
 )



 ;;--------------------------
 ;;  S T A R T   H E R E     
 ;;--------------------------

 (setq dclfile "Pickets.dcl"
       dclName "PICKETS"
 )
 (cond
   ;;((not (tm_create_dcl dclName)) (prompt (strcat "\nCannot create " dclfile ".")))
   ((< (setq dcl# (load_dialog dclfile)) 0)
    (prompt (strcat "\nCannot load " dclfile "."))
   )
   ((not (new_dialog dclName dcl#)) (prompt (strcat "\nProblem with " dclfile ".")))
   ((doit dcl#)) ; No DCL problems: fire it up
 )       ; end cond

 (princ)
)

Link to comment
Share on other sites

Next lets determine what we need to pass back to the in/out file from the lisp file

When the user clicks the calculate button we will pass the 3 values to the lisp file and have it return the answers.

The in/out file will have a loop in it so when the user clicks the calculate button it will loop. This also means we need to repopulate all tiles in the dcl file.

So your lisp needs to return the 3 original values of the questions plus the 4 calculated answers.

What are the 4 variables in your lisp file that are the answers?

In your original dcl file you assigned values and had the variables endr1 num2 spa end1 assigned. Is this correct? You had endr1 for the first and last values.

In your lisp file write a line at the end of the file

(setq ret (list dist1 pip1 bar1 endr1 num2 spa end1)) this will pass the list back to the in/out file and then we will parse the list and assign the values accordingly

Also get rid of the (princ) at the end of the lisp file.

If you want a program to return a value or list it needs to be the last thing in the file.

This is done one of two ways:

Either have the last line of the file be (setq ret (list dist1 pip1 bar1 endr1 num2 spa end1)) then you will have the closing parentheses of the defun )

Or use the setq ret above in the code the at the end of the file just write the variable

Ret

);_defun

Ok while you are digesting this I will get a in/out file ready to explain in my next post

Link to comment
Share on other sites

no problem. steppin on toes are allowed when learning

 

The basic in/out file:

 

Hopefully you are organized enough to have you lisp, dcl and in/out files saved in it own folder. If not make one for it. In the testing phase make sure you have the path to this folder mapped in auto cads support file search path.

Later we will create a project in the lisp environment then make a vlx file for easy use and distribution.

 

An in/out file is just another lisp file. It better to keep it separate for ease of correcting and to steal for other projects.

 

First lets look at on of my in/out files and see how it works. Just the in/out file is displayed for dissection.

It is called by another file and it calls the dcl file then returns values to the original file that called it.

 

The name of the file is qdx_io

The defun is qdx:DialogInput

The dcl file is called qdx.dcl

The dialog box name is qdx_maindlg

 

The program that calls this file does so like this

(setq retval (qdx:DialogInput)) this call the file that opens the dcl and returns the values back to retval.

 

At the top of the file there is a lot of error checking going on to minimize crashes

As you look through the file you can see where the what_next loop starts and see the cond at the end if a user click a certain button.

 

In the cond function we will put a call to your picket lisp and pass it 3 values

 

And set up some if statements to repopulate the tiles

 

Also notice that you can set up a save file to write values to when the user click the ok button

When the program starts it look for this file and load the values into the proper tile in the dcl

If a file is not found there are some default values set up.

 

Copy this file and save it to a folder so you can steal it and make it work for other projects later.

 

Any questions?

Can you see how this will work for you with a little alteration?

 

Of course the defun will have to be renamed from qdx:DialogInput to picket:DialogInput

Just to keep thing easy to follow.

 

What you need to do next is write a main lsp file that will call the in/out file.

Just put it in the same file as picket

 

(defun c:pkt ( / )

 

(picket:DialogInput)

(princ)

);_defun

 

So the process will be:

 

User types pkt

pkt calls the dialog box

User enters 3 answers and clicks calculate

The in/out loops and calls the picket lisp passing 3 values and returning the 3 values plus 4 processed answers

When the dialog box loops the 3 values a repopulated and the answers are displayed in the proper boxes.

 

Everybody is impressed and you get a raise

 

 

If you cant figure it out let me know and I’ll show you how it all works.

 

 

 

 
(defun qdx:DialogInput (/ dcl_id       dialogloaded dialogshow
                         dr_file      dr_set       qdx_depth
                         qdx_hwos     qdx_matt     qdx_sing
                         result       userclick    what_next
                       )
(setq dialogLoaded T
dialogShow T) 
(if (= -1 (setq dcl_id (load_dialog "qdx.DCL")));_looks for and loads the dcl file
(progn
(princ "\nERROR: Cannot load qdx.dcl");_error trapping
(setq dialogLoaded nil)
) ;_ end of progn
) ;_ end of if
(setq what_next 2);_this is a variable for the loop
(while (>= what_next 2);_this is the loop
(if (and (not (new_dialog "qdx_maindlg" dcl_id));_if everything is found let the program proceed
dialogLoaded
) ;_ end of and
(progn
(princ "\nERROR: Cannot show dialog qdxdlg");_error trap if there is a problem
(setq dialogShow nil)
) ;_ end of progn
) ;_ end of if
(if (and dialogLoaded dialogShow)
(progn
;;; below is where you assign values to tiles and other stuff

       (setq qdxff (findfile "c:/program files/quick draw/qdxlu.jdb"));_see if saved file exist
;;; if it does continue
       (if qdxff
       (progn
(setq dr_file (open qdxff "r"))
(setq retval (read(read-line dr_file)));-read values from saved file
(close dr_file)
       (set_tile "qdx_hwo" (cdr(assoc 2 retval)));_hardware offset
(set_tile "qdx_mtk" (cdr(assoc 1 retval)));_material thick
       (if (= (cdr(assoc 3 retval)) "1")
       (progn
(set_tile "qdx_sin" "1");_single
       (set_tile "qdx_dbl" "0");_double
       );_progn
       (progn
(set_tile "qdx_sin" "0");_single
       (set_tile "qdx_dbl" "1");_double
       );_progn
       );_if
(set_tile "qdx_dpt" (cdr(assoc 4 retval)));_depth
(mode_tile "qdx_dpt" 2)
       );_progn
  ;;;if saved file not there set default values
       (progn
(set_tile "qdx_hwo" "0.5313");_hardware offset
(set_tile "qdx_mtk" "0.75");_material thick
(set_tile "qdx_sin" "1");_single
       (set_tile "qdx_dbl" "0");_double
(set_tile "qdx_dpt" "20.00");_depth
       (mode_tile "qdx_dpt" 2)
       );_progn
       );_if

       (action_tile "qdx_sin" "(set_tile \"qdx_dbl\" \"0\")")
(action_tile "qdx_dbl" "(set_tile \"qdx_sin\" \"0\")")
(action_tile "qdx_wld" "(done_dialog 4)");_if user click this button go to the cond function below and run program
(action_tile "qdx_obj" "(done_dialog 5)");_if user click this button go to the cond function below and run program
(action_tile "qdxhlp"  "(help \"QD50.HLP\" \"Topic13\")")
(action_tile "cancel" "(done_dialog)(setq UserClick nil) ");_if user click the cancle button make dlg go bye-bye
;;; if user clicks ok  button assign tile values to variables
(action_tile
"accept"
(strcat
"(progn"
"(setq qdx_sing (get_tile \"qdx_sin\"))"
"(setq qdx_depth (get_tile \"qdx_dpt\"))"
"(setq qdx_matt (get_tile \"qdx_mtk\"))"
"(setq qdx_hwos (get_tile \"qdx_hwo\"))"
"(if (> (atof(get_tile \"qdx_dpt\")) 0.00)(progn (done_dialog)(setq UserClick T))"
"(alert \" Enter a box depth.\")))"
) ;_end strcat
) ;_ end of action_tile
(setq what_next (start_dialog))
(if UserClick   ; User clicked Ok
;; Build the resulting data
(progn
(setq result
       (list
(cons 3 qdx_sing);single or double
(cons 4 qdx_depth);_depth
(cons 1 qdx_matt);_material thickness
(cons 2 qdx_hwos);_hardware offset
) ;_ end of list
);_setq
       (qdx_wt_fl (vl-prin1-to-string result));_write last used to file
);_progn
) ;_ end of if
) ;_ end of progn
) ;_ end of if
(cond
((= what_next 4)
(command "ucs" "world"));_do this if user clicks the button named qdx_wld
((= what_next 5)
(qdx_obsel)) ;_do this if the user clicks the button named qdx_obj     
);_end cond
);_end while
(unload_dialog dcl_id)
result        ;;;  passes the results back to the main lisp file for processing
) ;_ end of defun

;;; this defun is called from the cond above when user clicks the correct button
(defun qdx_obsel (/ obj echo)
(setq echo(getvar "cmdecho"))
(setvar "cmdecho" 0)
(setvar "pickbox" pickbx)
(setq obj (car(entsel "\nSelect object to align UCS:")))
(if obj(command "ucs" "new" "object" obj))
(setvar "pickbox" 0)
(setvar "cmdecho" echo)
(princ)
 );_end defun
;;; this id called and passes values to write to a file so when the dialog box re appears it is loaded with last input
(defun qdx_wt_fl (aug1 / opff)
  (setq opff (open "c:/program files/quick draw/qdxlu.jdb" "w"))
  (write-line aug1 opff)
  (close opff)
 (princ)
);_defun

Link to comment
Share on other sites

Not sure if the correct variable are being passed back but you can correct them

Also I’m not sure about the format of the return answers. Are they all real numbers?

 

I also discovered that I was wrong in the return list. You don’t need to pass the 3 question values back if you use my solution in this post.

 

Here are all 3 files to play with:

 

[font=Times New Roman][font=Times New Roman];;;;; main calling program[/font]
[font=Times New Roman](defun c:pkt ()[/font]
[font=Times New Roman](picket:DialogInput)[/font]
[font=Times New Roman]  (princ)[/font]
[font=Times New Roman]  );_defun[/font]
[font=Times New Roman](defun picket (dst1 pip1 bar1 / ret aa ab ac ad ae af ag ds1 dst2 num1 d num2 spa1 y y1 y2 y3 y4 spa2 dst3 endb endr1 endr2)[/font]

[font=Times New Roman] (setq dst2 (+ (- dst1 pip1) bar1))  ;dst2 is the spacing of pickets less the pipe post[/font]
[font=Times New Roman] (setq num1 (/ dst2 4))   ;num1 is the number of picket spaces @ exactly 4"[/font]
[font=Times New Roman] (setq d (fix (+ num1 0.99)))      ;d is the number of spaces needed to round up[/font]
[font=Times New Roman] (setq num2 (- d 2))    ;num2 is the number of spacing for the middle of the rail[/font]
[font=Times New Roman] (setq spa1 (/ dst2 d))[/font]
[font=Times New Roman] (setq y (+ spa1 0.03125))[/font]
[font=Times New Roman] (setq y1 (* y 32))[/font]
[font=Times New Roman] (setq y2 (- y1 (rem y1 1)))[/font]
[font=Times New Roman] (setq y3 (/ y2 2))[/font]
[font=Times New Roman] (setq y4 (- y3 (rem y3 1)))[/font]
[font=Times New Roman] (setq spa2 (/ y4 16))    ;spa2 is the picket space in the middle in 16ths.[/font]
[font=Times New Roman] (setq dst3 (* spa2 num2))   ;dst3 is the middle dimension.[/font]
[font=Times New Roman]                                       ;This is the number of spaces times the picket[/font]
[font=Times New Roman]     ;spacing for the middle section.[/font]
[font=Times New Roman] (setq endb (- dst1 dst3)) [/font]
[font=Times New Roman] (setq endr1 (/ (* endb 16) 2))[/font]
[font=Times New Roman] (setq endr2 (- endr1 (rem endr1 1)))[/font]
[font=Times New Roman] (setq endr (/ endr2 16))[/font]
[font=Times New Roman] (setq endl (- endb endr))   ;endl is the left end dimension minus[/font]
[font=Times New Roman]     ;the right end dimension.[/font]
[font=Times New Roman] (setq ret (list endr1 num2 spa1 endr1));_send back answers[/font]
[font=Times New Roman]);_defun[/font]
[/font]

 

in/out file

 

 
(defun picket:DialogInput (/ dcl_id dialogloaded dialogshow userclick what_next rtvls dstx
       pipx barx
      )
(setq dialogLoaded T
dialogShow T) 
(if (= -1 (setq dcl_id (load_dialog "pickets.DCL")));_looks for and loads the dcl file
(progn
(princ "\nERROR: Cannot load pickets.DCL");_error trapping
(setq dialogLoaded nil)
) ;_ end of progn
) ;_ end of if
(setq what_next 2);_this is a variable for the loop
(while (>= what_next 2);_this is the loop
(if (and (not (new_dialog "PICKETS" dcl_id));_if everything is found let the program proceed
dialogLoaded
) ;_ end of and
(progn
(princ "\nERROR: Cannot show dialog PICKETS");_error trap if there is a problem
(setq dialogShow nil)
) ;_ end of progn
) ;_ end of if
(if (and dialogLoaded dialogShow)
(progn
;;; below is where you assign values to tiles and other stuff
(if rtvls
(progn
(set_tile "end1" (rtos(nth 0 rtvls)2 3))
(set_tile "sp" (rtos(nth 1 rtvls)2 3))
(set_tile "sp2" (rtos(nth 2 rtvls)2 3))
(set_tile "end2" (rtos(nth 3 rtvls)2 3))
);_progn
(progn
(set_tile "end1" "")
(set_tile "sp" "")
(set_tile "sp2" "")
(set_tile "end2" "")
);_progn
);_if

       (if dstx (set_tile "x" dstx)(set_tile "x" ""))
(if pipx (set_tile "y" pipx)(set_tile "y" ""))
(if barx (set_tile "z" barx)(set_tile "z" ""))


(action_tile "cancel" "(done_dialog)(setq UserClick nil) ");_if user click the cancle button make dlg go bye-bye
;;; if user clicks ok  button assign tile values to variables 
(action_tile "accept" 
(strcat
"(progn"
"(setq dstx (get_tile \"x\"))"
"(setq pipx (get_tile \"y\"))"
"(setq barx (get_tile \"z\"))"
"(if (not (member \"\" (list dstx pipx barx)))"
"(progn"
"(done_dialog 4)"
")" ;_progn
"(alert \"Please enter values\")"
")" ;_if
")" ;_progn
) ;_end strcat
) ;_ end of action_tile
(setq what_next (start_dialog))
) ;_ end of progn
) ;_ end of if
(cond
((= what_next 4)
(setq rtvls (picket (atof dstx)(atof pipx)(atof barx))));_do this if user clicks the button named qdx_wld
);_end cond
);_end while
(unload_dialog dcl_id) 
) ;_ end of defun

 

 

dcl file:

 

 
PICKETS :dialog {
label = "The Picket Spacing Machine!" ;
: row {
:boxed_column {
label = "ENTER DIMENSIONS EXACTLY";
:edit_box {
key="x";
label="What is your Dimension from Center to Center of Post?" ;
//value=dst1;
edit_width=14;
alignment=centered;
}
:edit_box {
key="y" ;
label = "What is your Post Diameter";
//value=pip1;
edit_width=14;
}                    
:edit_box {
key="z" ;
label = "What is your Picket size";
//value=bar1;
edit_width=14;
}
:row {
:column {
width=10;
alignment=centered;
label="End Space 1";
:edit_box {
edit_width=6;
key="end1" ;
//value=endr1;
}
}
:column {
width=3;}
:column {
width=10;
label="# of Spaces";
:edit_box {
edit_width=6;
key="sp";
//value=num2;
}
}
:row {
:column{
width=15;
:text {key="tt" ; value="SPACES @";
alignment=centered;}}
}
:column {
width=10;
label="Space Size";
:edit_box {
edit_width=6;
key="sp2";
//value=spa2;
}
}
:column {
width=3;}
:column {
width=10;
alignment=centered;
label="End Space 2";
:edit_box {
key="end2" ;
edit_width=6;
//value=endr1;
}
}
}
:row {
:boxed_column {
label="Written by Joe Barrett and Brandon DeLoach     <2009>" ;}
}
}
}
: row {          // defines the OK/Cancel button row
 : spacer { width = 20; }
 : button {    // defines the OK or calculate button
   label = "Calculate";
   is_default = true;
   key = "accept";
   width = 8;
   fixed_width = true;
 }
 : button {    // defines the Cancel button
   label = "Cancel";
   is_cancel = true;
   key = "cancel";
   width = 8;
   fixed_width = true; }

 : spacer { width = 20;}
}
}

 

Link to comment
Share on other sites

Hey johnM I really appreciate everything that you did and i was going to post the routine i did this weekend. It worked almost just like yours everything was the same except i would not show the result in feet and inches and after seeing this morning what you did i quickly studied it and saw the

(set_tile "xxxx" (rtos(nth 0 rtvls)2 3))

I was like thats it!

Unfortunately i saved as over it with another routine i did but i will post it shortly.

so you helped alot with your guiding info.

im sure will talk again thanks bud.

 

"JeSuS fReAk":D

Link to comment
Share on other sites

great to hear you figured it out.

so when it is finished and working like planed you should turn it into a vlx file so it will be easy to share and no one cane change it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...