Jump to content

Recommended Posts

Posted (edited)

Hi guys!

 

Please help me with a small issue. For you it's really child's play.

I made the following script and i want to turn it into a .lsp thru the "command" syntax (defun c:123()(command "zoom"......), but i have an error because the qoutation marks from the ssget function are misinterpreted when running the routine.

 

.......

 

Z
E
select
(setq ss (ssget "X" '((0 . "*TEXT")(62 . 7))))

TTT

 

.......

 

Any help will be highly appreciated.

 

 

 

Edited by Nick24
Posted

If I understand you correctly, want to zoom to all your text with a color index of 7?

 

If that is the case this should work for you:

(defun c:abc123 (/ ss)
(if (setq ss (ssget "X" '((0 . "*TEXT")(62 . 7))))
    (progn
        (command "zoom")
        (mapcar 'command (acet-geom-ss-extents ss 1)))))

 

  • Like 1
Posted (edited)
2 hours ago, WHM said:

If I understand you correctly, want to zoom to all your text with a color index of 7?

 

If that is the case this should work for you:


(defun c:abc123 (/ ss)
(if (setq ss (ssget "X" '((0 . "*TEXT")(62 . 7))))
    (progn
        (command "zoom")
        (mapcar 'command (acet-geom-ss-extents ss 1)))))

 


Thanks for the answer!

 

Actually what the script does is zoom extents -> select all texts with colour 7 and then with a custom function (TTT) it exports selected texts to an Excel sheet.

It worked great till now, but i want to run these commands all at once within a lisp routine.

Edited by Nick24
Posted (edited)
;;----------------------------------------------------------------------;;
;Zoom Extents and TTT command
(defun C:ZE (/ SS)
  (command "_.Zoom" "E")
  (if (setq ss (ssget "X" '((0 . "*TEXT")(62 . 7))))
    (C:TTT)
  )
)

To call other commands inside of a lisp you just have to wrap it with ( )

this will zoom extents and then make a selection set SS of all text and mtext that are color 7. if their is text that match that it will run TTT command.

if TTT doesn't use SS for the selection set rename the variable to what ever TTT uses.

 

or if TTT can handle all the selecting the text you just need.

;;----------------------------------------------------------------------;;
;Zoom Extents and TTT command
(defun C:ZE (/)
  (command "_.Zoom" "E")
  (C:TTT)
)

 

Edited by mhupp
Posted (edited)
12 hours ago, mhupp said:

;;----------------------------------------------------------------------;;
;Zoom Extents and TTT command
(defun C:ZE (/ SS)
  (command "_.Zoom" "E")
  (if (setq ss (ssget "X" '((0 . "*TEXT")(62 . 7))))
    (C:TTT)
  )
)

To call other commands inside of a lisp you just have to wrap it with ( )

this will zoom extents and then make a selection set SS of all text and mtext that are color 7. if their is text that match that it will run TTT command.

if TTT doesn't use SS for the selection set rename the variable to what ever TTT uses.

 


or if TTT can handle all the selecting the text you just need.

;;----------------------------------------------------------------------;;
;Zoom Extents and TTT command
(defun C:ZE (/)
  (command "_.Zoom" "E")
  (C:TTT)
)

 

Thanks for the answer!

 

Your routine is almost what i need, only thing is that it does not select the text i want. See below screenshot. It stops before selecting the text. I assume there's a problem with ssget function. I can attach TTT function if needed.

Capture.JPG

Edited by Nick24
Posted

It would help. just to see how its handling the selection of text.

Posted
1 minute ago, mhupp said:

It would help. just to see how its handling the selection of text.

 

Please see below.

 

In principal, i want it to zoom extents => select all texts with colour 7 => run TTT command. If you know other way to achieve this , other then what i pointed to, it's just as good.

 

Thanks again! 

 

(defun LM:writecsv ( lst csv / des sep )
(if (setq des (open csv "w"))
(progn
(setq sep (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList")) (",")))
(foreach row lst (write-line (LM:lst->csv row sep) des))
(close des)
t
)
)
)
(defun LM:lst->csv ( lst sep )
(if (cdr lst)
(strcat (LM:csv-addquotes (car lst) sep) sep (LM:lst->csv (cdr lst) sep))
(LM:csv-addquotes (car lst) sep)
)
)

(defun LM:csv-addquotes ( str sep / pos )
(cond
( (wcmatch str (strcat "*[`" sep "\"]*"))
(setq pos 0)
(while (setq pos (vl-string-position 34 str pos))
(setq str (vl-string-subst "\"\"" "\"" str pos)
pos (+ pos 2)
)
)
(strcat "\"" str "\"")
)
( str )
)
)

(defun C:ttt(/ lst ss i el x fn)
(setq lst (list) ss (ssget (list (cons 0 "TEXT"))) )
(repeat (setq i (sslength ss))
(setq x (ssname ss (setq i (1- i))))
(setq el (entget x))
(if (= (cdr (assoc 0 el)) "TEXT")
(setq lst (append lst (list (list (cdr (assoc 1 el))))))
)
)
(setq fn (vl-filename-mktemp nil nil ".csv"))
(if (and lst (LM:WriteCSV (reverse lst) fn))
(startapp "explorer" fn)
)
)

Posted

Change  the following in your lisp

 

(setq lst (list) ss (ssget (list (cons 0 "TEXT"))) )

to

(setq lst (list) ss (ssget "X" '((0 . "*TEXT")(62 . 7)))) ;this wont prompt to select objects b/c it selects everthing then filters down to text that are color 7

and then use the following

;;----------------------------------------------------------------------;;
;Zoom Extents and TTT command
(defun C:ZET (/)
  (command "_.Zoom" "E")
  (C:TTT)
)

I don't think this will work if the text you are trying to select are in blocks.

Posted
50 minutes ago, mhupp said:

Change  the following in your lisp

 


(setq lst (list) ss (ssget (list (cons 0 "TEXT"))) )

to

(setq lst (list) ss (ssget "X" '((0 . "*TEXT")(62 . 7)))) ;this wont prompt to select objects b/c it selects everthing then filters down to text that are color 7

and then use the following

;;----------------------------------------------------------------------;;
;Zoom Extents and TTT command
(defun C:ZET (/)
  (command "_.Zoom" "E")
  (C:TTT)
)

I don't think this will work if the text you are trying to select are in blocks.

 

Unfortunately, the result is the same. It still stops at selecting texts and asks me to select what i want before proceeding with TTT command.

 

PS: No texts are in blocks. 

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