+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Jan 2016
    Posts
    89

    Default Changing a hatch pattern scale, from a solid hatch

    Registered forum members do not see this ad.

    I've read the documentation in the autocad site and to change from solid to other kind of hatch you must mess up 2 dxf codes. 70 is 1 or 0 accordingly to solid or not. 2 is the hatch patern indeed. and finally 41 is the dxf for the scale of the pattern.

    So I tried to do the following:


    Code:
    (defun c:efg ( / trama solido e o s x texto tipodepeca z y)
        (if (setq s (ssget "_:L" '((0 . "HATCH"))))
            (repeat (setq i (sslength s))
                (setq e (ssname s (setq i (1- i)))
                      x (entget e)
                      trama (cdr (assoc 2 x))
    				  solido (cdr (assoc 70 x))
    				 
    
                )
    
    			(setq z (entmod (subst 0 solido x))) ;;;; change the dxf 70 from 1 (solid) to 0 (not solid)
    		
    			
    				
    				(if (= trama "SOLID") 
    					
    					(progn
    						(setq y (entmod (subst '(8 . "est.Trama") (assoc 8 x) z))) ;;;; Changes layer
    						
    						(setq w (entmod (subst '(2 . "AR-CONC") (assoc 2 x) y))) ;;;;Changes type of hatch
    						
    						(entmod (subst '(41 . 0.01) (assoc 41 x) w)) ;;;;Changes pattern scale (or shouldn't?)
    	 			
    						
    					)
    				)
                
            )
        )
    
        (princ)
    )
    Basically I change the dxf 70 from 1 to 0 (so that I can enable a not-solid hatch) and then change the dxf 2 to other pattern.

    The problem is that everything works allright, but the scale pattern doesnt change. (the layer and the hatch name are correct).

    Does this have to do with the order in which I modify the settings?
    Last edited by CesarA; 13th Jan 2016 at 03:42 pm.

  2. #2
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Jan 2016
    Posts
    89

    Default

    By the way I'm also trying to delete some hatches using
    Code:
    (ssdel x s)
    which translantes to (ssdel ename sslist) or something similar. I think the command is correctly written, but he doesnt delete the hatch regardless.

    Edit: solution for removal:
    Code:
    (command "erase" e "")
    The pattern scale problem persists somehow, any hint?
    Last edited by CesarA; 13th Jan 2016 at 04:48 pm.

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,574

    Default

    ssdel will remove an entity from a selection set; use entdel to set the erase flag for an entity in the drawing database.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  4. #4
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Jan 2016
    Posts
    89

    Default

    damn Lee mac, when I've seen you replied I hoped you had a hint on the pattern scale, the deletion is taken care of, the first problem persists tough..

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,574

    Default

    Quote Originally Posted by CesarA View Post
    damn Lee mac, when I've seen you replied I hoped you had a hint on the pattern scale, the deletion is taken care of, the first problem persists tough..
    Excuse me?
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  6. #6
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Jan 2016
    Posts
    89

    Default

    hmm.. yes? I didn't mean "damn you lee mac", but rather "damn my luck, lee mac" if that's what is bothering you I'm more than happy with your help

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,574

    Default

    I don't believe that you can modify a HATCH entity in this way in order for the pattern to display correctly, as the DXF data for a pattern filled hatch contains separate pattern data which is not present for a solid hatch. Furthermore, the pattern name and pattern type ActiveX properties are read-only, which would indicate that such objects cannot be tranformed into each other.

    I believe you would instead need to rebuild the HATCH to include this additional data - for this, I would strongly recommend using the ActiveX(COM) methods offered by Visual LISP, as entmake'ing a HATCH entity can be troublesome.

    Here are some examples of how to create a hatch using Visual LISP:

    Isometric Hatched Triangle
    Offset & Hatch Polylines
    Solid Hatch in Visual LISP
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  8. #8
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Jan 2016
    Posts
    89

    Default

    You are probably right.. anyways I checked a dxf list of a hatch and something strange happens


    ((-1 . <Entity name: 7ffff894590>) (0 . "HATCH") (330 . <Entity name: 7ffffb06e50>) (5 . "5F4761") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "est.Trama") (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "AR-CONC") (70 . 0) (71 . 0) (91 . 1) (92 . 3) (72 . 0) (73 . 1) (93 . 4) (10 3891.11 -3551.41 0.0) (10 3890.86 -3551.41 0.0) (10 3890.86 -3551.11 0.0) (10 3891.11 -3551.11 0.0) (97 . 0) (75 . 0) (76 . 1) (52 . 0.0) (41 . 0.01) (77 . 0) (78 . 13) (53 . 0.872665) (43 . 0.0) (44 . 0.0) (45 . 0.071726) (46 . -0.00627521) (79 . 2) (49 . 0.0075) (49 . -0.0825) (53 . 6.19592) (43 . 0.0) (44 . 0.0) (45 . -0.0138751) (46 . 0.0752192) (79 . 2) (49 . 0.006) (49 . -0.066) (53 . 1.75321) (43 . 0.00597717) (44 . -0.000522934) (45 . 0.0578509) (46 . 0.068944) (79 . 2) (49 . 0.00637402) (49 . -0.0701142) (53 . 0.806066) (43 . 0.0) (44 . 0.02) (45 . 0.106724) (46 . -0.0165519) (79 . 2) (49 . 0.01125) (49 . -0.12375) (53 . 1.68661) (43 . 0.00889367) (44 . 0.0186207) (45 . 0.0934662) (46 . 0.0974119) (79 . 2) (49 . 0.00956103) (49 . -0.105171) (53 . 6.12932) (43 . 0.0) (44 . 0.02) (45 . 0.0934662) (46 . 0.0974119) (79 . 2) (49 . 0.009) (49 . -0.099) (53 . 0.366519) (43 . 0.01) (44 . 0.015) (45 . 0.0596907) (46 . -0.0402619) (79 . 2) (49 . 0.0075) (49 . -0.0825) (53 . 5.68977) (43 . 0.01) (44 . 0.015) (45 . 0.0243315) (46 . 0.072515) (79 . 2) (49 . 0.006) (49 . -0.066) (53 . 1.24706) (43 . 0.0149742) (44 . 0.0116448 ) (45 . 0.0840222) (46 . 0.0322531) (79 . 2) (49 . 0.00637402) (49 . -0.0701142) (53 . 0.654498 ) (43 . 0.0) (44 . 0.0) (45 . 0.00121599) (46 . 0.0332894) (79 . 6) (49 . 0.0) (49 . -0.0652) (49 . 0.0) (49 . -0.067) (49 . 0.0) (49 . -0.06625) (53 . 0.1309) (43 . 0.0) (44 . 0.0) (45 . 0.026307) (46 . 0.0394412) (79 . 6) (49 . 0.0) (49 . -0.0382) (49 . 0.0) (49 . -0.0637) (49 . 0.0) (49 . -0.02525) (53 . 5.71595) (43 . -0.0223) (44 . 0.0) (45 . 0.0533822) (46 . -0.00225549) (79 . 6) (49 . 0.0) (49 . -0.025) (49 . 0.0) (49 . -0.078 ) (49 . 0.0) (49 . -0.1035) (53 . 5.54142) (43 . -0.0323) (44 . 0.0) (45 . 0.0583186) (46 . 0.0100105) (79 . 6) (49 . 0.0) (49 . -0.0325) (49 . 0.0) (49 . -0.0518 ) (49 . 0.0) (49 . -0.0735) (98 . 0))

    A lot of the codes repeat themselves.. shouldn't it be one code group for each parameter? Does anyone knows why this happens?

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,574

    Default

    Quote Originally Posted by CesarA View Post
    A lot of the codes repeat themselves.. shouldn't it be one code group for each parameter? Does anyone knows why this happens?
    There will be a set of 'pattern' DXF groups for each edge definition for the HATCH entity, so yes, the DXF groups will be repeated (this is similar to how DXF groups 10, 40, 41, 42 & 91 are repeated for each vertex of an LWPOLYLINE).
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  10. #10
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Jan 2016
    Posts
    89

    Default

    Registered forum members do not see this ad.

    Hmm this is interesting, this means i can probably create a similar list beyond the identity and coordinates of the hatch, and that way I'd probably have exactly what I want. Thanks Lee

Similar Threads

  1. Select Hatch Pattern by Scale and pattern
    By 3dwannab in forum AutoLISP, Visual LISP & DCL
    Replies: 19
    Last Post: 9th Feb 2017, 08:02 pm
  2. Hatch Pattern Scale
    By MisterJingles in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 26th Jan 2011, 09:51 pm
  3. Acad.lsp - Hatch Scale / Pattern..
    By hardwired in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 6th Nov 2009, 02:03 pm
  4. Changing the Auto hatch pattern in a wall style
    By Steamineagle in forum Architecture & ADT
    Replies: 0
    Last Post: 6th Jun 2008, 01:49 pm
  5. hatch pattern scale
    By allanp in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 26th Dec 2005, 02:25 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts