Author Topic: Make all hatches to solids?  (Read 6368 times)

0 Members and 1 Guest are viewing this topic.

KewlToyZ

  • Guest
Make all hatches to solids?
« on: December 06, 2007, 10:05:52 PM »
Just curious, because they seem to load faster and use less memory...
On that note is it possible to adjust drawing order of the automatic selections to back?
I haven't been able to determine if I can just select layers to send to back in drawing order yet either.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Make all hatches to solids?
« Reply #1 on: December 07, 2007, 01:24:43 AM »
Hi,

Something like this ?

EDIT : code revised according to Joe's message

Code: [Select]
(defun c:test (/ space ss hlst)
  (or *acdoc*
      (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
  (setq space (vla-get-ModelSpace *acdoc*))
  (if (setq ss (ssget "_X" '((0 . "HATCH") (410 . "Model"))))
    (progn
      (vlax-for h (vla-get-ActiveSelectionSet *acdoc*)
(vla-SetPattern h acHatchPatternTypePreDefined "SOLID")
(setq hlst (cons h hlst))
      )
      (if (vl-catch-all-error-p
    (setq sort (vl-catch-all-apply
'vla-getObject
(list (vla-getExtensionDictionary
space
       )
       "ACAD_SORTENTS"
)
       )
    )
  )
(setq sort (vla-addObject
     (vla-getExtensionDictionary
       space
     )
     "ACAD_SORTENTS"
     "AcDbSortentsTable"
   )
)
      )
      (vlax-invoke sort 'MoveToBottom hlst)
    )
  )
  (princ)
)
« Last Edit: December 07, 2007, 04:02:00 PM by gile »
Speaking English as a French Frog

FengK

  • Guest
Re: Make all hatches to solids?
« Reply #2 on: December 07, 2007, 02:31:18 AM »
Thanks gile. Haven't used "ACAD_SORTENTS" myself before.

Joe Burke

  • Guest
Re: Make all hatches to solids?
« Reply #3 on: December 07, 2007, 09:01:24 AM »
Hi gile,

Nice code as usual.

Just a thought regarding these lines:

  (setq ss (ssget "_X" '((0 . "HATCH") (410 . "Model"))))
  (vlax-for h (vla-get-ActiveSelectionSet *acdoc*)

The ActiveSelectionSet is a moving target in the sense if ssget is nil, I think* the ActiveSelectionSet is the previous set, assuming one exists.

So maybe this is safer?

  (if (ssget "_X" '((0 . "HATCH") (410 . "Model")))
    (vlax-for h (vla-get-ActiveSelectionSet *acdoc*)

The ss variable isn't used or needed.

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Make all hatches to solids?
« Reply #4 on: December 07, 2007, 09:59:06 AM »
Hi Joe,

Thanks for the correction I used to put a condition dealing with selection sets, but this time I forgot (too quickly written). :oops: I revise the code
I'm not sure, but I'd rather use a variable to reset the selection set to nil at the end of the routine, I know the number of selection sets made with LISP is limited (128).
« Last Edit: December 07, 2007, 04:55:27 PM by gile »
Speaking English as a French Frog

Guest

  • Guest
Re: Make all hatches to solids?
« Reply #5 on: December 07, 2007, 10:41:59 AM »
You don't really need any code for this (unless you've got a BUNCH of drawings you want to do this to).

All you have to do is select all hatch patterns (you can use QSELECT or Select Similar), then from the Properties pallete change the pattern to SOLID, and while you still have the hatch patterns selected, right-click and select DISPLAY ORDER -- SEND TO BACK.

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #6 on: December 07, 2007, 03:11:31 PM »
I want to run this as a code and definately not a selection set on every file in a directory selected.
And I'm so swamped at work I can't make the time to test today.
I just had to stop in for a few seconds of swamp zen. Thanks!

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #7 on: December 07, 2007, 07:05:58 PM »
The image thing was a real duh kind of deal
(command "image" "detach" "*") :ugly:

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #8 on: December 19, 2007, 05:09:56 PM »
Speaking of variable being nil in a selection set.....
Code: [Select]
(defun c:HATCH19()
(setq AllHatch (ssget "_X" '((0 . "HATCH"))))
(setq NumHatch (sslength AllHatch))
(setq Count 0)
(repeat NumHatch ;;this cycles number of items
    (setq Ename (ssname AllHatch Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
    (command "layer" "c" "19" HatchLyr "") ;;change hatch layer color to 19
   (setq Count (+ 1 Count))
   (prompt "\nAll Hatch Layers Made Color 19 !!!")
)
)

If no hatches exist I get a bad argument.
So I'm not sure at what point I want the if AllHatch is nil.
Especially in the case of batching files with the routine.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make all hatches to solids?
« Reply #9 on: December 19, 2007, 06:10:27 PM »
I would do it like
Code: [Select]
(defun c:HATCH19()
(if (setq AllHatch (ssget "_X" '((0 . "HATCH"))))
(progn
(setq NumHatch (sslength AllHatch))
(setq Count 0)
(repeat NumHatch ;;this cycles number of items
(setq Ename (ssname AllHatch Count))  ;;get entity name
(setq Edata (entget Ename))
(setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
(command "layer" "c" "19" HatchLyr "") ;;change hatch layer color to 19
(setq Count (+ 1 Count))
(prompt "\nAll Hatch Layers Made Color 19 !!!")
)
)
)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #10 on: December 19, 2007, 06:34:43 PM »
Thanks Tim :kewl:

Code: [Select]
(defun c:HATCH19()
(if (setq AllHatch (ssget "_X" '((0 . "HATCH")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumHatch (sslength AllHatch))
(setq Count 0)
  (repeat NumHatch ;;this cycles number of items
    (setq Ename (ssname AllHatch Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
    (command "layer" "c" "19" HatchLyr "") ;;change hatch layer color to 19
    (command "_.draworder" AllHatch "" order)
    (setq Count (+ 1 Count))   
    (command "clayer" "0")   
  )
  (prompt "\nHatch Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\nNo Hatch objects found!") ;else
 )
(princ)
)

Before you intervened i was playing with another that creates a layer for clients that send us files with everything on the 0 layerwith:
Code: [Select]
(defun c:XHATCH19()
(if (setq AllHatch (ssget "X" (list(cons 0 "HATCH"))))
(progn
(setq order "Back")
(setq NumHatch (sslength AllHatch))
(setq Count 0)
(repeat NumHatch ;;this cycles number of items
    (setq Ename (ssname AllHatch Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
    (command "layer" "make" "A-KTA-HTCH" "color" "19" "A-KTA-HTCH" "")
    (command "chprop" AllHatch "" "la" "A-KTA-HTCH" "")
    (command "_.draworder" AllHatch "" order)
   (setq Count (+ 1 Count))
   (command "clayer" "0")   
)
(prompt "\nAll Hatch Patterns Moved to A-KTA-HTCH Layer,
Draw Order Sent to Back & Made Color 19 !!!")
) ;then
(princ "\n No Hatch objects found!") ;else
)
(princ)
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make all hatches to solids?
« Reply #11 on: December 19, 2007, 06:37:35 PM »
Glad you got something that works.  Happy to help.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #12 on: December 19, 2007, 06:44:10 PM »
Hey Tim, I am curious, I always have a hard time understanding the order of events when using conditions.
I am trying to have a prompt on the command line
Code: [Select]
(prompt "\nPlease Wait......sorting hatches.....") ;amusementBut it never fires until after everything else has ran?
I've tried this before and always gave up on it.
I keep moving it around but it doesn't seem to want to prioritize?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Make all hatches to solids?
« Reply #13 on: December 19, 2007, 06:44:13 PM »
This is how i would approach it:

Code: [Select]
(defun c:HATCH19 (/ allhatch)
  (if (setq AllHatch (ssget "_X" '((0 . "HATCH"))))
    (progn
      (mapcar
'(lambda (x)
   (vla-put-color
     (vlax-ename->vla-object
       (tblobjname "layer" (cdr (assoc 8 (entget x))))
     )
     19
   )
)
(mapcar 'cadr (ssnamex allhatch))
      )
      (command "_.draworder" AllHatch "" "back")
      (prompt "\nAll Hatch Layers Made Color 19 !!!")
      (setvar 'clayer "0")
    )
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Make all hatches to solids?
« Reply #14 on: December 19, 2007, 06:47:32 PM »
Hey Tim, I am curious, I always have a hard time understanding the order of events when using conditions.
I am trying to have a prompt on the command line
Code: [Select]
(prompt "\nPlease Wait......sorting hatches.....") ;amusementBut it never fires until after everything else has ran?
I've tried this before and always gave up on it.
I keep moving it around but it doesn't seem to want to prioritize?

Try putting something like this in your loop (spinner):



Code: [Select]
(defun spinner (/)
  (setq *sym*
(cond
   ((= *sym* nil) "-")
   ((= *sym* "-") "\\")
   ((= *sym* "\\") "|")
   ((= *sym* "|") "/")
   ((= *sym* "/") "-")
)
  )
  (grtext -2 (strcat "Working... " *sym*))
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #15 on: December 19, 2007, 06:50:00 PM »
LOL man I always wondered where that came from.
Nice!

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Make all hatches to solids?
« Reply #16 on: December 19, 2007, 06:53:04 PM »
LOL man I always wondered where that came from.
Nice!

 :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #17 on: December 19, 2007, 07:03:17 PM »
OK, I remeber I saw this in express tools before and tried getting it to fire off.
My little twitch and tweak brain isn't gettin it  :ugly:

Code: [Select]
(defun c:XHATCH19(/ spinner)

(defun spinner (/)
  (setq *sym*
(cond
   ((= *sym* nil) "-")
   ((= *sym* "-") "\\")
   ((= *sym* "\\") "|")
   ((= *sym* "|") "/")
   ((= *sym* "/") "-")
)
  )
  (grtext -2 (strcat "Working... " *sym*))
)

(if (setq AllHatch (ssget "X" (list(cons 0 "HATCH"))))
(progn

(setq order "Back")
(setq NumHatch (sslength AllHatch))
(setq Count 0)
(repeat NumHatch ;;this cycles number of items
    (setq Ename (ssname AllHatch Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
    (spinner)
    ;(prompt "\nHatch found!! Please Wait......sorting next.....") ;amusement
    (command "layer" "make" "A-KTA-HTCH" "color" "19" "A-KTA-HTCH" "")
    (command "chprop" AllHatch "" "la" "A-KTA-HTCH" "")
    (command "_.draworder" AllHatch "" order)
   (setq Count (+ 1 Count))
   (command "clayer" "0")   
)
(prompt "\nAll Hatch Patterns Moved to A-KTA-HTCH Layer,
Draw Order Sent to Back & Made Color 19 !!!")
) ;then
(princ "\n No Hatch objects found!") ;else
)
(princ)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make all hatches to solids?
« Reply #18 on: December 20, 2007, 05:23:18 PM »
Won't this work for you?
Code: [Select]
(defun c:XHATCH19 (/ AllHatch)
  (if (setq AllHatch (ssget "X" (list (cons 0 "HATCH"))))
    (progn
      (command "layer" "make" "A-KTA-HTCH" "color" "19" "A-KTA-HTCH" "")
      (command "chprop" AllHatch "" "la" "A-KTA-HTCH" "")
      (command "_.draworder" AllHatch "" "Back")
      (command "clayer" "0")
      (prompt (strcat "\nAll Hatch Patterns Moved to A-KTA-HTCH Layer, "
                      "Draw Order Sent to Back & Made Color 19 !!!")
      )
    )
    (princ "\n No Hatch objects found!")
  )
  (princ)
)
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.

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #19 on: February 05, 2008, 03:21:47 PM »
Oh yeah it works, I meant that little "wait" status spinner from express tools.
I never could figure out the way to set it up to call in my routines.


Actually I ended up with a few different versions.
So many clients using different systems etc...

Code: [Select]
(defun c:GHATCH19()

(if (setq AllHatch (ssget "_X" '((0 . "HATCH")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumHatch (sslength AllHatch))
(setq Count 0)

  (repeat NumHatch ;;this cycles number of items
    (setq Ename (ssname AllHatch Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
    (prompt "\nHatch found!! Please Wait......sorting next.....") ;amusement
    (command "layer" "c" "19" HatchLyr "") ;;change hatch layer color to 19
    ;(command "chprop" AllHatch "" "COLOR" "19" "")
    (command "_.draworder" AllHatch "" order)
    (setq Count (+ 1 Count))   
    (command "clayer" "0")   
  )
  (prompt "\nHatch Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\nNo Hatch objects found!") ;else
 )
(princ)

;==========================================================================================================================================

(if (setq AllFILL (ssget "_X" '((0 . "FILL")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumFILL (sslength AllFILL))
(setq Count 0)

  (repeat NumFILL ;;this cycles number of items
    (setq Ename (ssname AllFILL Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq FILLLyr (cdr (assoc 8 Edata))) ;;get FILL layer name
    (prompt "\nFILL found!! Please Wait......sorting next.....") ;amusement
    (command "layer" "c" "19" FILLLyr "") ;;change FILL layer color to 19
    ;(command "chprop" AllFILL "" "COLOR" "19" "")
    (command "_.draworder" AllFILL "" order)
    (setq Count (+ 1 Count))   
    (command "clayer" "0")   
  )
  (prompt "\nFILL Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\nNo FILL objects found!") ;else
 )
(princ)
;==========================================================================================================================================

(if (setq AllSOLID (ssget "_X" '((0 . "SOLID")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumSOLID (sslength AllSOLID))
(setq Count 0)

  (repeat NumSOLID ;;this cycles number of items
    (setq Ename (ssname AllSOLID Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq SOLIDLyr (cdr (assoc 8 Edata))) ;;get SOLID layer name
    (prompt "\nSOLID found!! Please Wait......sorting next.....") ;amusement
    (command "layer" "c" "19" SOLIDLyr "") ;;change SOLID layer color to 19
    ;(command "chprop" AllSOLID "" "COLOR" "19" "")
    (command "_.draworder" AllSOLID "" order)
    (setq Count (+ 1 Count))   
    (command "clayer" "0")   
  )
  (prompt "\nSOLID Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\nNo SOLID objects found!") ;else
 )
(princ)
;==========================================================================================================================================
)

Defaulting to control by the object types seems the most popular since many don't have any standards for their layer structures still.
« Last Edit: February 05, 2008, 03:39:25 PM by KewlToyZ »

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make all hatches to solids?
« Reply #20 on: April 27, 2009, 10:46:27 AM »
Alan

Good tool.
Question: how would you change your code to change all hatches that are not bylayer and set them to your new layer and make these hatches to bylayer?

Gary

Won't this work for you?
Code: [Select]
(defun c:XHATCH19 (/ AllHatch)
  (if (setq AllHatch (ssget "X" (list (cons 0 "HATCH"))))
    (progn
      (command "layer" "make" "A-KTA-HTCH" "color" "19" "A-KTA-HTCH" "")
      (command "chprop" AllHatch "" "la" "A-KTA-HTCH" "")
      (command "_.draworder" AllHatch "" "Back")
      (command "clayer" "0")
      (prompt (strcat "\nAll Hatch Patterns Moved to A-KTA-HTCH Layer, "
                      "Draw Order Sent to Back & Made Color 19 !!!")
      )
    )
    (princ "\n No Hatch objects found!")
  )
  (princ)
)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make all hatches to solids?
« Reply #21 on: April 27, 2009, 11:35:37 AM »
Sorry, I should have made new post.

I got it figured out. Thanks
Code: [Select]
(defun c:XHATCH-9 (/ AllHatch)
  (if (setq AllHatch (ssget "X" (list (cons 0 "HATCH")(cons 62 8))))    (progn
      (command "layer" "make" "A-PATT-POCH" "color" "8" "A-PATT-POCH" "")
      (command "chprop" AllHatch "" "la" "A-PATT-POCH" "color" "BYLAYER" "")
      (command "_.draworder" AllHatch "" "Back")
      (command "clayer" "0")
      (prompt (strcat "\n* All Hatch Patterns Moved to A-PATT-POCH Layer *"))
    )
    (princ "\n* No Hatch objects found *")
  )
  (princ)
)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #22 on: April 27, 2009, 12:13:54 PM »
Sorry, I should have made new post.

I got it figured out. Thanks
Code: [Select]
(defun c:XHATCH-9 (/ AllHatch)
  (if (setq AllHatch (ssget "X" (list (cons 0 "HATCH")(cons 62 8))))    (progn
      (command "layer" "make" "A-PATT-POCH" "color" "8" "A-PATT-POCH" "")
      (command "chprop" AllHatch "" "la" "A-PATT-POCH" "color" "BYLAYER" "")
      (command "_.draworder" AllHatch "" "Back")
      (command "clayer" "0")
      (prompt (strcat "\n* All Hatch Patterns Moved to A-PATT-POCH Layer *"))
    )
    (princ "\n* No Hatch objects found *")
  )
  (princ)
)

I usually just set as much as possible to ByLayer:
Code: [Select]
(defun c:mkbylayer( / en ed )
;(SETUP)
(prompt "\nChanging all entities' colors to BYLAYER.  This may take awhile ...")
(command "layer" "u" "*" "")
(command "setbylayer" "All" "" "Yes" "Yes")
(setq en (entnext))
(setq ed (entget en))
(mkbylayer2 en ed)
(command "regenall")
(mkblkbylayer)
(command "regenall")
;(END)
(princ)
)

(defun mkbylayer2(en ed )
(setq cnt 0)
(while (setq en (entnext en))
(setq ed (entget en))
(mkblmod en ed)
(if (eq cnt 100)
(progn
(princ ".")
(setq cnt 0)
);progn
(setq cnt (1+ cnt))
);if
)
)


(defun mkblmod(en ed / cnt )

(if (/= (cdr (assoc 62 (entget en))) nil)
(progn
(setq ed
(subst (cons 62 256)
(assoc 62 ed)
ed 
)
)
(entmod ed)
(entupd en)
);progn
);if
)



(defun mkblkbylayer( / blk cnt)
(setq cnt 0)
(princ "\nModifying Blocks.  Be patient ...")
;modify first block
(setq blk (tblnext "block" t))
(mkblkbl blk)
;modify subsequent blocks
(while (setq blk (tblnext "block"))
(mkblkbl blk)
(if (eq cnt 1)
(progn
(princ ".")
(setq cnt 0)
);progn
(setq cnt (1+ cnt))
) ;if
) ;while
)

(defun mkblkbl(blk / en ed  )
(setq en (cdr (assoc -2 blk)))
(setq ed (entget en))
(mkblmod en ed)
(mkbylayer2 en ed)
)

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #23 on: April 28, 2009, 01:34:24 PM »
Minor Revision:
Count prints number as it iterates through the list
Code: [Select]
(defun c:HATCH19()
;===========================================================================Turn off command line responses
(command "CMDECHO" 0);DO NOT CHANGE THIS LINE
;===========================================================================

(if (setq AllHatch (ssget "_X" '((0 . "HATCH")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumHatch (sslength AllHatch))
(setq Count 0)

  (repeat NumHatch ;;this cycles number of items
    (setq Ename (ssname AllHatch Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
    (prompt "\nHatch found!! Please Wait......") ;amusement
    ;(command "layer" "c" "19" HatchLyr "") ;;change hatch layer color to 19
    (command "chprop" AllHatch "" "COLOR" "19" "")
    (command "_.draworder" AllHatch "" order)
    (setq Count (+ 1 Count))
(princ "\n Count = [ ")
(princ Count)
(princ " ] sorting next.....")
    (command "clayer" "0")   
  )
  (prompt "\nHatch Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\nNo Hatch objects found!") ;else
 )
(princ)

;===========================================================================

(if (setq AllFILL (ssget "_X" '((0 . "FILL")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumFILL (sslength AllFILL))
(setq Count 0)

  (repeat NumFILL ;;this cycles number of items
    (setq Ename (ssname AllFILL Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq FILLLyr (cdr (assoc 8 Edata))) ;;get FILL layer name
    (prompt "\nFILL found!! Please Wait......") ;amusement
    ;(command "layer" "c" "19" FILLLyr "") ;;change FILL layer color to 19
    (command "chprop" AllFILL "" "COLOR" "19" "")
    (command "_.draworder" AllFILL "" order)
(princ "\n Count = [ ")
    (princ Count)
(princ " ] sorting next.....")
    (princ "\n sorting next.....")
    (command "clayer" "0")   
  )
  (prompt "\nFILL Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\nNo FILL objects found!") ;else
 )
(princ)
;===========================================================================

(if (setq AllSOLID (ssget "_X" '((0 . "SOLID")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumSOLID (sslength AllSOLID))
(setq Count 0)

  (repeat NumSOLID ;;this cycles number of items
    (setq Ename (ssname AllSOLID Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq SOLIDLyr (cdr (assoc 8 Edata))) ;;get SOLID layer name
    (prompt "\nSOLID found!! Please Wait......") ;amusement
    ;(command "layer" "c" "19" SOLIDLyr "") ;;change SOLID layer color to 19
    (command "chprop" AllSOLID "" "COLOR" "19" "")
    (command "_.draworder" AllSOLID "" order)
    (setq Count (+ 1 Count))
(princ "\n Count = [ ")
(princ Count)
(princ " ] sorting next.....")
    (command "clayer" "0")   
  )
  (prompt "\nSOLID Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\nNo SOLID objects found!") ;else
 )
(princ)
;===========================================================================Turn on command line responses
(setvar "CMDECHO" 1); DO NOT CHANGE THIS LINE
;===========================================================================

;===========================================================================
)

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: Make all hatches to solids?
« Reply #24 on: April 28, 2009, 02:50:44 PM »
Hey Tim, I am curious, I always have a hard time understanding the order of events when using conditions.
I am trying to have a prompt on the command line
Code: [Select]
(prompt "\nPlease Wait......sorting hatches.....") ;amusementBut it never fires until after everything else has ran?
I've tried this before and always gave up on it.
I keep moving it around but it doesn't seem to want to prioritize?

Try putting something like this in your loop (spinner):



Code: [Select]
(defun spinner (/)
  (setq *sym*
(cond
   ((= *sym* nil) "-")
   ((= *sym* "-") "\\")
   ((= *sym* "\\") "|")
   ((= *sym* "|") "/")
   ((= *sym* "/") "-")
)
  )
  (grtext -2 (strcat "Working... " *sym*))
)


Haha Very nice RonJonP  :-D

KewlToyZ

  • Guest
Re: Make all hatches to solids?
« Reply #25 on: August 13, 2009, 11:21:01 AM »
Thanks for your help as always gents,
I have ended up here with the code structure:

Code: [Select]
; Change all hatches, solids, & fills to color 19 and send to back of drawing order
; Special thanks to TheSwamp crew:  CAB, T.Willey, ronjonp, GDF, & Lee Mac for their guidance, code, and suggestions.
; http://www.theswamp.org/index.php?topic=20391.0;all

(defun c:HATCH19()
;===========================================================================Turn off command line responses
(command "CMDECHO" 0);DO NOT CHANGE THIS LINE
;===========================================================================

(if (setq AllHatch (ssget "_X" '((0 . "HATCH")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumHatch (sslength AllHatch))
(setq Count 0)
(princ "\n   Total Hatches found : ")
(princ NumHatch)

  (repeat NumHatch ;;this cycles number of items
    (setq Ename (ssname AllHatch Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
    (prompt "\n   Hatch found!! Please Wait......") ;amusement
    ;(command "layer" "c" "19" HatchLyr "") ;;change hatch layer color to 19
    (command "chprop" AllHatch "" "COLOR" "19" "")
    (command "_.draworder" AllHatch "" order)
    (setq Count (+ 1 Count))
(princ "\n   Count = [ ")
(princ Count)
(princ " ] sorting next of total: ")
(princ NumHatch)
    (command "clayer" "0")   
  )
  (prompt "\n   Hatch Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\n   No Hatch objects found!") ;else
 )
(princ)

;===========================================================================

(if (setq AllFILL (ssget "_X" '((0 . "FILL")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumFILL (sslength AllFILL))
(setq Count 0)
(princ "\n   Total Fills found : ")
(princ NumFILL)

  (repeat NumFILL ;;this cycles number of items
    (setq Ename (ssname AllFILL Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq FILLLyr (cdr (assoc 8 Edata))) ;;get FILL layer name
    (prompt "\n   FILL found!! Please Wait......") ;amusement
    ;(command "layer" "c" "19" FILLLyr "") ;;change FILL layer color to 19
    (command "chprop" AllFILL "" "COLOR" "19" "")
    (command "_.draworder" AllFILL "" order)
(princ "\n   Count = [ ")
    (princ Count)
(princ " ] sorting next of total: ")
(princ NumFILL)
    (command "clayer" "0")   
  )
  (prompt "\n   FILL Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\n   No FILL objects found!") ;else
 )
(princ)
;===========================================================================

(if (setq AllSOLID (ssget "_X" '((0 . "SOLID")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumSOLID (sslength AllSOLID))
(setq Count 0)
(princ "\n   Total Solids found : ")
(princ NumSOLID)

  (repeat NumSOLID ;;this cycles number of items
    (setq Ename (ssname AllSOLID Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq SOLIDLyr (cdr (assoc 8 Edata))) ;;get SOLID layer name
    (prompt "\n   SOLID found!! Please Wait......") ;amusement
    ;(command "layer" "c" "19" SOLIDLyr "") ;;change SOLID layer color to 19
    (command "chprop" AllSOLID "" "COLOR" "19" "")
    (command "_.draworder" AllSOLID "" order)
    (setq Count (+ 1 Count))
(princ "\n   Count = [ ")
(princ Count)
(princ " ] sorting next of total: ")
(princ NumSOLID)
    (command "clayer" "0")   
  )
  (prompt "\n   SOLID Draw Order sent to back & Layer Made Color 19 !!!")
 ) ;then
 (prompt "\n   No SOLID objects found!\n") ;else
 )
(princ)
;===========================================================================Turn on command line responses
(setvar "CMDECHO" 1); DO NOT CHANGE THIS LINE
;===========================================================================

;===========================================================================
)