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 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. 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? 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. 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
页:
1
[2]