乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: Bill Tillman

[编程交流] Entmake AR-CONC Hatch为No-

[复制链接]

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 09:02:32 | 显示全部楼层
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
回复

使用道具 举报

0

主题

375

帖子

385

银币

限制会员

铜币
-7
发表于 2022-7-6 09:05:20 | 显示全部楼层
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.
  1. (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.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:10:05 | 显示全部楼层
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?
回复

使用道具 举报

180

主题

639

帖子

463

银币

中流砥柱

Rank: 25

铜币
897
发表于 2022-7-6 09:13:24 | 显示全部楼层
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.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 09:19:50 | 显示全部楼层
Based on your image maybe this is helpfull just need a couple of extra points for the boundary
 
  1. (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
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-9 09:24 , Processed in 0.786264 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表