K Baden Posted August 10, 2017 Share Posted August 10, 2017 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) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 10, 2017 Share Posted August 10, 2017 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) Quote Link to comment Share on other sites More sharing options...
K Baden Posted August 10, 2017 Author Share Posted August 10, 2017 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. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 10, 2017 Share Posted August 10, 2017 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")))) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 10, 2017 Share Posted August 10, 2017 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. Quote Link to comment Share on other sites More sharing options...
K Baden Posted August 10, 2017 Author Share Posted August 10, 2017 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 10, 2017 Share Posted August 10, 2017 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. Quote Link to comment Share on other sites More sharing options...
K Baden Posted August 10, 2017 Author Share Posted August 10, 2017 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. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 10, 2017 Share Posted August 10, 2017 Good to know that you got it solved and working as needed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.