Bill Tillman Posted February 14, 2012 Posted February 14, 2012 I am trying to create a cut-away section of a concrete slab for a detail, all of which is being drawn by VLISP. My confusion right now is this entmake utility which Lee-Mac shared with me long ago. I have tried all kinds of combinations with the numbers in this list but so far the AR-CONC hatch pattern I is not showing up. There is no error message or any debugging information presented, the code just exits quietly and I'm left wondering what is wrong. My code draws a polyline to represent the slab and then all I want to do is to fill the interior of the shape with the AR-CONC hatch with a scale of 0.25. (defun c:dummyhatch () (vl-load-com) (setq slabdp 6) (setq afrmdp 3) (setq pt1 '(0.0 0.0)) (setq pt2 (polar (polar pt1 (dtr 0.0) slabdp) (dtr 90.0) 1.75)) (command "._PLINE" pt1 "@6.5<90" "@2<350" "@1.6875<339" "@1.625<325" pt2 "@1.75<270" (strcat "@" (rtos slabdp) "<180") "") (entmake (list '(0 . "HATCH") '(100 . "AcDbEntity") '(8 . "0") '(62 . 2) '(100 . "AcDbHatch") '(10 0 0 0) '(210 0 0 1) '(2 . "AR-CONC") '(70 . 0) '(71 . 0) '(91 . 1) '(92 . 0) ;'(72 . 1) '(73 . 0) ;'(93 . 3) '(10 0 0 0) '(97 . 0) '(41 . 0.25) '(75 . 0) '(76 . 1) '(47 . 0.0334902) '(98 . 1) '(10 3.0 3.0 0.0))) (princ) ); end function (defun dtr (x) (* pi (/ x 180.0)) ); end function Quote
Lee Mac Posted February 14, 2012 Posted February 14, 2012 My confusion right now is this entmake utility which Lee-Mac shared with me long ago. AFAIK, I've never used entmake to create a Hatch, I always opt for the 'AddHatch' method. Quote
Stefan BMR Posted February 14, 2012 Posted February 14, 2012 Just to follow your way: (defun c:dummyhatch () (vl-load-com) (setq slabdp 6) (setq afrmdp 3) (setq pt1 '(0.0 0.0)) (setq pt2 (polar (polar pt1 (dtr 0.0) slabdp) (dtr 90.0) 1.75)) (command "-HATCH" "P" "AR-CONC" "0.25" "0.0" "W" "Y" pt1 "@6.5<90" "@2<350" "@1.6875<339" "@1.625<325" pt2 "@1.75<270" (strcat "@" (rtos slabdp) "<180") "" "" "") (princ) ); end function (defun dtr (x) (* pi (/ x 180.0)) ); end function Quote
Bill Tillman Posted February 14, 2012 Author Posted February 14, 2012 AFAIK, I've never used entmake to create a Hatch, I always opt for the 'AddHatch' method. Lee, and they always say "The eyes are the first thing to go....!" Yes, you did indeed at one time use entmake for a hatch. You wrote a wonderful program which helped me do elevation marks for T.O. Steel dimensions the union ironworkers in NYC were constantly asking me for. That code snippet I included was verbatim from the one you posted for me way back in the Spring of 2009. The only good thing about working in NYC in the Spring is that at least your not working in NYC in the Winter. Anyway, I will look into that AddHatch method and see what it can do. Thanks. Quote
Bill Tillman Posted February 14, 2012 Author Posted February 14, 2012 Ok, everyone remember this is an e-mail reply and you cannot see the LMAO look on my face. This is meant to be constructive and not intentionally mean-sprited reply to the above. And hopefully it will shed a little light on what we novice programmers go through in trying to find information. Before you read this, start playing some happy-funny, "Benny Hill Chasing a Naked Woman in fast forward" type music in the background for special effects...! I posted this morning and got a reply from the great Lee-Mac himself..that again is meant with all due respect. The guy writes awesome code and I've leaned a truckload reading his information. But his reply was that he never uses entmake to create a hatch.... http://www.cadtutor.net/forum/showthread.php?62985-How-to-create-SOLID-hatch-by-using-Lisp&highlight=AddHatch as well as the original code I submitted was something I copied from one of his examples. The reply from Stephan BMR was insightful and I tested it and found it worked perfect....BUT....and there's always a big BUT...as most slab conditions do, this one has an embed in the corner, which I purposely omitted for clarity sake. Anyway, Stephan's method while workable leaves me trying to figure out how to retrace the pattern for the embed. I succeeded in that but it's just too much to do for all the different conditions I'm working with. And remember, this is still the totally Automated program I'm creating. Ok, so I move forward with Lee-Mac's suggestion of using AddHatch, never used it before so the first thing I do is go into the Help and search and sure enough, there's loads of information on the command, but every damn one of the examples in coded in VB, not VLISP....so I search more on this forum and that's were I find the posting which included an example of Lee-Mac using entmake to do a hatch.... Ok, so I'm moving on and doing more searches for how one can accomplish this task. I was hoping the entmake would work or I could somehow just ask the VLISP code to simply pick a point in the middle of the polygon I created and fill it with the AR-CONC hatch. And to add insult to injury, in the short time it took me to type this, the damn clock has expired on my login and I have to re-login just to get it to post. Life is just a real joke for me! More to come on this one and I'll try and let you know how I came out! Quote
Lee Mac Posted February 14, 2012 Posted February 14, 2012 I don't see where I've used entmake to create a Hatch in the thread to which you have linked... But that is beside the point - I purely recommended the AddHatch method because in my experience I've found entmake to be troublesome where Hatches are concerned, I leave it to you to decide which route you want to follow. Quote
Bill Tillman Posted February 14, 2012 Author Posted February 14, 2012 At the risk of becoming a pain, here is a little more detail on why I need to find a way to have the VLISP code just click in the middle of this enclosed area to create the hatch. There are many conditions and slab depth variances I'm trying to prepare this for. The thought of having 3-4 different blocks for every slab depth that may be selected is not an option so I'm trying to have the code just draw the condition on the fly and be done with it. The sketch attached shows what I want to accomplish: I would like to find a way to have the hatch command give me the choice to just select a point, like where the cursor is located in this view, and fill the interior of the boundary, just like it would do if I chose the hatch command manually. When I run through the process in LISP I don't find a way to have it choose a point to fill. Any suggestions would be appreciated or maybe this just isn't do-able. Quote
Bill Tillman Posted February 14, 2012 Author Posted February 14, 2012 I don't see where I've used entmake to create a Hatch in the thread to which you have linked... But that is beside the point - I purely recommended the AddHatch method because in my experience I've found entmake to be troublesome where Hatches are concerned, I leave it to you to decide which route you want to follow. Lee, thanks again for the assistance. I'm trying to find some more information on the AddHatch method in VLISP. So far everything I'm finding is coming up in VBA. Will keep trying. This task has so many variables in it, like slab thickness, embed thickness, embed leg depth, etc...all of which can be deduced mathematically which will make drawing them on the fly using the variables I already have in this code a breeze. Thus it's important to try and find a way to get the hatch method to allow me to just pick a point inside the boundary area and be done with the concrete hatch. It's typical that this is not a major design part of the drawing, only an aesthetic one, but one the designers will balk at it if I can't find a way to hatch the concrete for them prior to them examining the drawings. Quote
BIGAL Posted February 15, 2012 Posted February 15, 2012 (edited) If I am understanding correct you want to hatch the white line area maybe use pick pt1 (left side) pick pt2 (right side) pick pt3 (approx hatch point) then do a pline as per code then just command -hatch pt3 etc I think this what Lee is getting at with addhatch Just me I would do pline as pt1 pt3 pt4 pt5 pt2 using polar the advantage is that you can create defuns so that your hatch works in any quadrant. Thinking further first pick point is actaually line same as second this gives angle of lines, pick near end can work out end of line then, caters for a non square corner. found this addhatch needs some more varables Lee ? ;; Set Vlisp Environment variables (setq ActiveDoc (vla-get-activedocument (vlax-get-acad-object))) (setq Space (if (= (getvar "cvport") 1) (vla-get-paperspace ActiveDoc) (vla-get-modelspace ActiveDoc) ) ) (vlax-invoke space 'addline Pt1 Pt2)) (vlax-invoke space 'addarc cenpt angle1 angle2 ) (vlax-invoke space 'addhatch pt1 ..........) ; needs more answers Edited February 15, 2012 by BIGAL Quote
BIGAL Posted February 15, 2012 Posted February 15, 2012 Did a bit more digging into addhatch never used it before so others may contradict me but basicly you pick a hatch, then create a polyline then use (vlax-invoke Hatch 'AppendOuterLoop) Hatch is the pattern chosen outerloop is the pline. To do my way you would use Bpoly first to create the "outerloop" It is actually there in the HELP just a case of putting it all together. A short cut (command "-hatch" pt1 "") works. Quote
BIGAL Posted February 16, 2012 Posted February 16, 2012 Sorry for hijacking post. Help bpoly tried (vlax-invoke space 'addbpoly Pt1)) gives ; error: ActiveX Server returned the error: unknown name: "ADDBPOLY" (command "bpoly" pt1 "') works ? I am pretty sure need to use boundary to create Outerloop I will keep looking Bill Quote
Stefan BMR Posted February 16, 2012 Posted February 16, 2012 Bill, here is a sample of vla-AddHatch, minimum tested. However, you have to calculate every single point of hatch contour, either to draw the objects that become the border of the hatch or to create hatch like in my previous post. BTW, the object embedded is a block? If it is, not much a help from vla method. To create hatch with vla-AddHatch , the selection set must contain connected object, i.e. the endpoints must be coincidental. The differences between command and vla-AddHatch is just a matter of speed; however, for a single hatch or two, is not a big deal. (defun ad_hatch (ss / ms echo i obj array hatch) ;ss = selection of object (setq ms (vla-get-ModelSpace ;or Paper Space (vla-get-ActiveDocument (vlax-get-acad-object))) echo (getvar 'cmdecho)) (setvar 'cmdecho 0) (repeat (setq i (sslength ss)) (setq obj (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) obj)) ) (setq array (vlax-safearray-fill (vlax-make-safearray vlax-vbObject (cons 0 (1- (length obj)))) obj)) (setq hatch (vla-AddHatch ms acHatchPatternTypePredefined "AR-CONC" :vlax-false AcHatchObject)) (if (vl-catch-all-apply 'vla-AppendOuterLoop (list hatch array)) (princ "\nEndpoints must be connected.") (progn (vlax-put hatch 'PatternScale 0.25) (if (vl-catch-all-apply 'vla-Evaluate (list hatch)) (progn (princ "\Invalid scale.") (vla-delete hatch) ) ;;; (progn ;;; (vlax-put hatch 'Layer "Hatch") ;;; (vlax-put hatch 'Color 1) ;;; ) ) ) ) (setvar 'cmdecho echo) (princ) ) (defun C:TEST (/ ss) (if (setq ss (ssget)) ;a filter for LINE, ARC, CIRCLE, ELLIPSE, PLINE, SPLINE, REGION may be added (ad_hatch ss)) (princ) ) I didn't put a filter in test function because you will not use this method to get the selection set. I think ssadd is more appropriate for automation. Quote
Lee Mac Posted February 16, 2012 Posted February 16, 2012 Bill, Have we not gone down this road before? http://www.cadtutor.net/forum/showthread.php?65562-To-entmake-or-not-to-entmake&p=448089&viewfull=1#post448089 Did you read the threads I linked you to? Quote
Bill Tillman Posted February 16, 2012 Author Posted February 16, 2012 Yes, but let me explain a little more in depth. I try not to clutter my posts with too much because this project is more complex than one could imagine. The slab section I'm working with has an embed in it, and sometimes, only sometimes, it also has a plate welded to the bottom of the embed which extends down the depth of the slab. Which means I need to keep this area, 1/4" clear along the interior edge. On top of that the user may choose any one of several different slab depths. Maybe that's clear as mud but that's the way it is. I resolved this by doing a two step operation. A few of the things I use in this drawing I've found no other way around this. And for this one, I first draw a polyline for just the area that will require the hatch based on the user's answers to the questions in the Excel spreadsheet. Then I simply choose this area as the hatch target and it's done. I then erase the polyline and redraw it back in to the correct dimensions. It's not an efficient process, but in the end I end up with exactly what's needed and the the routine will work for any set of variables. If the user wants to draw a 6" slab or a 6 ft slab or even a 600 mile slab thickness. The code works and that's what this project is all about. To work with whatever input comes in from the Excel file. Once the user clicks on the macro button in Excel, the whole process is controlled in AutoCAD by this VLISP file. I think I'm up to about 700 lines of code now, including comments, but the damn thing is working and that's not a bad thing. I would love to use AddHatch but I haven't found anything that shows me it works with a point, by simply selecting a single point within the object to be hatched. Quote
BIGAL Posted February 16, 2012 Posted February 16, 2012 Based on your image maybe this is helpfull just need a couple of extra points for the boundary (DEFUN getline () (setq tp1 (entsel "\nSelect wall near end : ")) (setq tpp1 (entget (car tp1))) (setq pt1 (cdr (assoc 10 tpp1))) (setq pt2 (cdr (assoc 11 tpp1))) (setq pt3 (cadr tp1)) (setq wallh (cdr (assoc 39 tpp1))) (setq hts (caddr pt1)) (setq d1 (distance pt1 pt3)) (setq d2 (distance pt2 pt3)) (if (> d1 d2) (progn (setq temp pt1) (setq pt1 pt2) (setq pt2 temp) ) ) (setq ang (angle pt2 pt1)) ) ; end defun (getline) (setq ang1 ang) (setq pt11 pt1) (setq pt12 pt2) (getline) (setq pt3 (polar pt11 ang1 200)) (setq pt4 (polar pt1 ang 200)) (setq osnapold (getvar "osmode")) (setvar "osmode" 0) (command "line" pt11 pt3 pt4 pt1 "") (setq pt3 (getpoint "\npick center")) (command "-hatch" pt3 "") (setvar "osmode" osnapold) You could remove the central pick by fudging a point based on the two lines but though i would see if you used it first, still looking into add bpoly can not find an example Quote
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.