Jump to content

Recommended Posts

Posted

I have a piping utility which creates 3D components to insert into a model.

All works fine.

But, everthing is on a single dialog, appart from a child dialog for elbow bend radii.

 

I am considering changing the layout of the main dialog such that when selecting the item type to be created/inserted (radio button) the main dialog is closed to be replaced by a new dialog with just the relevant options for that selection. When selecting the OK button in the new dialog the item is inserted into the drawing.

 

Question:

Can this be done keeping all of the code in a single DCL file and single lsp file?

any hints/tips to get me started would be appreciated :)

 

SteveN

Posted

You can have a pop child dcl so when you select a dcl button the child is displayed the child can have grand children also. Is this what you want.

 

image.png.acf6744ff9512d1f3fa10614a83b32da.png

Posted

Hi Bigal,

NO, I already have a child dcl, here

spacer.png

 

What I am trying to achive is by selecting 'fittings' (in the above image) the current dialog is closed not hidden and a replacemnet dialo is opened/loaded which will contain ALL of the fittings options, so the greyed out options in the above image will not be presented to the user.

 

Here are the 2 dialogs (still wip)

spacer.png

 

 

I hope that makes sense.

Posted

Yes that is possible, you will of course need to define 2 dialogue boxes and so on. I'd make them dynamically - a part of the lisp file.

 

DCL as part of a LISP file can be made 2 ways, I'd go for create a temporary DCL file -somewhere- and each line use 'Write Line' some of the others define DCL in a list first and do a repeat loop to do the write line after that. Not sure if that makes sense what I am describing, the 2nd method might be a little more efficient and quicker but the 'write line' for each line allows you more scope to put in if statements and so the second DCL can be a bit more dynamic.

 

For passing the variables, you can set variables for each in the first dialogue, update the variable as the DCL is changed - and then when the DCL is closed the variables are retained and can be used to populate the next DCL. Close on the first can then open the second.

 

Something like that anyway

Posted

Sounds like you have no option but close the dcl and open the second but with correct items greyed out. When you hit Ok om second dcl it can reopen the 1st dcl if you need to do more. It may be better to just daisy chain the input so make all the dcl's little ones so do a next, next type of sequence rather than trying to do one big one.

image.png.bc68d29951e3a85bb4b4699b6771ca98.png

image.png.bcec3af208351a91ef215ec181ad3d25.png

image.png.21f7a3b8526a2f575efe42e94ea46379.png

 

  • Like 1
Posted (edited)

I've made some progress, I have the second (child) dialog displaying and working, almost.

Still not able to turn off the original dialog.

can be seen in this image, In the backgound.:

spacer.png

 

In the action tile on the first dialog that calls the child dialog, I've tried:

;(unload_dialog dcl_id_m)

;(unload_dialog "dcl_id_m")

neither work.

 

 

Edited by sln8458
  • Like 1
Posted

what is the action code for the parent that calls the child? It should have a done_dialog, (done_dialog 1) I think

Posted (edited)
10 minutes ago, Steven P said:

what is the action code for the parent that calls the child? It should have a done_dialog, (done_dialog 1) I think

This is the code that opens the child dialog (NEST_FITTINGS)

 	(action_tile "s1"				 						;toggle Fitting options
		"(L1_ON)(L1_CLEAR)(L5_OFF)(L5_CLEAR)
		(RESET_LABELS)(RESET_DIMS)(RESET_LIST)(NEST_FITTINGS)
		(done_dialog DCL_ID_M)"			;(unload_dialog dcl_id_m)"		;(unload_dialog "dcl_id_m")"									 
	); END ACTION TILE 

 

Done dialog didn't work without the " "'

with " " the parent dialog closed, but the child does not open!!

 

Parent dialog Defun

 

Edited by sln8458
Posted
(defun DIALOG ()
  (setq DCL_ID_M (load_dialog "sln_piping.dcl")) ;load the DCL file
  (if (not (new_dialog "sln_piping" DCL_ID_M)) ;initialize the DCL file
    (exit) ;exit if this doesn't work
   ) ;end if 


(action_tile "accept" "(CHECK_SELECTIONS)") 
  (action_tile "cancel" "(setq newtile nil size nil)(done_dialog)(exit)")
;-----------------------------------------------------------------------;
;-----------------------------END OF ACTION TILE STATEMENTS--------------;  
; (defun DIALOG () continued
  (start_dialog)											;start dialog
  (unload_dialog dcl_id_m) 									;unload 

 

Posted

Quickly looking I have used a 1 in the past rather than dcl_id_m - have you tried that (I guess you have), another option is term-dialog which should close all dialogs then open the new one?

Posted (edited)

This works, almost!

 	(action_tile "s1"	
		"(L1_ON)(L1_CLEAR)(L5_OFF)(L5_CLEAR)
		(RESET_LABELS)(RESET_DIMS)(RESET_LIST)
		(term_dialog)(NEST_FITTINGS)"		;(unload_dialog "dcl_id_m")"									 
	); END ACTION TILE 

The child dialog pops up and totally covers the parent dialog, identical size & position.

When selecting OK, the chosen fitting is placed as intended.

 

If you drag the child dialog to one side, you can then see the parent dialog.

Edited by sln8458
Posted

So to check, are you closing the parent first and then opening the child?

Posted

Write a separate defun function includes the child dialog codes then in the action tile that you would like to fire up the child dialog when closing the parent one, add done_dialog then assign a variable to something like (setq go_child t) then after the start_dialog you can check if the variable is true then load the dialog.

 

Why do you have all these dummy radio buttons ? you can replace them with popup list which would reduce that big size of dialog and should look much more pretty than that, I believe.

  • Like 1
Posted

Yes, might be a help to see them, got some examples of what your trying to do but I'd need 10 minutes somewhere to slim them down so you can see what I did.

 

Posted (edited)

Try this, cut and pasted and shortened from other stuff so might be something missing, run with 'DCL' - just as a worked example to follow

 

- It creates 2 files 'on the fly' - Parent and Child, change these names to suit if you want. Saved in the Windows Temporary files folder and saved there each time. Since the names are fixed there should only ever be 1 copy of these there, not filling up temp folder each time this runs

 

- Adjust them to suit your needs. The DCL file is made up using "Write Line" to make the text file - a bit less efficient but allows for some programming as you make the file up. Here parent and child are similar (copy and pasted!)

 

- Remember to use unique names for everything and in both files, not strictly necessary but good practice anyway, and also remember to define local variables as required (this has messed up a few of my DC:s forgetting that part)

 

- There is a button in the parent DCL box which open the child DCL as well (both open) - as Tharwat mentioned, this is opened via a separate LISP by way of an example

 

- Includes example of passing data from parent to child

 

- Have fun!

 

 

(defun c:dcl ( / p parentname c childname parent_id child_id MyCancel MyStuff )

;;Initial values


;;End initial stuff


;; Write DCL Files:
;;PARENT DCL Header Stuff. As a temp file
  (setq p (open (setq parentname (vl-filename-mktemp "PARENT" (getvar "TEMPPREFIX") ".dcl")) "w"))
  (write-line "Parentkey : dialog {" p)
  (write-line "  key = \"Parent box\";" p)
  (write-line "  label = \"Parent box\";" p)
  (write-line "  spacer;" p)

;DCL Body Stuff
(write-line "  : text { key = \"pfiletext\"; label = \"Some text\"; width = 20; alignment = right;}" p)
(write-line "  : text { key = \"pFile\"; label = \"File Name\"; width = 5; alignment = left;}" p)
(write-line "  : text { key = \"pLisp\"; label = \"Lisp Name\"; width = 5; alignment = left;}" p)
(write-line "  : row  {alignment = middle;" p)
(write-line "  :   text { key = \"pOR1\"; label = \"-OR-\"; width = 20; alignment = right;}" p)
(write-line "    }" p) ; end row
(write-line "  : button { key = \"Pfolder\"; label = \"Change Lisp Library\"; is_default = false; fixed_width = true; width = 5;}" p)
(write-line "  : list_box {key = \"pDCLHELPTEXT\"; height = 10; fixed_height = true; width = 50; fixed_width = true;}" p)
(write-line "  : button { key = \"POK\"; label = \"OK\"; is_default = true; fixed_width = true; width = 5;}" p)
(write-line "  : button { key = \"Pcancel\"; label = \"Cancel\"; is_default = true; fixed_width = true; width = 5;}" p)

;DCL End Stuff
  (write-line "}" p)
  (close p)
;; Close Parent DCL File




;CHILD DCL Header Stuff. As a temp file
  (setq c (open (setq childname (vl-filename-mktemp "CHILD" (getvar "TEMPPREFIX") ".dcl")) "w"))
  (write-line "Childkey : dialog {" c)
  (write-line "  key = \"Child box\";" c)
  (write-line "  label = \"Child box\";" c)
  (write-line "  spacer;" c)

;DCL Body Stuff
(write-line "  : text { key = \"cfiletext\"; label = \"Little text\"; width = 20; alignment = right;}" c)
(write-line "  : text { key = \"cFile\"; label = \"--\"; width = 5; alignment = left;}" c)
(write-line "  : text { key = \"cLisp\"; label = \"--\"; width = 5; alignment = left;}" c)
(write-line "  : row  {alignment = middle;" c)
(write-line "  :   text { key = \"cOR1\"; label = \"-OR-\"; width = 20; alignment = right;}" c)
(write-line "    }" c) ; end row
(write-line "  : button { key = \"Cfolder\"; label = \"Change Lisp Library\"; is_default = false; fixed_width = true; width = 5;}" c)
(write-line "  : list_box {key = \"cBABYTEXT\"; height = 10; fixed_height = true; width = 50; fixed_width = true;}" c)
(write-line "  : button { key = \"COK\"; label = \"OK\"; is_default = true; fixed_width = true; width = 5;}" c)

;DCL End Stuff
  (write-line "}" c)
  (close c)
;; Close Child DCL File


;; Start Parent DCL
;; Get Parent DCL IDs
  (setq parent_id (load_dialog parentname))
  (if (not (new_dialog "Parentkey" parent_id)) (exit) ) ; if DCL Doesn't exist

  (action_tile "Pfolder" "(buttonlisp childname \"Childkey\" \"Hello World\")")
  (action_tile "POK"     "(setq MyStuff \"Passing Data\")(done_dialog 1)")
  (action_tile "Pcancel" "(setq MyCancel \"Yes\")(done_dialog 0)")

  (start_dialog)
  (unload_dialog parent_id)
;; End Parent DCL



;; Start Child DCL
  (if (= MyCancel "Yes")
    ()
    (progn
;; Get Child DCL IDs
      (setq child_id (load_dialog childname))
      (if (not (new_dialog "Childkey" child_id)) (exit) ) ; if DCL Doesn't exist

      (set_tile "cFile" MyStuff)

      (action_tile "Cfolder" "(alert \"Does nothing\")")
      (action_tile "COK"     "(setq MyStuff \"Passed Data\")(done_dialog 1)")
      (action_tile "Ccancel" "(done_dialog 0)")

      (start_dialog)
      (unload_dialog child_id)
    ) ; end progn
  ); end if

)


(defun buttonlisp ( DCLdname DCLKey Data / DCL_id) ; Pass DCL Names to here to open dialogs defined above
  (setq DCL_id (load_dialog DCLdname))
  (if (not (new_dialog DCLKey DCL_id)) (exit) ) ; if DCL Doesn't exist


;;Tiles and actions can be anything... will ignore any that are not in the DCL
  (set_tile "cFile" Data )

  (action_tile "Cfolder" "(alert \"Does nothing\")")
  (action_tile "COK"     "(setq MyStuff \"Passed Data\")(done_dialog 1)")
  (action_tile "Ccancel" "(done_dialog 0)")

  (start_dialog)
  (unload_dialog DCL_id)
)

 

Edited by Steven P
Small edit to code to ButtonLisp and pfolder action tile
Posted

Thanks guys.

Lots to try and lots to think about.

Posted (edited)

Updating this a little with a slight different concept. I should really work this up as a better answer... but I am in the office today and so CAD will be off at home time - If I get chance I'#ll do something this afternoon.

 

In this example the button "Change Lisp library" will close the original dialog and run a new one, the example above kept them both open, with the 'OK' button closing the original dialog and opening the next one.

 

This method works by having the action_tiles for the controls setting a flag and closing the dialog as if it is an 'OK'. Later in the LISP (could be the next line) read the flag and open a new dialog according to what that flag value is

 

(action_tile "Button" "(setq RunaLisp 1)(done_dialog 1)")
(action_tile "OK"     "(setq MyStuff \"Passing Data\")(done_dialog 1)")
(action_tile "cancel" "(setq MyCancel \"Yes\")(done_dialog 0)")
...
(if (= RunaLisp nil).. run ending dialog / routines
(if (= RunaLisp 1)(buttonlisp childname "Childkey" "Hello World"))
...
(defun buttonlisp .. LISP to create alternative dialogs)

 

 

 

(defun c:dcl ( / p parentname c childname parent_id child_id MyCancel MyStuff runalisp MyTile)

;;Initial values


;;End initial stuff

;; Write DCL Files:


;;;;;;;;PARENT DCL;;;;;;;;
;; Header Stuff. As a temp file
  (setq p (open (setq parentname (vl-filename-mktemp "PARENT" (getvar "TEMPPREFIX") ".dcl")) "w"))
  (write-line "Parentkey : dialog {" p)
  (write-line "  key = \"Parent box\";" p)
  (write-line "  label = \"Parent box\";" p)
  (write-line "  spacer;" p)

;DCL Body Stuff
(write-line "  :row { : boxed_radio_column { label = \"Select 'S'\";" p)
(write-line "  : radio_button { key = \"ps1\"; label = \"Fittings\"; }" p)
(write-line "  : radio_button { key = \"ps2\"; label = \"Flanges\"; }" p)
(write-line "  : radio_button { key = \"ps3\"; label = \"Valves\"; }" p)
(write-line "  : radio_button { key = \"ps4\"; label = \"Pipes\"; }" p)
(write-line "  }}" p) ; end radio row

(write-line "  : row  {alignment = middle;" p)
(write-line "  :   text { key = \"pOR1\"; label = \"-OR-\"; width = 20; alignment = right;}" p)
(write-line "  : button { key = \"Pfolder\"; label = \"A Button\"; is_default = false; fixed_width = true; width = 5;}" p)
(write-line "    }" p) ; end row

(write-line "  : row  {alignment = middle;" p)
(write-line "  : button { key = \"POK\"; label = \"OK\"; is_default = true; fixed_width = true; width = 5;}" p)
(write-line "  : button { key = \"Pcancel\"; label = \"Cancel\"; is_default = true; fixed_width = true; width = 5;}" p)
(write-line "    }" p) ; end row

;DCL End Stuff
  (write-line "}" p)
  (close p)
;;;;;;;; Close Parent DCL File ;;;;;;;;;




;;;;;;;CHILD 1 DCL;;;;;;;;
;; Header Stuff. As a temp file
  (setq c (open (setq childname (vl-filename-mktemp "CHILD" (getvar "TEMPPREFIX") ".dcl")) "w"))
  (write-line "Childkey : dialog {" c)
  (write-line "  key = \"Child box\";" c)
  (write-line "  label = \"Child box\";" c)
  (write-line "  spacer;" c)

;DCL Body Stuff
(write-line "  : text { key = \"cfiletext\"; label = \"Little text\"; width = 20; alignment = right;}" c)
(write-line "  : text { key = \"cFile\"; label = \"--\"; width = 5; alignment = left;}" c)
(write-line "  : text { key = \"cLisp\"; label = \"--\"; width = 5; alignment = left;}" c)
(write-line "  : button { key = \"Cfolder\"; label = \"Change Lisp Library\"; is_default = false; fixed_width = true; width = 5;}" c)
(write-line "  : button { key = \"COK\"; label = \"OK\"; is_default = true; fixed_width = true; width = 5;}" c)

;DCL End Stuff
  (write-line "}" c)
  (close c)
;;;;;;;; Close Child DCL File ;;;;;;;;


;; Start Parent DCL
;; Get Parent DCL IDs
  (setq parent_id (load_dialog parentname))
  (if (not (new_dialog "Parentkey" parent_id)) (exit) ) ; if DCL Doesn't exist


(setq MyTile "none selected")
  (action_tile "ps1" "(setq RunaLisp 1)(setq MyTile \"S1\")(done_dialog 1)")
  (action_tile "ps2" "(setq RunaLisp 2)(setq MyTile \"S2\")(done_dialog 1)")
  (action_tile "ps3" "(setq RunaLisp 3)(setq MyTile \"S3\")(done_dialog 1)")
  (action_tile "ps4" "(setq RunaLisp 4)(setq MyTile \"S4\")(done_dialog 1)")

  (action_tile "Pfolder" "(setq RunaLisp 1)(done_dialog 1)")
  (action_tile "POK"     "(setq MyStuff \"Passing Data\")(done_dialog 1)")
  (action_tile "Pcancel" "(setq MyCancel \"Yes\")(done_dialog 0)")

  (start_dialog)
  (unload_dialog parent_id)
;; End Parent DCL

(if (= RunaLisp 1)(buttonlisp childname "Childkey" MyTile))
(if (= RunaLisp 2)(buttonlisp childname "Childkey" MyTile))
(if (= RunaLisp 3)(buttonlisp childname "Childkey" MyTile))
(if (= RunaLisp 4)(buttonlisp childname "Childkey" MyTile))
(if (= RunaLisp nil)
  (progn

;; Start Child DCL
  (if (= MyCancel "Yes")
    ()
    (progn
;; Get Child DCL IDs
      (setq child_id (load_dialog childname))
      (if (not (new_dialog "Childkey" child_id)) (exit) ) ; if DCL Doesn't exist

      (set_tile "cFile" MyStuff)
      (action_tile "Cfolder" "(alert \"Does nothing\")")
      (action_tile "COK"     "(setq MyStuff \"Passed Data\")(done_dialog 1)")
      (action_tile "Ccancel" "(done_dialog 0)")

      (start_dialog)
      (unload_dialog child_id)
    ) ; end progn
  ); end if

)); end prog , end if 'runalisp = nil


)


(defun buttonlisp ( DCLdname DCLKey Data / DCL_id) ; Pass DCL Names to here to open dialogs defined above
  (setq DCL_id (load_dialog DCLdname))
  (if (not (new_dialog DCLKey DCL_id)) (exit) ) ; if DCL Doesn't exist


;;Tiles and actions can be anything... will ignore any that are not in the DCL
  (set_tile "cFile" Data )

  (action_tile "Cfolder" "(alert \"Does nothing\")")
  (action_tile "COK"     "(setq MyStuff \"Passed Data\")(done_dialog 2)")
  (action_tile "Ccancel" "(done_dialog 2)")

  (start_dialog)
  (unload_dialog DCL_id)
)

 

 

Thinking about it, you can use the done_dialog value (below, 0 or 1) to set the next action, you can set done_dialog value to whatever you want.

 

So in your dialog you could have:

(done_dialog 0) for cancel

(done_dialog 1) for OK

(done_dialog 2) for Fittings DCL

(done_dialog 3) for Flanges DCL

(done_dialog 4) for Valves DCL

 

 

 

Hope it makes sense that way.. in the office surrounded by the boss and his little minions so a quick answer...  (joke - the boss is good here)

 

 

Edited by Steven P

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