Author Topic: Routine requires an enter between picks.  (Read 4228 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Routine requires an enter between picks.
« on: January 12, 2021, 11:22:09 AM »
I'm trying to change overridden dimensions from their overridden color to another color. Not change the dimstyle, just the dims placed in the drawing.

The dimoverride command runs and allows me to pick the dimensions. It changes them just fine but doesn't move onto the next ssget without me hitting enter, but it works fine.

Now that I write that, that sounds like normal operation since I want the user to pick the objects that need to change. Can someone verify that for me?

I don't know...

If I switch them around the ssget col
Code - Auto/Visual Lisp: [Select]
for text, lines, and etc. runs then gives me the pickbox for the dims but won't actually pick the dims.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ col col1 )
  2.  
  3.  (while (if (setq col1 (ssget "_:L" '((0 . "dimension"))))
  4.     (command "_.dimoverride" "dimclrd" 1 "dimclre" 1 "dimclrt" 1 "" col1 "")
  5.     )
  6.    )
  7.  
  8.   (setq col (ssget "_:L" '((0 . "MultiLeader,Hatch,*Line,*Text,Arc,Circle"))))
  9.         (foreach x (mapcar 'cadr (ssnamex col))
  10.         (entmod (append (entget x) '((62 . 1)))))
  11.  
  12.  
  13.   (princ)
  14. )

Any ideas.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Routine requires an enter between picks.
« Reply #1 on: January 12, 2021, 01:36:20 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ col lst)  
  2.   (if (setq col (ssget "_:L" '((0 . "MultiLeader,Hatch,*Line,*Text,Arc,Circle,dimension"))))
  3.     (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex col)))
  4.       (if (= (strcase (cdr (assoc 0 (setq lst (entget x))))) "DIMENSION")
  5.         (command "_.dimoverride" "dimclrd" 1 "dimclre" 1 "dimclrt" 1 "" (ssadd x) "")
  6.         (entmod (append lst '((62 . 1))))
  7.         )
  8.       )
  9.     )
  10.   (princ)
  11. )
  12.  

jlogan02

  • Bull Frog
  • Posts: 327
Re: Routine requires an enter between picks.
« Reply #2 on: January 14, 2021, 01:47:20 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ col lst)  
  2.   (if (setq col (ssget "_:L" '((0 . "MultiLeader,Hatch,*Line,*Text,Arc,Circle,dimension"))))
  3.     (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex col)))
  4.       (if (= (strcase (cdr (assoc 0 (setq lst (entget x))))) "DIMENSION")
  5.         (command "_.dimoverride" "dimclrd" 1 "dimclre" 1 "dimclrt" 1 "" (ssadd x) "")
  6.         (entmod (append lst '((62 . 1))))
  7.         )
  8.       )
  9.     )
  10.   (princ)
  11. )
  12.  

Thanks Tharwat,

Am I understanding the
Code - Auto/Visual Lisp: [Select]
correctly. It's adding all entities found in
Code - Auto/Visual Lisp: [Select]
  1. setq col
to the selection of dimoverride, and then entmoding those selections found for that selection?

So in effect using the opportunity given by the user prompt for selecting dims during the dimoverride?
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Routine requires an enter between picks.
« Reply #3 on: January 14, 2021, 01:56:11 PM »
No, the ssadd function converts an entity to selection set and it is only for the dimension objects in this case although I think it would work without converting the entity to selection which means that you can replace the (ssadd x) with just the variable 'x' .

Entmod is used for all the object names that are included in the filter with ssget except the dimensions.

jlogan02

  • Bull Frog
  • Posts: 327
Re: Routine requires an enter between picks.
« Reply #4 on: January 15, 2021, 05:18:14 PM »
No, the ssadd function converts an entity to selection set and it is only for the dimension objects in this case although I think it would work without converting the entity to selection which means that you can replace the (ssadd x) with just the variable 'x' .

Entmod is used for all the object names that are included in the filter with ssget except the dimensions.

Dropping the
Code - Auto/Visual Lisp: [Select]
does indeed work. Thanks.

I have several versions of this to make. The next version would select all objects colored RED and change them to 56. Each subsequent version would do the same, color 56 to 136, 136 to 191, 191 to 107.

so...RED to color 56
Code - Auto/Visual Lisp: [Select]
  1.  (if (setq col (ssget "_X" '((62 . 1)(0 . "MultiLeader,Hatch,*Line,*Text,Arc,Circle,dimension"))))
  2.     (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex col)))
  3.       (if (= (strcase (cdr (assoc 0 (setq lst (entget x))))) "DIMENSION")
  4.         (command "_.dimoverride" "dimclrd" 56 "dimclre" 56 "dimclrt" 56 "" (ssadd x) "")
  5.         (entmod (append lst '((62 . 56))))
  6.        )
  7.      )
  8.    )

Changed
Code - Auto/Visual Lisp: [Select]
  1. (setq col (ssget "_:L" '((0 . "MultiLeader,Hatch,*Line,*Text,Arc,Circle,dimension"))))
to
Code - Auto/Visual Lisp: [Select]
  1. (setq col (ssget "_X" '((62 . 1)(0 . "MultiLeader,Hatch,*Line,*Text,Arc,Circle,dimension"))))
;;;get all red objects

and changed the color numbers from
Code - Auto/Visual Lisp: [Select]
  1. (command "_.dimoverride" "dimclrd" 1 "dimclre" 1 "dimclrt" 1 "" (ssadd x) "")
  2.         (entmod (append lst '((62 . 1))))
to
Code - Auto/Visual Lisp: [Select]
  1. (command "_.dimoverride" "dimclrd" 56 "dimclre" 56 "dimclrt" 56 "" (ssadd x) "")
  2.         (entmod (append lst '((62 . 56))))

Either I've dropped something and am not seeing it. Or I'm missing code and don't know it.

If I leave out the (62 . 1) from the code it changes everything including objects I don't want changed. If I include (62 . 1) it changes all red objects to color 56 but dimensions.


J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Routine requires an enter between picks.
« Reply #5 on: January 15, 2021, 05:33:31 PM »
Your mods should work without any issue I believe.

But the objects that didn't change to the new color 56 may were on Red color by layer and if so, then you need to go with different selection set by iterating the layer table and get the layer names that set with red color then add the list into the filter of the selection set.

Difficult?  :no:

jlogan02

  • Bull Frog
  • Posts: 327
Re: Routine requires an enter between picks.
« Reply #6 on: January 15, 2021, 05:51:51 PM »
Let me verify that and get back to you.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

jlogan02

  • Bull Frog
  • Posts: 327
Re: Routine requires an enter between picks.
« Reply #7 on: January 15, 2021, 06:03:52 PM »
Drew an line on a layer with layer color set to red - Fail.
Drew a line on a layer and changed the lines color property to red using the code you helped me with earlier - Success.

Did the same with a dimensions.
Dim on Layer with layer color set to red - failed.
Dim on Layer with overridden dimclrt, dimclre, dimclrd to red - failed.

We have one layer that uses color bylayer RED. I can deal with that.


J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

jlogan02

  • Bull Frog
  • Posts: 327
Re: Routine requires an enter between picks.
« Reply #8 on: January 15, 2021, 06:06:54 PM »
Full code

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ST01to56 (/ *error* col lst osm )
  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.   (defun *error* (msg)
  24.     (if osm
  25.       (setvar 'osmode osm)
  26.     )
  27.     (if (not (member msg '("Function cancelled" "quit / exit abort")))
  28.       (princ (strcat "\nError: " msg))
  29.     )
  30.     (princ)
  31.   )
  32.   (setq osm (getvar 'osmode))
  33.   (setvar 'osmode 0)
  34.   (setvar 'cmdecho 0)
  35.  
  36.   (if (setq col (ssget "_X" '((0 . "MultiLeader,Hatch,*Line,*Text,Arc,Circle,dimension")(62 . 1))))
  37.     (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex col)))
  38.       (if (= (strcase (cdr (assoc 0 (setq lst (entget x))))) "DIMENSION")
  39.         (command "_.dimoverride" "dimclrd" 56 "dimclre" 56 "dimclrt" 56 "" (ssadd x) "")
  40.         (entmod (append lst '((62 . 56))))
  41.        )
  42.      )
  43.    )
  44.  
  45.   (_addlayer "FiberMgt_056" 56 "Continous" 1)
  46.  
  47.   (if (setq fm1 (ssget "x" '((8 . "FiberMgt_001"))))
  48.     (foreach x (mapcar 'cadr (ssnamex fm1))
  49.        (entmod (append (entget x) '((8 . "FiberMgt_056"))))
  50.     )
  51.   )
  52.  
  53.     ;;(command ".-layer" "filter" "edit" "Stations Standard Layers" "add" "FiberMgt_056" "exit" "")
  54.  
  55.  
  56.   (if (tblsearch "LAYER" "FiberMgt_001")
  57.     (command "-laydel" "_n" "FiberMgt_001" "" "Y" "")
  58.   )
  59.  
  60.   (command ".-layer" "filter" "edit" "Stations Standard Layers" "add" "FiberMgt_056" "exit" "")
  61.  
  62.   (setvar 'osmode osm)
  63.   (setvar 'cmdecho 1)
  64.  
  65.   (princ)
  66. )
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Routine requires an enter between picks.
« Reply #9 on: January 16, 2021, 06:47:23 AM »
Hi,
Rectify this:
Code - Auto/Visual Lisp: [Select]
  1.  (mapcar 'cadr (ssnamex fm1))
With this:
Code - Auto/Visual Lisp: [Select]
  1. (vl-remove-if 'listp (mapcar 'cadr (ssnamex fm1)))
  2.  

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Routine requires an enter between picks.
« Reply #10 on: January 16, 2021, 11:00:33 PM »
Hi,
Rectify this:
Code - Auto/Visual Lisp: [Select]
  1.  (mapcar 'cadr (ssnamex fm1))
With this:
Code - Auto/Visual Lisp: [Select]
  1. (vl-remove-if 'listp (mapcar 'cadr (ssnamex fm1)))
  2.  
@Tharwat you don't need the vl-remove-if when "_X" is used in ssget.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Routine requires an enter between picks.
« Reply #11 on: January 17, 2021, 03:53:41 AM »
Thanks Ron, you are right.
But what makes that difference once using that string mode in your opinion ?

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Routine requires an enter between picks.
« Reply #12 on: January 17, 2021, 03:55:35 AM »
Logan,
Please upload the same drawing that you tested your codes out on to take a close look if possible.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Routine requires an enter between picks.
« Reply #13 on: January 18, 2021, 02:34:47 PM »
Thanks Ron, you are right.
But what makes that difference once using that string mode in your opinion ?
I'm not sure I understand your question.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Tharwat

  • Swamp Rat
  • Posts: 707
  • Hypersensitive
Re: Routine requires an enter between picks.
« Reply #14 on: January 18, 2021, 02:45:09 PM »
Once using the ssget "_X" then there is no need to use (vl-remove-if 'listp ... but with the ssget "_:L" for instance there is a need to use (vl-remove-if 'listp  since the return of the ssnamex would return the last item in the list as a list.

I have read about ssget and ssnamex functions and nothing was written in regard of such a return or so.