DCL radio button insert block

DCL radio button insert block

god17169
Participant Participant
1,880 Views
5 Replies
Message 1 of 6

DCL radio button insert block

god17169
Participant
Participant

hello guys, i'am a novice on this, i have read about dcl and i was able to create one 

 

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

title : dialog {
label = "Drawing Title" ;

:boxed_radio_column {
label = "Type" ;

: radio_button {
key = "rb1" ;
label = "&Title" ;
value = "1" ;
}

: radio_button {
key = "rb2" ;
label = "&Detail" ;
}

: radio_button {
key = "rb3" ;
label = "&Section" ;
}

:edit_box {
label="Drawing Name: ";
key = "name";
edit_limit = 30;
edit_width = 30;
}

:edit_box {
label="Drawing Scale: ";
key = "scale";
edit_limit = 30;
edit_width = 30;
}

}

ok_cancel ;

: paragraph {

: text_part {
label = "Designed and Created";
}

: text_part {
label = "by AkosiChris";
}

}

}

 

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

now i want an lisp file that when i click radio button "Title" it would insert a block that will use the data on edit_box "Drawing name" and "drawing scale". Same should happen if i click "Detail" or Section"

 

I;am having a hard time on this, so far i can only load the dcl but i dont know the code to insert the block and call the data in edit_box to be in the attribute of the inserted block.

 

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

(defun C:title ()
(setq p1 (getpoint "\nPick Insertion point:"))
(setq radio_option $value)
if(= radio_option "rb1")
(cond
((=radio_option "0") (command "-Insert" "STEPUP.dwg" "_non" pt "" pause))
((=radio_option "1") (command "-Insert" "STEPUP.dwg" "_non" pt "" pause))
)
)
(if(= radio_option "rb2")
((=radio_option "0") (command "-Insert" "STEPSLOPE.dwg" "_non" pt "" pause))
((=radio_option "1") (command "-Insert" "STEPSLOPE.dwg" "_non" pt "" pause))
)
)
)

(setq dcl_id (load_dialog "drawingtitle.dcl"))

(if (not (new_dialog "title" dcl_id)

)

(exit)
)


(set_tile "A/1" "Enter Number/Letter Here")
(mode_tile "name" 2)
(action_tile "A/1" "(setq A/1 $value)")
(action_tile "rdwg" "(setq rdwg $value)")
(action_tile "rb1" "(setq hole \"title\")")
(action_tile "rb2" "(setq hole \"scale\")")


(action_tile
"cancel"
"(setq ddiag 1) (done_dialog) "
)

(action_tile
"accept"
"(setq ddiag 2) (done_dialog) "
)


(start_dialog)
(unload_dialog dcl_id)
(princ)
)

(princ)

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

0 Likes
Accepted solutions (1)
1,881 Views
5 Replies
Replies (5)
Message 2 of 6

paullimapa
Mentor
Mentor

Check out this tutorial and you'll get a better handle on DCL especially with Radio buttons:

 

http://www.jefferypsanders.com/autolisp_DCL_Part5.html

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 6

scot-65
Advisor
Advisor
This will get quite lengthy so I will give you a start...

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

Where:
(TITLE_GET) is a subroutine (function) that will gather
all the tiles status and save these values as a LIST. For your
example, there will be 3 of them. I'm taking a "snapshot"
of the dialog's state just before closing.

Let's take advantage of the done_dialog's integer return to start_dialog:
(setq sd (start_dialog))

From there enter into your "Main" program to evaluate:
(if (and sd (> sd 0))...

Subroutine:
(setq USER_TITLE (list
(get_tile "Rad100") ;<-- need to add key to :boxed_radio_column
(get_tile "name") ;<-- these are text case sensitive
(get_tile "scale")
))

Access this list using (nth 0 USER_TITLE), (nth 1 USER_TITLE), etc.

By assigning boxed_radio_column to a key, the set_tile and get_tile
values will be any of it's children keys in the radio set.
Try it yourself - remove "value" in the DCL and add inside the LSP
file, under the "Set" section: (set_tile "Rad100" "rb1")

I'm in quick reply here, but I do have a text document that is a
beginning LSP template that uses DCL. Search for it in this forum.

Good Luck.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 4 of 6

smaher12
Advocate
Advocate
Accepted solution

See if this helps any. Note, you have to enter in your block name in the "YOUR_BLOCK_NAME" section.

 

 

(defun c:ss ()

 (defun title_dflt ()
   (if (= typ nil) (setq typ "t"))
   (if (= name nil) (setq name "Drawing Name"))
   (if name (set_tile "name" name))
   (if (= scale nil) (setq scale "Scale: 1/8\" = 1'-0\""))
   (if scale (set_tile "scale" scale))

   (if (= typ "t") (set_tile "rb1" "1"))
   (if (= typ "d") (set_tile "rb2" "1"))
   (if (= typ "s") (set_tile "rb3" "1"))
 ); title_dflt

 (title_set)
  (if
    (setq p1 (getpoint "\nSpecify insertion point: "))
      (progn
	(cond
	  ((= typ "t") 
	   (command "-insert" "YOUR_BLOCK_NAME" "_none" p1 "" "" "" name scale)
	  )
	  ((= typ "d") 
	   (command "-insert" "YOUR_BLOCK_NAME" "_none" p1 "" "" "" name scale)
	  )
	  ((= typ "s") 
	   (command "-insert" "YOUR_BLOCK_NAME" "_none" p1 "" "" "" name scale)
	  )
	); cond
      ); progn
  ); if
 (princ)
); ss

 (defun title_set ()
   (setq dcl_id (load_dialog "ss.dcl"))
    (if (not (new_dialog "ss" dcl_id))
     (exit)
 )

 (title_dflt)
   (action_tile "rb1" "(setq typ \"t\")")
   (action_tile "rb2" "(setq typ \"d\")")
   (action_tile "rb3" "(setq typ \"s\")")
   (action_tile "name" "(setq name $value)")
   (action_tile "scale" "(setq scale $value)")
   (action_tile "accept" "(done_dialog)")
   (action_tile "cancel" "(exit)")
    (start_dialog)
     (unload_dialog dcl_id)
      (princ)
 ); title_set
(princ)
ss : dialog {
	 label = "Drawing Title";
  spacer;       

	: boxed_radio_row {
	  label = "Block Type:";

	  : radio_button {
	    label = "&Title";
	    key = "rb1";
	  }
	  : radio_button {
	    label = "&Detail";
	    key = "rb2";
	  }
	  : radio_button {
	    label = "&Section";
	    key = "rb3";
	  }
	} // end boxed_radio_row
  spacer;

	: boxed_column {
	  label = "Drawing:";

	  : edit_box {
	    label = "Name:";
	    key = "name";
	    edit_width = 30;
	    mnemonic = "T";
	    allow_accept = true;
	  }
	  : edit_box {
	    label = "Scale:";
	    key = "scale" ;
	    edit_width = 30 ;
	    mnemonic = "T" ;
	    allow_accept = true ;
	  }
	} // end boxed_column
  spacer;

  ok_cancel;
} // end dialog
Message 5 of 6

god17169
Participant
Participant
thanks for this code smasher12, rely worked, except the part that should call the Drawing name and scale, it did not attached to the inserted blocks, i ill try to find a solution for this on my side, but aside from that this code took me closer to what i was trying to achieve.. apprieciate your time and code..
0 Likes
Message 6 of 6

scot-65
Advisor
Advisor
From the above code, name and scale are attributes of the block.
(setvar "ATTDIA" 0) before inserting.

Also, if one can select the names from a list instead of entering
in an edit box, then it will be more user friendly and less prone
to errors.

Look into list_box and/or popup_list.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.