sadhu Posted November 19, 2014 Share Posted November 19, 2014 I use the code below to add a polyline to a block made in lisp. I need help for a similar code (similar format and syntax) to add a 1. solid hatch (color by layer) 2. and a circle. to the block. (vla-put-closed (vlax-invoke Blk_Nme ; block name 'AddLightWeightPolyline (list (car pt1) (cadr pt1) (car pt2) (cadr pt2) (car pt3) (cadr pt3) ) ) :vlax-true ) Code syntax to substitute 'AddLightWeightPolyline . All help and/or indication is appreciated. I would like to avoid using ENTMAKE. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 19, 2014 Share Posted November 19, 2014 Hi , Try this and change values to suit your needs of them . (defun c:Test (/ o _add_circle_+_solid) ;; Tharwat 19.11.2014 ;; (princ "\n Pick a sinlge Block to addd Circle with Hatch :") (if (setq o (ssget "_+.:S:E:L" '((0 . "INSERT")))) (progn (defun _add_circle_+_solid (spc pnt rad / c h) ;; spc = Block definition ;; ;; pnt = Circle insertion point ;; ;; rad = Radius of Circle ;; (if (and (setq c (vla-addcircle spc (vlax-3d-point pnt) rad)) (setq h (vla-addhatch spc acHatchPatternTypePredefined "SOLID" :vlax-true ) ) ) (progn (vlax-invoke h 'AppendOuterLoop (list c)) (vlax-invoke h 'Evaluate) ) ) ) (_add_circle_+_solid (vla-item (vla-get-blocks (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) ) (cdr (assoc 2 (entget (ssname o 0)))) ) '(0. 0. 0.) 1.0 ) (vla-regen doc acallviewports) ) ) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
sadhu Posted November 20, 2014 Author Share Posted November 20, 2014 Thank you Tharwat for your reply and suggestion. The code below is what I have for making an anonymous block. What I'm trying to do is solid-hatch the closed polyline and add a circle. I tried to integrate your code but without success. (defun c:pttest() (vl-load-com) (setq radiusPT 5 profon 0.5 pt0 '(0 0 0) Blk_Nme "New_block" *doc (cond (*doc)((vla-get-ActiveDocument (vlax-get-acad-object)))) spc (if (or (eq AcModelSpace (vla-get-ActiveSpace *doc)) (eq :vlax-true (vla-get-MSpace *doc))) (vla-get-ModelSpace *doc) (vla-get-PaperSpace *doc)) BOX_type "steel 0.5" lay "0" ) ;insertion points (setq ins_Pt(getpoint "\n Select insertion point") x1(car ins_Pt) y1(cadr ins_Pt) x2 (- x1 0.2 ) y2 (- y1 0.2 ) boxtype_ins_pt (list x2 y2) ; attribute insertion point p1 (list (- x1 radiusPT) (- y1 profon)) ; for solid hatch p2 (list (- x1 radiusPT) (+ y1 profon)) p3 (list (+ x1 radiusPT) (+ y1 profon)) p4 (list (+ x1 radiusPT) (- y1 profon)) L1 0.02 ptl1 (list (- x1 radiusPT L1) y1) ptl2 (list (+ x1 radiusPT L1) y1) ptl3 (list x1 (+ y1 profon L1)) ptl4 (list x1 (- y1 profon L1)) ) ; make block (setq Blk_Nme (vlax-invoke (vla-get-Blocks *doc) 'Add (list (car ins_Pt) (cadr ins_Pt) 0.) "*U" ) ) ; put closed polyline (vla-put-closed (vlax-invoke Blk_Nme 'AddLightWeightPolyline (list (car p1) (cadr p1) (car p2) (cadr p2) (car p3) (cadr p3) (car p4) (cadr p4)) ) :vlax-true ) ; code to hatch closed polyline and be part of the block ; code to add a circle to the block "Blk_Nme" with center "ins_Pt" and radius "radiusPT" ;insert attribute BOX_type (vlax-invoke Blk_Nme 'AddAttribute 0.02 ;text height acAttributeModePreset; ; attribute visibile "BOX_type" (list (car boxtype_ins_pt) (cadr boxtype_ins_pt) 0.) "BOX_type tag" ; attribute tag BOX_type ; attribute value ) ;insert block (vla-put-layer (setq bObj (vlax-invoke spc ;mSpace 'InsertBlock (setq p1 (list (car ins_Pt) (cadr ins_Pt) 0. ) ) (vla-get-Name Blk_Nme) 1. 1. 1. 0. ) ) lay ) ) 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.