Author Topic: Help about print hatch in block!  (Read 5001 times)

0 Members and 1 Guest are viewing this topic.

duyhung

  • Guest
Help about print hatch in block!
« on: December 22, 2010, 05:01:57 AM »
I want to choose all hatch in my drawing and i want set them in colour 250 but I can't choose hatch in block. Please give me a solution to solve problems (one lisp).
I want print all hatch is translucent.
Thanks all.
Sorry I'm not good at English!
« Last Edit: December 22, 2010, 07:33:09 AM by duyhung »

pBe

  • Bull Frog
  • Posts: 402
Re: Help about print hatch in block!
« Reply #1 on: December 22, 2010, 06:16:25 AM »
Not sure what you mean by that but...

This will select all hatch (quick and dirty)

Code: [Select]
(ssget "_X" '((0 . "HATCH")))
(command "_chprop" "p" "" "c" "250" "")

You want it printed transluscent (????)  , i suggest you use TrueColor and send your hatch patterns  back (Draw Order)
there are better ways on doing this but.. :roll:



« Last Edit: December 22, 2010, 06:25:35 AM by pBe »

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Help about print hatch in block!
« Reply #2 on: December 22, 2010, 07:33:23 AM »
Check this out Buddy.  :-)

Code: [Select]
(defun c:test (/ ss )
 ; Tharwat Dec. 22 . 2010
  (if (setq ss (ssget "_x" '((0 . "HATCH"))))
  ((lambda (i / a e)
   (while
     (setq a (ssname ss (setq i (1+ i))))
       (setq e (entget a))
           (entupd (cdr (assoc -1 (entmod (subst (cons 62 250)(assoc 62 e) e)))))
         )
        )
     -1
    )
       
    (Alert " No Hatches Found")
    )
  (princ)
  )

Tharwat

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Help about print hatch in block!
« Reply #3 on: December 22, 2010, 08:22:47 AM »
I want to choose all hatch in my drawing and i want set them in colour 250 but I can't choose hatch in block.

You may mean this .  :-)

Code: [Select]
(defun c:test (/ ss)
 ; Tharwat Dec. 22 . 2010
  (vl-load-com)
  (if (setq ss (nentsel "\n Select Object :"))
    (progn
      (vla-put-color (vlax-ename->vla-object (car ss)) 250)
       (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)
      )
    )
    (princ "Written by Tharwat")
  (princ)
  )

Tharwat
« Last Edit: December 22, 2010, 08:44:35 AM by Tharwat »

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help about print hatch in block!
« Reply #4 on: December 22, 2010, 08:25:32 AM »
Check this out Buddy.  :-)

Code: [Select]
(defun c:test (/ ss )
 ; Tharwat Dec. 22 . 2010
  (if (setq ss (ssget "_x" '((0 . "HATCH"))))
  ((lambda (i / a e)
   (while
     (setq a (ssname ss (setq i (1+ i))))
       (setq e (entget a))
           (entupd (cdr (assoc -1 (entmod (subst (cons 62 250)(assoc 62 e) e)))))
         )
        )
     -1
    )
       
    (Alert " No Hatches Found")
    )
  (princ)
  )

Tharwat

What if DXF 62 isn't present?  :wink:

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Help about print hatch in block!
« Reply #5 on: December 22, 2010, 08:34:21 AM »
What if DXF 62 isn't present?  :wink:

Is there any entity which do not have a DXF 62 with it ? : :-)

Tharwat

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help about print hatch in block!
« Reply #6 on: December 22, 2010, 08:39:22 AM »
What if DXF 62 isn't present?  :wink:

Is there any entity which do not have a DXF 62 with it ? : :-)

Yes, those with a colour set to ByLayer  :-)

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Help about print hatch in block!
« Reply #7 on: December 22, 2010, 08:54:04 AM »
What if DXF 62 isn't present?  :wink:

Is there any entity which do not have a DXF 62 with it ? : :-)

Yes, those with a colour set to ByLayer  :-)

That's related to color No. 256 , so does it mean that it does not have a DXF 62 ? :|

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help about print hatch in block!
« Reply #8 on: December 22, 2010, 08:55:45 AM »
What if DXF 62 isn't present?  :wink:

Is there any entity which do not have a DXF 62 with it ? : :-)

Yes, those with a colour set to ByLayer  :-)

That's related to color No. 256 , so does it mean that it does not have a DXF 62 ? :|

Query it and you shall see  :-)

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Help about print hatch in block!
« Reply #9 on: December 22, 2010, 09:00:53 AM »
What if DXF 62 isn't present?  :wink:

Is there any entity which do not have a DXF 62 with it ? : :-)

Yes, those with a colour set to ByLayer  :-)
That's related to color No. 256 , so does it mean that it does not have a DXF 62 ? :|

Query it and you shall see  :-)

It would be also nice if it is supported with an example.  :-)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help about print hatch in block!
« Reply #10 on: December 22, 2010, 09:05:10 AM »
What if DXF 62 isn't present?  :wink:

Is there any entity which do not have a DXF 62 with it ? : :-)

Yes, those with a colour set to ByLayer  :-)
That's related to color No. 256 , so does it mean that it does not have a DXF 62 ? :|

Query it and you shall see  :-)

It would be also nice if it is supported with an example.  :-)

Create any object, set the colour to ByLayer and use entget or this to query it.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Help about print hatch in block!
« Reply #11 on: December 22, 2010, 09:14:42 AM »
I guess it would give the DXf (67 . 0) as ByLayer .

I faced that before, and sometimes were working and sometimes weren't .
And I had to replace the (cons 62 250) to be (cons 67 250) which kept me nervious with changing colours for entities in general.  :-)

Regards.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help about print hatch in block!
« Reply #12 on: December 22, 2010, 09:25:23 AM »
I guess it would give the DXf (67 . 0) as ByLayer .

I faced that before, and sometimes were working and sometimes weren't .
And I had to replace the (cons 62 250) to be (cons 67 250) which kept me nervious with changing colours for entities in general.  :-)

When set the ByLayer, the DXF 62 code will not be present in the DXF Data list.

How might you go about updating the value should it not be present? Perhaps by adding it to the list?

Say:

Code: [Select]
(if (assoc 62 <entitylist>)
  (subst (cons 62 <NewValue>) (assoc 62 <entitylist>) <entitylist>)
  (append <entitylist> (list (cons 62 <NewValue>)))
)

That would work, but I think there is a better way to approach it, consider this function:

Code: [Select]
(defun c:test ( / ss i )
 
  (if (setq ss (ssget "_:L" '((0 . "HATCH"))))
   
    (repeat (setq i (sslength ss))     
      (_UpdateDXF 62 250 (entget (ssname ss (setq i (1- i)))))
    )   
  )
  (princ)
)

(defun _UpdateDXF ( code value elist )
  (if
    (setq elist
      (entmod (list (assoc -1 elist) (cons code value)))
    )
    (entupd (cdr (assoc -1 elist)))
  )
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Help about print hatch in block!
« Reply #13 on: December 22, 2010, 11:27:13 AM »
None of those will work on the level the OP is asking.  If you want to change all hatch patterns ( nested also ), then you will have to step through all the block definitions.  Since layouts are defined by blocks, then those that are not thought of as nested will change also.

Code: [Select]
(vlax-for blk (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vlax-for i blk
        (if (= (vla-get-ObjectName i) "AcDbHatch")
            (vla-put-Color i 250)
        )
    )
)

May need a regen after.
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Help about print hatch in block!
« Reply #14 on: December 22, 2010, 11:28:27 AM »
And Lee is correct about the dxf code not being there is the color of an entity is ByLayer.  You will have to put it in the dxf code list like he shows.
Tim

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

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help about print hatch in block!
« Reply #15 on: December 22, 2010, 11:34:56 AM »
And Lee is correct about the dxf code not being there is the color of an entity is ByLayer.  You will have to put it in the dxf code list like he shows.

Thanks Tim, I completely overlooked the original request with my explanations...  :oops:

duyhung

  • Guest
Re: Help about print hatch in block!
« Reply #16 on: December 22, 2010, 12:41:11 PM »
Thanks all.
Hey I don't know much about advance lisp. I write lisp as beginner, apload and run lisp. Can you give me one complete lisp?
In my country it's 0 hour 37 minutes. When you are working I'm sleep  :-)
Thanks!

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Help about print hatch in block!
« Reply #17 on: December 22, 2010, 12:54:58 PM »
Usually we help, we don't give, but since you are new here, here is a complete lisp.

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

    (vl-load-com)
    (vlax-for blk (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object)))
        (vlax-for i blk
            (if (= (vla-get-ObjectName i) "AcDbHatch")
                (vla-put-Color i 250)
            )
        )
    )
    (command "_.regenall")
    (princ)
)
Tim

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

Please think about donating if this post helped you.

duyhung

  • Guest
Re: Help about print hatch in block!
« Reply #18 on: December 22, 2010, 01:02:24 PM »
Thanks Tim I know and I'll study more about lisp!.

pBe

  • Bull Frog
  • Posts: 402
Re: Help about print hatch in block!
« Reply #19 on: December 23, 2010, 12:45:54 AM »
Hence the 2nd post

plain and simple  :-)
and it works
except the nested part of course:


« Last Edit: December 23, 2010, 12:54:57 AM by pBe »