Jump to content

Set specific hatch to dimscale


K Baden

Recommended Posts

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!!!

 

 

(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)
)

Link to comment
Share on other sites

Hi,

 

Something like this one?

(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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"))))

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...