Jump to content

Gap Dcl in Block list


Recommended Posts

Posted

Hi Sir,

how to gap betwwen main block and nested block in dcl 

  ;-----------------------------------------------


  (cond 
    ((null (setq lst (vl-sort lst '<)))
     (princ "\nNo blocks found in drawing.")
    )

    ((null 
       (and 
         (setq tmp (vl-filename-mktemp nil nil ".dcl"))
         (setq des (open tmp "w"))
         (foreach line 
           (list 
             (strcat "blockpreview : dialog { label = \"" datetitle "\";") ;; Title with date-time
             "  spacer;"
             "  : row {"
             "    : boxed_column { label = \"Block List\"; width = 35; fixed_width = true;"
             "      : list_box { key = \"lst\"; height = 15; fixed_height = true; }"
             "    }"
             "    spacer;"
             "    : boxed_column { label = \"Preview\"; width = 35; fixed_width = true;"
             "      : image { key = \"img\"; height = 15; fixed_height = true; }"
             "    }"
             "  }"
             "  spacer;"
             "  : image { color = 30; width = 50; height = 0.5; alignment = centered; }" ;; Orange line
             "  spacer;"
             "  : boxed_column { label = \"Block Tools\";" ;; Single box around ALL buttons
             "    : row {"
             "      : button { key = \"cbp_btn\"; label = \"Change Base Point\"; }"
             "      : button { key = \"cbpr_btn\"; label = \"Change Base Point (Ref)\"; }"
             "    }"
             "    spacer;"
             "    : row {"
             "      : button { key = \"rename_btn\"; label = \"Rename\"; is_default = true; }"
             "      : button { key = \"select_btn\"; label = \"Select Block\"; }"
             "      : button { key = \"cancel\"; label = \"Cancel\"; is_cancel = true; }"
             "      : button { key = \"about\"; label = \"About\"; }"
             "    }"
             "  }"
             "  spacer;"
             "  : text { label = \"Author: XYZ | https://abcd.com/\"; alignment = centered; }"
             "}"
           )
           (write-line line des)
         )
         (not (setq des (close des)))
         (< 0 (setq dcl (load_dialog tmp)))
         (new_dialog "blockpreview" dcl)
       )
     )
     (princ "\nUnable to load dialog.")
    )

    ;------------------------------------------------

 

DCL.jpg

Posted

One way, might be the easiest is to change the list that populates 'Block List', adding spaces to the nested block

 

 

So you might have a line like this in your LISP:

 

(start_list "lst" 3)(mapcar 'add_list BlockList)(end_list)

 

Where BlockList is your list of block, might be

 

(setq BlockList (list "BLOCK-1" "BLK-1" "BLK-2"... "BLOCK-2"))

 

Which you could change to be

 

(setq BlockList (list "BLOCK-1" "   BLK-1" "   BLK-2"... "BLOCK-2"))

 

 

 

I don't think you can do the indenting with DCL, has to be done before then.

 

  • Like 1
Posted

Use the DCL tabs attribute and prefix the list items with a tab character ("\t").

  • Like 2
Posted

I didn't know you could do that!

 

 

Still need to add the tabs \t to the base list, but you'd get a better result I think

 

Posted
4 hours ago, Steven P said:

I didn't know you could do that!

 

 

Still need to add the tabs \t to the base list, but you'd get a better result I think

 

 

I use the technique frequently to achieve list box columns - for example, as used by the Content Builder dialog displayed by my Incremental Numbering Suite.

  • Like 2
Posted

Sir 

 

\t not working 

 

  ;; Collect block names
  (setq lst nil)
  (while (setq def (tblnext "BLOCK" (null def))) 
    (if 
      (and 
        (= 0 (logand 125 (cdr (assoc 70 def))))
        (not (wcmatch (cdr (assoc 2 def)) "`_*,`**,*|*"))
      )
      (setq lst (cons (cdr (assoc 2 def)) lst))
    )
  )

  ;-----------------------------------------------DCL


  (cond 
    ((null (setq lst (vl-sort lst '<)))
     (princ "\nNo blocks found in drawing.")
    )

    ((null 
       (and 
         (setq tmp (vl-filename-mktemp nil nil ".dcl"))
         (setq des (open tmp "w"))
         (foreach line 
           (list 
             (strcat "blockpreview : dialog { label = \"" datetitle "\";") ;; Title with date-time
             "  spacer;"
             "  : row {"
             "    : boxed_column { label = \"Block List\"; width = 35; fixed_width = true;"
             "      : list_box { key = \"lst\"; height = 15; fixed_height = true; }"
             "    }"
             "    spacer;"
             "    : boxed_column { label = \"Preview\"; width = 35; fixed_width = true;"
             "      : image { key = \"img\"; height = 15; fixed_height = true; }"
             "    }"
             "  }"
             "  spacer;"
             "  : image { color = 30; width = 50; height = 0.5; alignment = centered; }" ;; Orange line
             "  spacer;"
             "  : boxed_column { label = \"Block Tools\";" ;; Single box around ALL buttons
             "    : row {"
             "      : button { key = \"cbp_btn\"; label = \"Change Base Point\"; }"
             "      : button { key = \"cbpr_btn\"; label = \"Change Base Point (Ref)\"; }"
             "    }"
             "    spacer;"
             "    : row {"
             "      : button { key = \"rename_btn\"; label = \"Rename\"; is_default = true; }"
             "      : button { key = \"select_btn\"; label = \"Select Block\"; }"
             "      : button { key = \"cancel\"; label = \"Cancel\"; is_cancel = true; }"
             "      : button { key = \"about\"; label = \"About\"; }"
             "    }"
             "  }"
             "  spacer;"
             "  : text { label = \"Author: XYZ | https://abcd.com/\"; alignment = centered; }"
             "}"
           )
           (write-line line des)
         )
         (not (setq des (close des)))
         (< 0 (setq dcl (load_dialog tmp)))
         (new_dialog "blockpreview" dcl)
       )
     )
     (princ "\nUnable to load dialog.")
    )

    ;----------------------------------------------------------------------------
    (t
     (start_list "lst")
     (foreach x lst (add_list x))
     (end_list)

     (set_tile "lst" "0")
     (setq blkname (car lst))
     (_blockpreview blkname)

     (action_tile 
       "lst"
       "(setq blkname (nth (atoi $value) lst)) (_blockpreview blkname)"
     )
     (action_tile "rename_btn" "(done_dialog 2)")
     (action_tile "select_btn" "(done_dialog 3)")
     (action_tile "cbp_btn" "(done_dialog 4)")
     (action_tile "cbpr_btn" "(done_dialog 5)")
     (action_tile "cancel" "(done_dialog 0)")
     (action_tile "about" "(startapp \"explorer\" \"https://ABCD.COM/\")")

     (setq response (start_dialog))

     (cond 
       ((= response 2) (RENB blkname))
       ((= response 3)
        (princ "\nSelect a block reference in the drawing.")
        (if (and (setq ent (car (entsel))) (= "INSERT" (cdr (assoc 0 (entget ent))))) 
          (progn (setq blkname (cdr (assoc 2 (entget ent)))) (RENB blkname))
          (princ "\nInvalid selection.")
        )
       )
       ((= response 4) (LM:changeblockbasepoint nil))
       ((= response 5) (LM:changeblockbasepoint t))
     )
    )
  )

  (*error* nil)
  (princ)
)

 

dcl2.jpg

Posted

Where have you added the tab character "\t"?

Where did you add the tabs attribute?

Posted (edited)

sorry wrongly code posted 

  (cond 
    ((null (setq lst (vl-sort lst '(lambda (a b) (< (car a) (car b))))))
     (princ "\nNo blocks found in drawing.")
    )

    ((null (and
      (setq tmp (vl-filename-mktemp nil nil ".dcl"))
      (setq des (open tmp "w"))
      (foreach line 
        (list 
          (strcat "blockpreview : dialog { label = \"" datetitle "\";")
          "  spacer;"
          "  : row {"
          "    : boxed_column { label = \"Block List\"; width = 35; fixed_width = true;"
          "      : list_box { key = \"lst\"; height = 15; fixed_height = true; tabs = \"20 8\"; }"
          "    }"
          "    spacer;"
          "    : boxed_column { label = \"Preview\"; width = 35; fixed_width = true;"
          "      : image { key = \"img\"; height = 15; fixed_height = true; }"
          "    }"
          "  }"
          "  spacer;"
          "  : image { color = 30; width = 50; height = 0.5; alignment = centered; }"
          "  spacer;"
          "  : boxed_column { label = \"Block Tools\";"
          "    : row {"
          "      : button { key = \"cbp_btn\"; label = \"Change Base Point\"; }"
          "      : button { key = \"cbpr_btn\"; label = \"Change Base Point (Ref)\"; }"
          "    }"
          "    spacer;"
          "    : row {"
          "      : button { key = \"rename_btn\"; label = \"Rename\"; is_default = true; }"
          "      : button { key = \"select_btn\"; label = \"Select Block\"; }"
          "      : button { key = \"cancel\"; label = \"Cancel\"; is_cancel = true; }"
          "      : button { key = \"about\"; label = \"About\"; }"
          "    }"
          "  }"
          "  spacer;"
          "  : text { label = \"Author: xyz | https://abcd.com/\"; alignment = centered; }"
          "}"  ;; 
        )
        (write-line line des))
      (not (setq des (close des)))
      (< 0 (setq dcl (load_dialog tmp)))
      (new_dialog "blockpreview" dcl)
    ))
     (princ "\nUnable to load dialog.")
    )

    (t
     (start_list "lst")
     (foreach x lst 
       (add_list (strcat (car x) "\t" (cadr x))) ; Tab-separated entry
     )
     (end_list)

     (set_tile "lst" "0")
     (setq blkname (caar lst))
     (_blockpreview blkname)

 

.....

     "    : boxed_column { label = \"Block List\"; width = 35; fixed_width = true;"
          "      : list_box { key = \"lst\"; height = 15; fixed_height = true; tabs = \"20 8\"; }"
          "    }"

;----------------------------------------------------------------
(t
     (start_list "lst")
     (foreach x lst 
       (add_list (strcat (car x) "\t" (cadr x))) ; Tab-separated entry
     )
     (end_list)

 

 

Edited by sachindkini

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