Draw polyline with one shape at one end and another shape at the opposite end

Draw polyline with one shape at one end and another shape at the opposite end

Homecad2007
Enthusiast Enthusiast
2,618 Views
22 Replies
Message 1 of 23

Draw polyline with one shape at one end and another shape at the opposite end

Homecad2007
Enthusiast
Enthusiast

Hi there, is is possible to draw a polyline with a rectanlge at the start or end and lets say a circle at the opposite end.  I am trying to use it for a schematic drawing, shapes could differ but I would be ok with a rectangle and circle for starters.  If anyone knows how to even start something like this or examples of similar it would be appreciated.

 

Thanks

Tony

0 Likes
Accepted solutions (3)
2,619 Views
22 Replies
Replies (22)
Message 21 of 23

Sea-Haven
Mentor
Mentor

Had some time so did a front end. Note tested in Bricscad and Acad. 

 

It is front end only not intergrated into Kents excellent code. It returns radio button circle 1 & 2 as 0 or 1 if 1 its selected. The next 4 values are returned in a list (radorlen1 ht1 radorlen2 ht2) obviously the ht is ignored if the button is "Circle"

 

 

; a left right input dcl with options
; By Alan H Dec 2020
; info@alanh.com.au

(defun AH:getvalrad (/ x y num fo fname lst)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
(write-line "ddgetvalAH3 : dialog {" fo)
(write-line " label =  \"Block ends\"   ;" fo)
(write-line " : row 	{" fo)
(write-line " : column 	{" fo)
(write-line " label =  \"LEFT \" ;" fo)
(write-line "spacer_1 ;" fo)
(write-line " : radio_column  {" fo)
(write-line " width = 25;" fo)
(write-line " label =  \"Circle or Squares \" ;" fo)
(write-line "spacer_1 ;" fo)
(write-line " : radio_button {" fo)
(write-line  "key =  \"Rb1\"  ;" fo)
(write-line  "label = \"Circle\" ;" fo)
(write-line " }" fo)
(write-line "spacer_1 ;" fo)
(write-line " : radio_button {" fo)
(write-line  "key =  \"Rb2\"  ;" fo)
(write-line  "label = \"Square\" ;" fo)
(write-line " }" fo)
(write-line " }" fo)
(write-line "spacer_1 ;" fo)
(write-line " : column 	{" fo)
(write-line " width = 25;" fo)
(write-line " label = \"Enter sizes\" ; " fo)
(write-line ": edit_box {" fo)
(write-line " key = \"Key1\" ;" fo)
(write-line " label = \"Length or rad\" ;" fo)
(write-line " edit_width = 5 ;" fo)
(write-line " edit_limit = 4 ;" fo)
(write-line "   allow_accept = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line " key = \"Key2\" ;" fo)
(write-line " label = \"Height\" ;" fo)
(write-line " edit_width = 5 ;" fo)
(write-line " edit_limit = 4 ;" fo)
(write-line "   allow_accept = true ;" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line " : column 	{" fo)
(write-line " label =  \"RIGHT \" ;" fo)
(write-line "spacer_1 ;" fo)
(write-line " : radio_column  {" fo)
(write-line " width = 25;" fo)
(write-line " label =  \"Circle or Squares \" ;" fo)
(write-line "spacer_1 ;" fo)
(write-line " : radio_button {" fo)
(write-line  "key =  \"Rb3\"  ;" fo)
(write-line  "label = \"Circle\" ;" fo)
(write-line " }" fo)
(write-line "spacer_1 ;" fo)
(write-line " : radio_button {" fo)
(write-line  "key =  \"Rb4\"  ;" fo)
(write-line  "label = \"Square\" ;" fo)
(write-line " }" fo)
(write-line " }" fo)
(write-line "spacer_1 ;" fo)
(write-line " : column 	{" fo)
(write-line " width = 25;" fo)
(write-line " label = \"Enter sizes\" ; " fo)
(write-line ": edit_box {" fo)
(write-line " key = \"Key3\" ;" fo)
(write-line " label = \"Length or rad\" ;" fo)
(write-line " edit_width = 5 ;" fo)
(write-line " edit_limit = 4 ;" fo)
(write-line "   allow_accept = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line ": edit_box {" fo)
(write-line " key = \"Key4\" ;" fo)
(write-line " label = \"Height\" ;" fo)
(write-line " edit_width = 5 ;" fo)
(write-line " edit_limit = 4 ;" fo)
(write-line "   allow_accept = true ;" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_only ; }" fo)
(close fo)
(setq dcl_id (load_dialog fname))
(if (not (new_dialog "ddgetvalAH3" dcl_id))
(exit)
)
(setq lst (list "Key1" "Key2" "Key3" "Key4"))
(if (= radlen nil)(setq radlen (list 100 100 100 100)))
(if (or (= Rb1 nil)(= Rb1 "1"))(set_tile "Rb1" "1")(set_tile "Rb2" "1"))
(if (or (= Rb3 nil)(= Rb3 "1"))(set_tile "Rb3" "1")(set_tile "Rb4" "1"))
(setq x 0)
(repeat 4
       (set_tile (nth x lst) (rtos (nth x  radlen)2 0))
	   (setq x (+ x 1))
)
(setq radlen '())

(action_tile "accept" 
	  "(setq Rb1 (get_tile \"Rb1\"))
      (setq Rb3 (get_tile \"Rb3\"))
      (mapcar '(lambda (y) (setq radlen (cons (atof (get_tile y)) radlen))) lst )
	  (done_dialog)")
	  
(start_dialog)
(unload_dialog dcl_id)
(vl-file-delete fname)
(setq  radlen (reverse radlen))
(princ)
)
(AH:getvalrad)

 

 

 

0 Likes
Message 22 of 23

Kent1Cooper
Consultant
Consultant
Accepted solution

@Kent1Cooper wrote:

@Homecad2007 wrote:

Is it possible to make the segment all one so that if you erase it the entire segment is selected.  ....


It could be made to put the three pieces together into ... a Group .... I'll look into it ....


Here's the revised version that does that.  I also added *error* handling, and Undo begin/end wrapping, and other little controls.  And I changed the definitions of the Blocks so that their insertion points go on the endpoints of the Polylines, which simplified the insertion points in the Insert commands, but also means you can change scale factors and they'll still lie correctly at the ends.  AND, as an illustration of the possibility of additional shapes, I added a Diamond shape.  It now draws these kinds of things:

Kent1Cooper_0-1609166849567.png

[Currently, the size option for the Diamond shape asks for one size, as with the Circle diameter, for a rotated-square shape only, but it could be altered to let you have the Diamond in different proportions, as with the Rectangle.  For that matter, the Circle could also allow different scale factors and make elliptical shapes.]

Kent Cooper, AIA
Message 23 of 23

Homecad2007
Enthusiast
Enthusiast

Thanks Kent, works great

0 Likes