Author Topic: User input in scripts?  (Read 3206 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
User input in scripts?
« on: January 19, 2004, 10:28:18 AM »
I use scripts a lot, i don't know how to write lisp programs, and i always get stuck when it comes to user inputs.

i.e. i wish to rotate an attribute value in a rotated block so that the text is rotated to zero, everything in the script goes well until it comes to the select block part, then it pauses, i click on the block and have to type 'resume to get the script going again.

is there an easier way to do this?

Oh while I'm here, can anyone recommend a good book or website which will show me how to write lisp routines as it's getting to the point where it's becoming necessary that i learn how to do it.

cheers :twisted:
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

daron

  • Guest
Re: User input in scripts?
« Reply #1 on: January 19, 2004, 10:51:24 AM »
Quote from: Hudster

Oh while I'm here, can anyone recommend a good book or website which will show me how to write lisp routines as it's getting to the point where it's becoming necessary that i learn how to do it.


Website www.smadsen.com
book: Start at the library.

Craig

  • Guest
Re: User input in scripts?
« Reply #2 on: January 19, 2004, 11:08:28 AM »
Quote from: Hudster
i.e. i wish to rotate an attribute value in a rotated block so that the text is rotated to zero, everything in the script goes well until it comes to the select block part, then it pauses, i click on the block and have to type 'resume to get the script going again.

Here ya go Hudster, this should do what your trying to accomplish:
Code: [Select]
(defun c:rot_attr (/ cmd txt index a1 a2 a2a a3 check_att att_name1);;Rotate all selected blocks attributes to zero
  (setq cmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (prompt "\nSelect blocks to rotate attributes: ")
  (setq a1 (ssget '((0 . "INSERT"))))
  (setq index 0)
  (repeat (sslength a1);;Counts how many blocks were selected and repeats that many times
    (setq a2 (entget (ssname a1 index)));;gets first list from block
    (setq a3 (entget(entnext(cdr(assoc -1 a2)))));;gets sub-list from same block
    (setq check_att (cdr(assoc 0 a3)));;checks to make sure this block has attributes
    (if (= check_att "ATTRIB");;if the block does have attributes
      (progn;;then
(while (/= check_att "SEQEND");;this makes sure the block hasn't reached the sequence end
 (setq att_name1 (cdr(assoc -1 a3)));;gets the name of the block/attribute
 (command "attedit" "" "" "" "" att_name1 "a" "0" "");;rotates attribute to zero
 (setq a3 (entget(entnext(cdr(assoc -1 a3)))));;goes to the next attribute in the block
 (setq check_att (cdr(assoc 0 a3)));;extracts out whether its "ATTRIB" or "SEQEND"
 ;; It keeps looping until all attributes have been extracted and rotated then goes to the
 ;; next selected block and repeats the entire process
 );;end while
);;end progn
      );;end if
    (setq index (+ index 1))
    );;end repeat
  (setvar "CMDECHO" cmd)
  (princ);;clear the command line
  );;end defun rot_attr

SMadsen

  • Guest
Re: User input in scripts?
« Reply #3 on: January 19, 2004, 11:12:28 AM »
Quote from: Daron
Quote from: Hudster

Website www.smadesen.com
book: Start at the library.


That's www.smadsen.com. Thanks for the recommendation, Daron. I'd recommend AfraLisp any time, though! :)

hudster

  • Gator
  • Posts: 2848
User input in scripts?
« Reply #4 on: January 19, 2004, 11:13:34 AM »
Cheers

www.smadesen.com

All I get on this site is a "Page cannot be displayed" message.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

SMadsen

  • Guest
User input in scripts?
« Reply #5 on: January 19, 2004, 11:17:04 AM »
Typo in URL - look in above post

daron

  • Guest
User input in scripts?
« Reply #6 on: January 19, 2004, 11:29:30 AM »
Sorry Stig. I should check my spelling.

hudster

  • Gator
  • Posts: 2848
User input in scripts?
« Reply #7 on: January 27, 2004, 10:40:52 AM »
I've done a bit of checking and user input is possible using a macro function.

If you type \ the macro pauses to allow you to select an item.

So my original query about rotating attributes to zero can be solved by using this macro command

^C^C-attedit;Y;;;;\;a;0;;
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue