+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    33

    Default Set specific hatch to dimscale

    Registered forum members do not see this ad.

    Good morning everyone.
    I have a bit of code for different hatches on my drawing, now i want to add a line that will find all "GRATE" hatch patterns and change them to the dimscale. Can anyone help me out? Thanks in advance!!!


    Code:
    (defun c:IB ()
      (if (setq ss (ssget "X" '((0 . "HATCH") (2 . "CROSS"))))
        (progn
          (setq count 0)
          (repeat (sslength ss)
    	(command "-hatchedit" (ssname ss count) "co" "" ".")
    	(command "-hatchedit" (ssname ss count) "p" "" "32" "")
    	(setq count (1+ count))
    	)
          )
        )
      (princ)
    )

  2. #2
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    5,983

    Default

    Hi,

    Something like this one?
    Code:
    (defun c:Test ( / scl int sel ent)
         (and (setq scl (getvar 'DIMSCALE) int -1 sel (ssget "_X" '((0 . "HATCH")(2 . "GRATE"))))
              (while (setq ent (ssname sel (setq int (1+ int))))
                (vla-put-PatternScale (vlax-ename->vla-object ent) scl)
                )
              )  
      (princ)
      ) (vl-load-com)

  3. #3
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    33

    Default

    This works like a dream for changing the scale to the dimscale. my only issue seems to be that it deletes every occurrence of the hatch except one lol! Any idea why it would be doing that? There are typically multiple of these hatches on our drawings.

  4. #4
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    340

    Default

    Quote Originally Posted by K Baden View Post
    This works like a dream for changing the scale to the dimscale. my only issue seems to be that it deletes every occurrence of the hatch except one lol! Any idea why it would be doing that? There are typically multiple of these hatches on our drawings.
    Maybe the scale is too large to show the pattern?

    See if this highlights them: (sssetfirst nil (ssget "_X" '((0 . "hatch") (2 . "grate"))))

  5. #5
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    5,983

    Default

    Quote Originally Posted by K Baden View Post
    This works like a dream for changing the scale to the dimscale. my only issue seems to be that it deletes every occurrence of the hatch except one lol! Any idea why it would be doing that? There are typically multiple of these hatches on our drawings.
    The program doesn't delete any hatch object at all but maybe the DimScale variable is too big as ronjonp stated earlier.

  6. #6
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    33

    Default

    AH! I've done a bit more testing on the first code, this will only update the scale if the current scale of the hatch is lower than the dimscale. for example, i have 4 GRATE hatches, 2 scaled at 80, two scaled at 120, and my dimscale is 96. It will change the scale of the 2 hatches currently scaled to 80, but the hatches that are 120, disappear. Also, if i have only a GRATE hatch currently scaled at 120, it will not do anything to it.

  7. #7
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    5,983

    Default

    Quote Originally Posted by K Baden View Post
    Here's what ive got. its giving me an error loading now. the error is: "error: malformed list on input"
    ronjonp's suggestion is to copy and paste the codes into your command line right away then hit Enter to see if the hatch patterns are existed and to know if the scale is too big for the patterns or so.

    Please update your post and delete the codes that you have modified because they are not correct.

  8. #8
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    33

    Default

    I am pretty sure i've got it working smoothly now. Thanks so much for the help. I'm extremely new to coding, so this is all still a bit of a foreign language to me! I really appreciate your help, though. It seems to be working fine now with further testing. I'm honestly not sure why i was having some instances for hatch delete. I'm thinking it may have been due to it being associative without a boundary, as i just copied several instances of the same hatch to test.

  9. #9
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    5,983

    Default

    Registered forum members do not see this ad.

    Good to know that you got it solved and working as needed.

Similar Threads

  1. Deleting a Specific Area of a Hatch
    By Casio47 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 9
    Last Post: 10th Nov 2016, 06:10 pm
  2. selecting specific blocks and summing up values of specific attributes
    By hetauma in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 10th Apr 2014, 02:46 pm
  3. LISP - Do routine if specific text is found in a specific block attribute
    By h0okem in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 19th Nov 2011, 05:53 am
  4. Faster way of drawing specific radii archs in specific locations.
    By bbankston in forum AutoCAD Beginners' Area
    Replies: 9
    Last Post: 26th Dec 2010, 03:09 am
  5. Specific Insulation/Batting Hatch
    By Morrison in forum AutoCAD General
    Replies: 9
    Last Post: 14th Mar 2009, 01:24 pm

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