Jump to content

dcl start up


aloy

Recommended Posts

Is there a way to increase the text height with the program?. My attempt with the code given below doesn't seem to work.

(defun C:test(/ rws myTable row cell lst)
(setq l2(reverse l2)) ;l2 comes from saving in dialog
(setq n(length l2))  
(setq n(- n 1))
(command "table" 18 1 '(0 15) 2 2)
(if (and(setq en (entlast))
(setq myTable (vlax-EName->vla-Object en))
 (= (vla-get-ObjectName myTable) "AcDbTable")
(setq rws (vla-Get-Rows myTable))
)
(vla-InsertRows myTable rws (vla-GetRowHeight myTable (1- rws)) n)
)
(vla-settext myTable 0 0 "PIPE FLOW RESULTS")
(vla-settext myTable 1 0 "Solution No.")
(vla-settext myTable 1 1 "Solution Method")
(vla-settext myTable 1 2 "Pipe Size(mm)")
(vla-settext myTable 1 3 "Slope(%)")
(vla-settext myTable 1 4 "Manning's n")
(vla-settext myTable 1 5 "Flow(l/s)")
(vla-settext myTable 1 6 "Depth(mm)")
(vla-settext myTable 1 7 "Central  Angle(Rad.)")
(vla-settext myTable 1 8 "Full Bore  Flow(l/s)")
(vla-settext myTable 1 9 "Full Bore Vel(m/s)")
(vla-settext myTable 1 10 "Max. Flow(l/s)")
(vla-settext myTable 1 11 "Wetted Peri.(mm)")
(vla-settext myTable 1 12 "HydrRadius(mm)")
(vla-settext myTable 1 13 "Ratio-  n/nFull")
(vla-settext myTable 1 14 "CrossSecArea(mm^2")
(vla-settext myTable 1 15 "% PipeFull")
(vla-settext myTable 1 16 "AverageVel.(m/s)")
(vla-settext myTable 1 17 "Roughness")
;(setq nCols (length (car lx)))
(setq row 2)
(setq cell 0)
(if (/= l2 nil) 
     (while (/= l2 nil)
(setq lst(car l2))
        (while (<= cell 17)
   ;(vla-settextHeight myTable row cell 0.22) 
          (vla-settext myTable row cell (car lst))
          (vla-setCellAlignment myTable row cell acMiddleCenter)
   (setq lst(cdr lst))
          ;(if (> nCols 17) (progn (setq row(+ row 1)) (setq cell -1)))
         (setq cell(+ 1 cell))
        )
       (setq l2 (cdr l2))        
(setq row(+ row 1))
       (setq cell 0)
     )
)
(princ) 
)

Results.jpg

Link to comment
Share on other sites

  • Replies 151
  • Created
  • Last Reply

Top Posters In This Topic

  • aloy

    72

  • rlx

    67

  • Lee Mac

    6

  • stevesfr

    3

Top Posters In This Topic

Posted Images

Hi Rlx,

Thanks for links. I will look at them in a few moments. Here is the list l2 ( and the snippet in the dialog lisp showing how it is generated) for testing the code given in my previous post.

 

(defun Results2()

(setq lst2 (list nr1 "Varying 'n'" dia slo man flo gdx thita1 gq2 gv1 q1 p1 ar1 rt a1 pf gv n1))

(if (/= lst2 nil) (progn (setq l2 (cons lst2 l2) nr1 (+ nr1 1)))

)

)

 

(setq l2 '((3 "Varying 'n'" "300" "2.0" "0.013" "125" "245.9" "4.53" "139.1" "1.97" "146.48" "679" "91.3" "1.112" "62018" "82.0" "2.02" "0.0145")

(2 "Varying 'n'" "300" "1.5" "0.011" "80" "179.1" "3.53" "142.4" "2.01" "149.92" "530" "83.1" "1.186" "44025" "59.7" "1.82" "0.0130")

(1 "Varying 'n'" "450" "1" "0.011" "80" "168.2" "2.63" "341.9" "2.15" "359.94" "592" "91.6" "1.273" "54256" "37.4" "1.47" "0.0140"))

)

Link to comment
Share on other sites

I have seen the two methods. Tharwat's method appears to be the easiest.

Thanks.

 

Glad to be able to help :-) Just now little 'terrorist' walked in so no rest for me the next couple of hours ;-)

 

Gr. Rlx

Link to comment
Share on other sites

Rlx,

Another help please. I give below one of the four dialogs with calculated results on it. When I press "Save Results" the results will be saved to a list of lists and the results in the dialog disappears. Now I want to press "Results Table" to clear the dialog and bring the results table. That means the dialog can be closed both by "Close" and "Results Table" buttons. Is this possible. My attempts failed and could not find anything like that in the internet.

picture.JPG

Link to comment
Share on other sites

Rlx,

Another help please. I give below one of the four dialogs with calculated results on it. When I press "Save Results" the results will be saved to a list of lists and the results in the dialog disappears. Now I want to press "Results Table" to clear the dialog and bring the results table. That means the dialog can be closed both by "Close" and "Results Table" buttons. Is this possible. My attempts failed and could not find anything like that in the internet.

 

 

Sure , when you press "Close" you probably do a 'done_dialog' with a integer , something like (done_dialog 2) and if you want the same effect when you press "Results Table" you would do the same but with a different code , for example (done_dialog 3). You capture this code usually with something like (setq drv (start_dialog)) , drv = dialog return value. And after the line with start_dialog you would use the 'COND' function to see which button has ended the dialog and what action has to be taken (cond ((= drv 2)(save & exit)) ((= drv 3)(show results table))). Hope this makes sense 2 you?

 

 

gr. Rlx

Link to comment
Share on other sites

Hi Rlx,

Seems to have not got it yet. For example following code got me spinning:

(action_tile "table1" "(done_dialog 2)")

(action_tile "calc" "(Calculate)")

(action_tile "accept" "(done_dialog 1)")

 

(setq drv (start_dialog))

(cond ((= drv 1) (unload_dialog Dcl_Id%))

((= drv 2) (putTable)))

(defun putTable()

(results))

; table1 = key for "Results Table" button

; 'putTable' is the fuction activated when "Results Table" pressed

; saving results ok

Could you please advise?.

Link to comment
Share on other sites

Hi Rlx,

Seems to have not got it yet. For example following code got me spinning:

(action_tile "table1" "(done_dialog 2)")

(action_tile "calc" "(Calculate)")

(action_tile "accept" "(done_dialog 1)")

 

(setq drv (start_dialog))

(cond ((= drv 1) (unload_dialog Dcl_Id%))

((= drv 2) (putTable)))

(defun putTable()

(results))

; table1 = key for "Results Table" button

; 'putTable' is the fuction activated when "Results Table" pressed

; saving results ok

Could you please advise?.

 

 

Hi Aloy ,

 

 

your code is essentially ok. Just put your (defun putTable () ...) outside the dialog handler routine just as any other routine and make sure all the dialog values are stored in the appropriate global variables so your table function can reference them. Is the normal way to go with your app to first press calc and then if the results are ok you press table?

 

 

When your calculate function computes all the values for your table you must make sure you dont declare your variables in the calculate function as local variables because then your table function can't evaluate them.

 

 

I also assume you use your calculate function to verify your data. You could include a global variable like 'table-data-verified'. This way your calculation function can set a 'flag' that the data is ok for use in your table. When you then call the table function you would have something like (if table-data-verified (putTable) (progn (alert "You must first use calculate to verify the dialog data")(return to dialog))).

 

 

I guess your app is nearing completion? Although some apps are always evolving :-)

 

 

gr. Rlx

Link to comment
Share on other sites

Hi Rlx,

I have the following code:

(defun aloy_dialogim ()

(new_dialog dcl-name Dcl_Id%)

(aloy_init_dialogim)

(action_tile "eb_pipesize" "(update_pipesizeim (setq dia $value))")

(action_tile "eb_manning" "(update_manningim (setq man $value))")

(action_tile "eb_flow" "(update_flowim (setq flo $value))")

(action_tile "eb_slope" "(update_slopeim (setq slo $value))")

(action_tile "save" "(Resultsim)")

(action_tile "table" "(done_dialog 2)")

(action_tile "calc" "(Calculateim)")

(action_tile "accept" "(done_dialog 1)")

 

(setq drv (start_dialog))

(cond ((= drv 1) (unload_dialog Dcl_Id%))

((= drv 2) (putTable)))

)

(defun putTable()

(Resultsim1))

 

When "Save Results" pressed, the results are saved. When "Results Table" pressed the dialog disappears but no table. However when I invoke (putTable) a table appears without results. The results is an automation error that can be handled. Why the 'putTable' doesn't get activated?. I am referring to the table in the post #126

Link to comment
Share on other sites

Hi Rlx,

I have the following code:

(defun aloy_dialogim ()

(new_dialog dcl-name Dcl_Id%)

(aloy_init_dialogim)

(action_tile "eb_pipesize" "(update_pipesizeim (setq dia $value))")

(action_tile "eb_manning" "(update_manningim (setq man $value))")

(action_tile "eb_flow" "(update_flowim (setq flo $value))")

(action_tile "eb_slope" "(update_slopeim (setq slo $value))")

(action_tile "save" "(Resultsim)")

(action_tile "table" "(done_dialog 2)")

(action_tile "calc" "(Calculateim)")

(action_tile "accept" "(done_dialog 1)")

 

(setq drv (start_dialog))

(cond ((= drv 1) (unload_dialog Dcl_Id%))

((= drv 2) (putTable)))

)

(defun putTable()

(Resultsim1))

 

When "Save Results" pressed, the results are saved. When "Results Table" pressed the dialog disappears but no table. However when I invoke (putTable) a table appears without results. The results is an automation error that can be handled. Why the 'putTable' doesn't get activated?. I am referring to the table in the post #126

 

 

Hi Aloy,

 

 

Little difficult without the complete program , but you could try the following :

 

 

change your table action to (action_tile "table" "(Resultsim)(done_dialog 2)"). This makes sure you save your data before you exit the dialog.

 

 

Secondly , you would typically set a break point (F9) in your visual lisp editor within the putTable sub routine , just before you create the table itself. The program wil halt execution there and then you can inspect if all the variables have been set properly. You have a list of data , does it contain all the values it should?

 

 

Set a break point at the start of (vla-settext mytable row cell (car lst)) and inspect all your variables (watchwindow) : mytable , row , cell and lst or (car lst). Do they show the values you'd expect? If not , your data is not 'global' but probably saved in a local list or local variable?

 

 

gr. Rlx

Edited by rlx
Link to comment
Share on other sites

Thanks Rlx,

The problem solved. I left the "table" action same as before. However, changed the function definition for the dialog lisp as given below and I get what is given following table. I have also found that is very easy to format the table in exel the way we need after exporting to it. I therefore think that this product can be used for report writing for sewerage or drainage projects.

Thanks for all the help I have received from you and others in this forum.

With Best Regards,

Aloy.

(defun aloyim (/ Dcl_Id% eb-list)  
 (aloy_initim)
 (load"pipeflowx")   
 (load"FlowChecky")
 (load"pipeflowz")
 (load"MakeTableim1")
 (setq nr4 1
n nil
lim nil)
 (aloy_dialogim)
 (putTable)
 (aloy_exit)
 (princ)
)

Result1.jpg

Link to comment
Share on other sites

Super Moderator,

Thanks very much for the advice and sorry for any mishap. I have read the "Code Posting Guidelines" again and promise that I will fully comply. I also want to assure you that no property rights have been violated in working out these codes, but this forum has been of great support for me.

Thanks again,

Aloy

Edited by aloy
Link to comment
Share on other sites

Rlx,

The code given in my previous post doesn't appear to work in the way intended. For example even if I ended the dialog with "close" button the table appears on the screen, which should not be the case. It should appear only when the "Results Table" button is pressed. When I checked its return value, it still is 1. I think these drv value fixing code needs further testing.

Regards,

Aloy

Link to comment
Share on other sites

Rlx,

The code given in my previous post doesn't appear to work in the way intended. For example even if I ended the dialog with "close" button the table appears on the screen, which should not be the case. It should appear only when the "Results Table" button is pressed. When I checked its return value, it still is 1. I think these drv value fixing code needs further testing.

Regards,

Aloy

 

Hi ALoy , that should not be too deficult. When you init your dialog add something like (setq I_WantToShowMyTable nil). Make sure you declare this variable in your main routine and not in the dialog sub. When you exit your dialog with code 2 , in the part with the (cond ((= drv 2) etc , add (setq I_WantToShowMyTable T) and then when you come to (putTable) in the main routine add (if I_WantToSHowMyTable (putTable)).

 

Gr. Rlx

Link to comment
Share on other sites

Hi Rlx,

I think I have got it corrected for now. Will check your method also. What appears to have gone wrong is I have hanged the "key" for the "Results Table" button as "table" as shown in post #130, though I have put it correctly in post #128. Obviously 'table' has a conflict with the autocad command "Table". Another thing I found out is that whenever a "key" is not defined properly for a button, it returns 1 when pressed. This caused the problem. After correcting it the dialogs work all right. I corrected the lisp code as given below. I give an autocad drawing for the results table for anyone to convert to excel. Will verify the accuracy of the results later.

Regards,

Aloy

(defun aloyim (/ Dcl_Id% eb-list)  
 (aloy_initim)
 (load"pipeflowx")   
 (load"FlowChecky")
 (load"pipeflowz")
 (load"MakeTableim1")
 (setq nr4 1
n nil
lim nil)
 (aloy_dialogim)
 (if (= drv 2)(putTable))
 (aloy_exit)
 (princ)
)

TableTry.dwg

Link to comment
Share on other sites

Hi Rlx,

I think I have got it corrected for now. Will check your method also. What appears to have gone wrong is I have hanged the "key" for the "Results Table" button as "table" as shown in post #130, though I have put it correctly in post #128. Obviously 'table' has a conflict with the autocad command "Table". Another thing I found out is that whenever a "key" is not defined properly for a button, it returns 1 when pressed. This caused the problem. After correcting it the dialogs work all right. I corrected the lisp code as given below. I give an autocad drawing for the results table for anyone to convert to excel. Will verify the accuracy of the results later.

Regards,

Aloy

(defun aloyim (/ Dcl_Id% eb-list)  
 (aloy_initim)
 (load"pipeflowx")   
 (load"FlowChecky")
 (load"pipeflowz")
 (load"MakeTableim1")
 (setq nr4 1
n nil
lim nil)
 (aloy_dialogim)
 (if (= drv 2)(putTable))
 (aloy_exit)
 (princ)
)

 

okidoki...

 

btw , thats why I label my tiles bt_myclosebutton , eb_myeditbox , tg_mytoggle , so I avoid any conflict and can see quickly what type of tile triggered an action. Also I try to use variable names in the keyname , tg_savetoexcel -> (setq Aloy-SaveTo Excel "1") where I use Aloy- (dash) as prefix for variables and Aloy_ (underscore) as prefix for function definitions , also to avoid any conflict with other loaded functions. To some this may seem to be a little over the top but if you write / use as many functions as I do you sometimes learn the hard way you know ;-)

 

Gr. Rlx

Link to comment
Share on other sites

Rlx,

You have given me the details of fixing the value for drv and also how the variable should not have a conflict with the system. These helped me to come this far and I think we have reached the all important milestone. This thread appears to have many hits recently and I hope it has been of help to many.

cheers.:D:beer:

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...