TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jlogan02 on December 19, 2019, 07:17:55 PM

Title: More dimscale please
Post by: jlogan02 on December 19, 2019, 07:17:55 PM
How would I include a filter for text objects found on "X" layers located at pt1 and pt2?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo4 ( / dim pt1 pt2)
  2.  
  3.    pt1 '(33.375 21.4375);;revision text
  4.         pt2 '(31.875 5.3125);;revision text
  5. )
  6.  
  7. (setq dim (getvar 'dimscale)
  8.         pt1 (mapcar '* pt1 (list dim dim))
  9.         pt2 (mapcar '* pt2 (list dim dim))
  10. )
  11.  
  12. ;;need combine a filter for all TEXT layers with pt1 pt2
  13. ;;something like ????
  14. (setq rev1 (ssget "C" (list pt1 pt2) ((8 . "Text*")))
  15.  
  16. (command "._change" rev1 "" "p" "la" "TBLK_TBLK_REVTEXT" "")
  17.  
  18.   (princ)
  19. )
  20.  
  21. )
Title: Re: More dimscale please
Post by: ribarm on December 20, 2019, 08:31:38 AM
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo4 ( / dim pt1 pt2 pt1n pt2n rev1 rev2 )
  2.  
  3.   (setq
  4.      pt1 '(33.375 21.4375) ;;; revision text
  5.      pt2 '(31.875 5.3125) ;;; revision text
  6.   )
  7.   ;|
  8.   (setq dim (getvar 'dimscale)
  9.         pt1 (mapcar '* pt1 (list dim dim)) ;;; I am not sure what do you meant with this...
  10.         pt2 (mapcar '* pt2 (list dim dim)) ;;; I am not sure what do you meant with this...
  11.   )
  12.   |;
  13.   (setq dim (getvar 'dimscale)
  14.         pt1n (mapcar '+ pt1 (list dim dim)) ;;; Maybe this is what you wanted, but not sure either...
  15.         pt2n (mapcar '+ pt2 (list dim dim)) ;;; Maybe this is what you wanted, but not sure either...
  16.   )
  17.  
  18.   (setq rev1 (ssget "_C" (list pt1 pt1n) '((0 . "*TEXT")))) ;;; first sel set with point pt1 (entities could be TEXT or MTEXT on any layer)
  19.   (setq rev2 (ssget "_C" (list pt2 pt2n) '((0 . "*TEXT")))) ;;; second sel set with point pt2 (entities could be TEXT or MTEXT on any layer)
  20.  
  21.   (command "_.CHANGE" rev1 "" "_P" "_LA" "TBLK_TBLK_REVTEXT" "")
  22.   (command "_.CHANGE" rev2 "" "_P" "_LA" "TBLK_TBLK_REVTEXT" "")
  23.  
  24.   (princ)
  25. )
  26.  
Title: Re: More dimscale please
Post by: ronjonp on December 20, 2019, 09:19:21 AM
Remember too that these text objects need to be visible on the screen for this to work.
Title: Re: More dimscale please
Post by: jlogan02 on December 20, 2019, 07:24:10 PM
I see why that was confusing. I posted the wrong code.
This is what I currently us

Code - Auto/Visual Lisp: [Select]
  1. (if (and (= (getvar 'dimscale) 8)
  2.   (setq rev1 (ssget "c" '(268.5 171.0) '(254.25 42.125) '((8 . "Text*"))))
  3.   )
  4.    (command "._change" rev1 "" "p" "la" "TBLK_TBLK_REVTEXT" "")
  5.   (and (setq rev1 (ssget "c" '(33.375 21.4375) '(31.875 5.375) '((8 . "Text*"))))
  6.         (command "._change" rev1 "" "p" "la" "TBLK_TBLK_REVTEXT" "")
  7.         )
  8. )
  9.  

We use model space with multiple scaled title blocks. The above code demonstrates how I handle changes to the area specified by the ssget "c" in a
1 1/2" = 1'-0" drawing. If it's not a dimscale of 8 then it's got to be dimscale 1.0. For now I'm only addressing these two title blocks. I would like to expand that to address all 12 of our title blocks.

The code below is closer to what I have in mind.

Code - Auto/Visual Lisp: [Select]
  1.  
  2.   (setq lst '((31.875 5.3125) (33.375 21.4375)))
  3.   (setq dim (getvar 'dimscale) lst (mapcar '(lambda (x) (mapcar '* x (list dim dim))) lst))
  4.   (setq rev1 (ssget (cons "_C" lst) '((8 . "TEXT*"))));;;my issue is here, I'm pretty sure. I just don't know why.
  5.  
  6.   do stuff here....
  7.  
  8.  


 

Title: Re: More dimscale please
Post by: jlogan02 on December 20, 2019, 07:26:01 PM
Yes Ron. Thanks for that. I have that set in the larger code. Actually I think we may have discussed that in a prior post about roughly the same thing I'm trying to do here.

Remember too that these text objects need to be visible on the screen for this to work.
Title: Re: More dimscale please
Post by: BIGAL on December 20, 2019, 10:18:14 PM
Change to layouts and all your title block problems will go away.
Title: Re: More dimscale please
Post by: ribarm on December 21, 2019, 05:30:38 AM
Code - Auto/Visual Lisp: [Select]
  1.   ...
  2.   (setq rev1 (ssget (cons "_C" lst) '((8 . "TEXT*"))));;;my issue is here, I'm pretty sure. I just don't know why.
  3.  
  4.   do stuff here....
  5.  

Code - Auto/Visual Lisp: [Select]
  1.   ...
  2.   (setq rev1 (append (cons 'ssget (cons "_C" lst)) '(((8 . "TEXT*")))))
  3.  
  4.   do stuff here....
  5.  
Title: Re: More dimscale please
Post by: Lee Mac on December 21, 2019, 08:19:54 AM
Code - Auto/Visual Lisp: [Select]
  1.   ...
  2.   (setq rev1 (ssget (cons "_C" lst) '((8 . "TEXT*"))));;;my issue is here, I'm pretty sure. I just don't know why.
  3.  
  4.   do stuff here....
  5.  

Code - Auto/Visual Lisp: [Select]
  1.   ...
  2.   (setq rev1 (append (cons 'ssget (cons "_C" lst)) '(((8 . "TEXT*")))))
  3.  
  4.   do stuff here....
  5.  

Or just:
Code - Auto/Visual Lisp: [Select]
  1. (setq rev1 (ssget "_C" lst '((8 . "TEXT*"))))
Title: Re: More dimscale please
Post by: ribarm on December 21, 2019, 08:31:51 AM
Yes Lee, I haven't noticed that... It was already correctly posted before, but I was seduced by OP's code...
Title: Re: More dimscale please
Post by: jlogan02 on December 24, 2019, 05:14:41 PM
Here's the full code with Lee's last suggestion.

Code - Auto/Visual Lisp: [Select]
  1. (defun Rev_Up ( / DIM DIM1 OSM REV1 REV2 X)
  2.   (defun _addlayer (name color ltype plot)
  3.     (cond ((not (tblsearch "layer" name))
  4.            (entmakex (list '(0 . "LAYER")
  5.                            '(100 . "AcDbSymbolTableRecord")
  6.                            '(100 . "AcDbLayerTableRecord")
  7.                            '(70 . 0)
  8.                            (cons 2 name)
  9.                            (cons 62 color)
  10.                            (cons 6
  11.                                  (cond ((tblobjname "ltype" ltype))
  12.                                        ("continuous")
  13.                                  )
  14.                            )
  15.                            (cons 290 plot)
  16.                            ;;1 = plottable 0 = not=plottable
  17.                      )
  18.            )
  19.           )
  20.           ((tblobjname "layer" name))
  21.     )
  22.   )
  23.  
  24.   (setvar 'osmode 0)
  25.   (setvar 'cmdecho 0)
  26.  
  27.   (command "Zoom" "E")
  28.  
  29.   (setq lst '((31.875 5.3125) (33.375 21.4375)))
  30.   (setq dim (getvar 'dimscale) lst (mapcar '(lambda (x) (mapcar '* x (list dim dim))) lst))
  31.   (setq rev1 (ssget "_C" lst '((8 . "TEXT2"))))
  32.  
  33.   (_addlayer "TBLK_TBLK_REVTEXT" 3 "Continous" 1)
  34.   (_addlayer "TBLK_TBLK_REVLINES" 9 "Continous" 1)
  35.   (command "_.CHANGE" rev1 "" "_P" "_LA" "TBLK_TBLK_REVTEXT" "")
  36.  
  37.   (setvar 'osmode 1)
  38.   (setvar 'cmdecho 1)
  39.  
  40.   (princ)
  41. )
  42. (REV_UP)

When I run it through the vlide console...

Code - Auto/Visual Lisp: [Select]
  1. _$ (setq lst '((31.875 5.3125) (33.375 21.4375)))
  2. ((31.875 5.3125) (33.375 21.4375))
  3. _$ (setq dim (getvar 'dimscale) lst (mapcar '(lambda (x) (mapcar '* x (list dim dim))) lst))
  4. ((765.0 127.5) (801.0 514.5))
  5. _$ (setq rev1 (ssget "_C" lst '((8 . "TEXT2"))));;ichose to speicifically identify the layer I'm looking for.
  6.  
  7. Error: too many arguments; warning: unwind skipped on hard error
I suspect I'm fat fingering something or not reading something correctly. My eyes are a bit tired today.

-------------------

If I use...
Code - Auto/Visual Lisp: [Select]
  1. (setq rev1 (append (cons 'ssget (cons "_C" lst)) '(((8 . "TEXT*")))))

at the console, I get...
Code - Auto/Visual Lisp: [Select]
  1. _$ (setq lst '((31.875 5.3125) (33.375 21.4375)))
  2. ((31.875 5.3125) (33.375 21.4375))
  3. _$ (setq dim (getvar 'dimscale) lst (mapcar '(lambda (x) (mapcar '* x (list dim dim))) lst))
  4. ((765.0 127.5) (801.0 514.5))
  5. _$ (setq rev1 (append (cons 'ssget (cons "_C" lst)) '(((8 . "TEXT2)))))
  6. (SSGET "_C" (765.0 127.5) (801.0 514.5) ((8 . "TEXT2")))
  7. _$ (_addlayer "TBLK_TBLK_REVTEXT" 3 "Continous" 1)
  8. <Entity name: 1b975c66980>
  9. _$ (_addlayer "TBLK_TBLK_REVLINES" 9 "Continous" 1)
  10. <Entity name: 1b975c66990>
  11. _$ (command "_.CHANGE" rev1 "" "_P" "_LA" "TBLK_TBLK_REVTEXT" "")
  12. nil


Change to layouts and all your title block problems will go away.

Yes!!! I've actually set up a meeting for the first of the year on this. This code is part of that. Moving objects from old drawings into the new Pspace title block. This code assists with that.

Happy Holidays to you all.

Title: Re: More dimscale please
Post by: jlogan02 on January 06, 2020, 05:00:12 PM
Getting back to this just now...I still haven't figure out why I'm getting... "too many arguments".
Title: Re: More dimscale please
Post by: Dlanor on January 07, 2020, 06:25:46 AM
Code - Auto/Visual Lisp: [Select]
  1. (defun Rev_Up ( / DIM DIM1 OSM REV1 REV2 X)
  2.   (defun _addlayer (name color ltype plot)
  3.     (cond ((not (tblsearch "layer" name))
  4.            (entmakex (list '(0 . "LAYER")
  5.                            '(100 . "AcDbSymbolTableRecord")
  6.                            '(100 . "AcDbLayerTableRecord")
  7.                            '(70 . 0)
  8.                            (cons 2 name)
  9.                            (cons 62 color)
  10.                            (cons 6
  11.                                  (cond ((tblobjname "ltype" ltype))
  12.                                        ("continuous")
  13.                                  )
  14.                            )
  15.                            (cons 290 plot)
  16.                            ;;1 = plottable 0 = not=plottable
  17.                      )
  18.            )
  19.           )
  20.           ((tblobjname "layer" name))
  21.     )
  22.   )

This should probably be this (cons 6.....)

Code - Auto/Visual Lisp: [Select]
  1. (defun Rev_Up ( / DIM DIM1 OSM REV1 REV2 X)
  2.   (defun _addlayer (name color ltype plot)
  3.     (cond ((not (tblsearch "layer" name))
  4.            (entmakex (list '(0 . "LAYER")
  5.                            '(100 . "AcDbSymbolTableRecord")
  6.                            '(100 . "AcDbLayerTableRecord")
  7.                            '(70 . 0)
  8.                            (cons 2 name)
  9.                            (cons 62 color)
  10.                            (cons 6
  11.                                  (cond ((tblobjname "ltype" ltype) ltype)
  12.                                        ("continuous")
  13.                                  )
  14.                            )
  15.                            (cons 290 plot)
  16.                            ;;1 = plottable 0 = not=plottable
  17.                      )
  18.            )
  19.           )
  20.           ((tblobjname "layer" name))
  21.     )
  22.   )
  23.  

as (tblobjname "ltype" ltype) returns an entity if true

You are masking it by passing in "continous" instead of "continuous" in some of your calls
Title: Re: More dimscale please
Post by: snownut2 on January 07, 2020, 07:41:10 AM
What is line 12?

("Continuous")

Looks like a function call.  No parentheses required.
Title: Re: More dimscale please
Post by: Lee Mac on January 07, 2020, 08:13:31 AM
What is line 12?

("Continuous")

Looks like a function call.  No parentheses required.

Note that it's not a function call, but rather a cond condition, returning a literal string.
Title: Re: More dimscale please
Post by: jlogan02 on January 07, 2020, 04:55:14 PM
Thanks for that.

However, your catch didn't solve that problem.


Code - Auto/Visual Lisp: [Select]
  1. _$ (setq lst '((31.875 5.3125) (33.375 21.4375)))
  2. ((31.875 5.3125) (33.375 21.4375))
  3. _$ (setq dim (getvar 'dimscale) lst (mapcar '(lambda (x) (mapcar '* x (list dim dim))) lst))
  4. ((31.875 5.3125) (33.375 21.4375))
  5. _$ (setq rev1 (ssget "_C" lst '((8 . "TEXT2"))));;shouldn't I be getting the selected entities after this?

<selection set: ????;;;instead I'm getting too many arguments

Error: too many arguments;

I've literally stripped the code down to just the guts and...nothing. This is getting aggravating.
Title: Re: More dimscale please
Post by: MP on January 07, 2020, 05:07:46 PM
(setq rev1 (ssget "_c" (car lst) (cadr lst) '((8 . "TEXT2"))))

Cheers.
Title: Re: More dimscale please
Post by: MP on January 08, 2020, 03:45:55 PM
... <selection set: ???? ;; instead I'm getting too many arguments ... this is getting aggravating.

Did the following code snip remedy this ^ issue?

(setq rev1 (ssget "_c" (car lst) (cadr lst) '((8 . "TEXT2"))))
Title: Re: More dimscale please
Post by: jlogan02 on January 09, 2020, 01:12:52 PM
Sorry man...was outta town. It appears to have pulled it all together. Thanks
Title: Re: More dimscale please
Post by: MP on January 09, 2020, 05:47:49 PM
Thanks for letting me know - glad it helped - you’re most welcome - cheers.