Author Topic: Is anyone aware of these?  (Read 5064 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
Is anyone aware of these?
« on: April 30, 2008, 06:10:18 PM »
Code: [Select]
(acet-str-format "\nSpecify layer for new objects [Source/Current] <%1>: " def)Under the express tools you can use acet-str-format and def (in this case) replaces %1. That's cooler than strcat and more like other languages.

I also think these ones could be pretty useful too.
Code: [Select]
(acet-sys-shift-down)   ;call once to initialize
 (acet-sys-control-down)
As long as you have express tools, you can call these functions. If anyone has rolled their own to remove themselves from the Express tools, that's cool too. Mind sharing the how?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Is anyone aware of these?
« Reply #1 on: May 01, 2008, 12:10:14 AM »
As for the acet-str-format Check this out:
http://www.theswamp.org/index.php?topic=5138.0
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Didge

  • Bull Frog
  • Posts: 211
Re: Is anyone aware of these?
« Reply #2 on: May 01, 2008, 04:32:22 AM »
I tend to avoid using 3rd party coding as I find my own coding easier to debug.
For anybody interested, I've attached an excel file listing most of the ACET functions for reference.

I must admit to using the "ACET progress" functions cos they're just too sweet to ignore.

Code: [Select]
(defun c:TEST (/)
  (setq INDX 0 TOTAL 1234567)
  (setq PROG (+ 1 (fix (/ TOTAL 100.0))) )
  (acet-ui-progress-init "Processing stuff:" TOTAL)
  (repeat TOTAL
    (if (= 0 (rem INDX PROG)) (acet-ui-progress-safe INDX))
    (setq INDX (1+ INDX))
  )
  (acet-ui-progress-done)
  (princ)
)

Think Slow......

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Is anyone aware of these?
« Reply #3 on: May 01, 2008, 08:24:35 AM »
I must admit to using the "ACET progress" functions cos they're just too sweet to ignore.

Wouldn't it be nice if they just finally rolled all the ET into core AutoCAD and added the ACET functions into core VLISP?

daron

  • Guest
Re: Is anyone aware of these?
« Reply #4 on: May 01, 2008, 09:19:33 AM »
Yes it would.

daron

  • Guest
Re: Is anyone aware of these?
« Reply #5 on: May 01, 2008, 09:26:29 AM »
Thanks CAB. I hadn't seen that before.

Didge

  • Bull Frog
  • Posts: 211
Re: Is anyone aware of these?
« Reply #6 on: May 01, 2008, 11:27:49 AM »
Quote
Wouldn't it be nice if they just finally rolled all the ET into core AutoCAD and added the ACET functions into core VLISP?

Yes, but on second thoughts, if they made things too easy many of us would be out of jobs.
Think Slow......

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Is anyone aware of these?
« Reply #7 on: May 01, 2008, 11:38:38 AM »
I tend to avoid using 3rd party coding as I find my own coding easier to debug.
For anybody interested, I've attached an excel file listing most of the ACET functions for reference.

I must admit to using the "ACET progress" functions cos they're just too sweet to ignore.

Code: [Select]
(defun c:TEST (/)
  (setq INDX 0 TOTAL 1234567)
  (setq PROG (+ 1 (fix (/ TOTAL 100.0))) )
  (acet-ui-progress-init "Processing stuff:" TOTAL)
  (repeat TOTAL
    (if (= 0 (rem INDX PROG)) (acet-ui-progress-safe INDX))
    (setq INDX (1+ INDX))
  )
  (acet-ui-progress-done)
  (princ)
)


holy crap, thanks for the excel file didge.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

daron

  • Guest
Re: Is anyone aware of these?
« Reply #8 on: May 01, 2008, 04:49:45 PM »
As for the acet-str-format Check this out:
http://www.theswamp.org/index.php?topic=5138.0

With that in mind I took it as a challenge to create one. When I posted this I hadn't even considered how you'd go about doing it. With the above I haven't studied any of the code, but came up with one based off of getting a gist of how they work. Here's my version.
Code: [Select]
;;;=============================================================;
;;; string format ;
;;;-------------------------------------------------------------;
;;; formats a string similar to that of python or other langs.  ;
;;; ex. (str-format "%4 %3 %2 %1 said %1 %2 %3 %4" ;
;;; '("this" 5 "is a tricky" 0.25) ;
;;;-------------------------------------------------------------;
;;;returns: "0.25 is a tricky 5 this said this 5 is a tricky...";
;;;-------------------------------------------------------------;
;;; Author: Daron Rogers 2008 ;
;;; Version: 0.1A ;
;;;_____________________________________________________________;
;;; Requirements: format number will start at 1 and continue ;
;;; for length of strlst. Ensure %n starts at 1 and ends at len.;
;;; Program will not crash, but it will not pass desired output ;
;;;_____________________________________________________________;
(defun str-format (str strlst / amt strlst str dtpr)
   (setq amt (length strlst)
strlst
   (mapcar
      '(lambda (x)
  (cond ((= (type x) 'real)
(rtos x 2 2)
)
((= (type x) 'int)
(itoa x)
)
((= (type x) 'str)
x
)
  )
       )
      strlst
   )
   );ensures all items in list are string
   (while (> amt 0)
      (setq dtpr (cons
    (cons
       (strcat "%" (itoa amt))
       (nth (1- amt) strlst)
    )
    dtpr
)
    amt (1- amt)
      )
   ) ;creates dotted pair list ex. (("%1" . "string") ("%2" . "0.55"))
   (mapcar
      '(lambda (x)
  (while (vl-string-search (car x) str)
     (setq str (vl-string-subst (cdr x) (car x) str))
  )
       )
      dtpr
   )
   str
)

taner

  • Guest
Re: Is anyone aware of these?
« Reply #9 on: May 04, 2008, 07:49:02 PM »
Code: [Select]
;;;Below is my string format function
(defun th-str-format (str newstrlst / n oldstr oldstrlst)
  (setq n 0)
  (setq oldstrlst (mapcar
    (function (lambda (x)
(setq n (1+ n)
      oldstr (strcat "$" (rtos n 2 0) "#")
)
      )
    )
    newstrlst
  )
  )
  (mapcar
    (function (lambda (a b)
(setq str (th-str-repl a b str))
      )
    )
    oldstrlst
    newstrlst
  )
  str
)
(defun th-str-repl (curchar newchar str)
  (while (vl-string-search curchar str)
    (setq str (vl-string-subst newchar curchar str))
  )
  str
)
;;;test as below
;;; Command: (th-str-format "\ncollecting all $1# objects on layer $2#..." (list
;;;"12" "23"))
;;;"\ncollecting all 12 objects on layer 23..."
;;;
;;;Command: (th-str-format "\ncollecting all $1# objects on layer $2#..." (list
;;;"12" "23" "45"))
;;;"\ncollecting all 12 objects on layer 23..."
;;;
;;;Command: (th-str-format "\ncollecting all $1# ob$1#jects on layer $2#..." (list
;;;"12" "23"))
;;;"\ncollecting all 12 ob12jects on layer 23..."
;;;
;;;Command: (th-str-format "\ncollecting all $1# objects $3#on layer $2#..." (list
;;;"12" "23" "ab"))
;;;"\ncollecting all 12 objects abon layer 23..."

« Last Edit: May 04, 2008, 08:00:05 PM by taner »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Is anyone aware of these?
« Reply #10 on: May 04, 2008, 08:23:36 PM »
I just modified Will's to allow any number of replacements.
http://www.theswamp.org/index.php?topic=5138.msg62320#msg62320

Code: [Select]
;;  by Will modified by CAB
(defun str-format (str lst / r)
  (mapcar '(lambda (x y)
    (while (vl-string-search y str 0)
      (setq str (vl-string-subst x y str))
    )
  )
lst
(progn  ; CAB
           (setq idx (1+(length lst)))
           (while (not(zerop(setq idx (1- idx))))
           (setq r (cons (strcat "%" (itoa idx)) r)))
           r
)
  )
  str
)


Usage:
(str-format "This is for %1 and you." '("me"))
"This is for me and you."

(str-format "This is for %2 and %1." '("you" "us"))
"This is for us and you."

(str-format "This is %3 for %2 and %1." '("our" "them" "not"))
"This is not for them and our."
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
Re: Is anyone aware of these?
« Reply #11 on: May 05, 2008, 09:29:46 AM »
Very nice, guys.

Bob Q

  • Guest
Re: Is anyone aware of these?
« Reply #12 on: May 23, 2012, 12:18:51 PM »
Thanks for the progress stuff, I didn't understand what it did but ran it, and it shows the progress bar, very nice!

Now how could we do something like this for something that will run for an indeterminate amount of iterations?

  :-D

GDF

  • Water Moccasin
  • Posts: 2081
Re: Is anyone aware of these?
« Reply #13 on: May 23, 2012, 05:53:19 PM »
I tend to avoid using 3rd party coding as I find my own coding easier to debug.
For anybody interested, I've attached an excel file listing most of the ACET functions for reference.

I must admit to using the "ACET progress" functions cos they're just too sweet to ignore.

Code: [Select]
(defun c:TEST (/)
  (setq INDX 0 TOTAL 1234567)
  (setq PROG (+ 1 (fix (/ TOTAL 100.0))) )
  (acet-ui-progress-init "Processing stuff:" TOTAL)
  (repeat TOTAL
    (if (= 0 (rem INDX PROG)) (acet-ui-progress-safe INDX))
    (setq INDX (1+ INDX))
  )
  (acet-ui-progress-done)
  (princ)
)


holy crap, thanks for the excel file didge.

I have used this one before...very nice.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Is anyone aware of these?
« Reply #14 on: May 25, 2012, 07:49:15 AM »
Now how could we do something like this for something that will run for an indeterminate amount of iterations?

  ;D
I don't think it's possible, all these progress bars would require a minimum & maximum value or a ratio or a percentage. They simply draw the progress bar filled to the current position relative to the full position.

If you don't want to use a 3rd party one, and cannot use the Express tools version (for whatever reason) - you could try my text based progress bar:
Code - Auto/Visual Lisp: [Select]
  1. ;;; Simulate a progress bar in the status bar's mode area.
  2. ;;; msg = A string to be displayed with the progress bar in the status area.
  3. ;;; n   = A ratio from 0.0 to 1.0 to set how far the progress bar indicates,
  4. ;;;       if nil then remove the progress bar.
  5. (defun ProgressBar  (msg n / l i s)
  6.   (if n
  7.     (progn ;; Get the mode tile's length
  8.            (setq l (- (atoi (menucmd "M=$(linelen)")) (strlen msg)))
  9.            ;; Get the numnber of characters simulating the number n (0.0= none, 1.0=all)
  10.            (setq i (fix (* l n)))
  11.            (repeat l
  12.              (if (> (setq i (1- i)) 0)
  13.                (setq s (cons 33 s))
  14.                (setq s (cons 46 s))))
  15.            (grtext -1 (strcat msg (vl-list->string (reverse s)))))
  16.     (grtext -1 msg)))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.