乐筑天下

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

[编程交流] Insert Block, Angle and Move t

[复制链接]

27

主题

126

帖子

99

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
135
发表于 2022-7-5 17:57:21 | 显示全部楼层 |阅读模式
I'm working on this LISP that inserts blocks based on node points and then rotates the inserted block towards the nearest line based on layer. For select blocks, will also move the block to the nearest point.
 
I've attached the full LISP, because it is a longer LISP file. Below are more specific areas of noting.
 
Currently, I'm getting an error of "Command: BLI ; error: bad argument type: lselsetp nil".
 
The insert block based on the node point is what we have had, and currently works as intended.
 
Syntax
 
  1. ;;; --------- SYNTAX -    "layer of pt"       "block name"                     "layer for block"    "visb for blck"              "Angle"    "Adjust Insert"(BLINS_BlockFunction     "E-LITE-CLNG"        "Ceiling Lights"                 "E-LITE-CLNG"        "Ceiling Light - Recessed"   nil        0)(BLINS_BlockFunction     "T-SOUN-FLOR"        "FE Outlet-Duplex-Wall v7.0"     "E-POWR-FLOR"        ""                           0          1)
 
Main Funtion
 
Within the BLINS_BlockFunction, the part that I am adding with the angle and closest point. If the "Adjust Insert" is 0, then it won't move to the nearest wall line. If it is 1, then it will move. Not all blocks are expected to move to the nearest wall line.
 
  1. (defun BLINS_BlockFunction (myBLILayer myBlockName myBlockLayer myVisibility myAA AIns)...(setq pt (cdr (assoc 10 enlist)))        ; declare the point (pt) variable(setq myAngle (BLINS_GetAngle pt myAA)) ; set angle of block insertion.(if (= AIns 0)        ;If Adjust Insert = 0, then keep closestpt the same as insertion point.    (setq closestpt pt))(if (= AIns 1)  ;If Adjust Insert = 1, then set closestpt to nearest wall line.    (setq closestpt myPointTMP))        ;myPointTMP is set in the BLINS_GetAngle function.(command "_-insert" myBlockName closestpt 1 myAngle "")...
 
Determining the Angle
With an earlier version of the code, prior to the error I started getting, it would insert the block at 180 degrees, plus the specified angle noted in the syntax. Even if there was an odd angled wall line near the insertion point.
 
What is expected is that it determines the angle to the line, and then adds the angle from the syntax. The reason for this is to make sure the block comes in perpendicular to the line.
 
  1. (defun BLINS_GetAngle (myPoint myAA / myPoint2 myPointTMP myDistTMP myDist cnt enlist myAngle);;; Get Angle Based on Closest Point To Baseline Set(if         (progn                (setq cnt 0)                (while (< cnt (sslength BLINSBaselineSet))       ; WHILE the length of the set (pointSet) is less than the counter (cnt)                        (setq ename (ssname BLINSBaselineSet cnt))        ; use the SSName function to assign the value from the counter to the (pointSet) variable                        (setq myPointTMP (vlax-curve-getClosestPointTo ename myPoint ))       ; declare the point (pt) variable                        (setq myDistTMP (distance myPoint myPointTMP))                        (if (or (= myDist nil) (< myDistTMP myDist))                                (progn                                        (setq myDist myDistTMP)                                        (setq myPoint2 myPointTMP))                                ) ;end if (or (= myDist nil) (< myDistTMP myDist))                        (setq cnt (+ cnt 1))                        );end while                (setq myAngle (Angle_RTD (angle myPoint myPoint2))) ; "angle" Return Values == An angle, in radians.                ) ;end progn        (setq myAngle 180) ;if (else)        ) ;end if(if (/= myAA nil)  (setq myAngle (+ myAngle myAA)))myAngle) ;defun BLINS_GetAngle(defun Angle_RTD (anglertd)(/ (* anglertd 180.0) pi))
 
Within part of that, it is prompting for the baseline of the line. That part is:
 
  1. (defun BLINS_CreateBaselineSet ()  (setq BLINSBaselineSet                         (ssget "_X" (list                                        (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,POLYLINE,SPLINE")                                        (cons 8 "A-WALL-INTR")                                        ))) );defun BLINS_CreateBaselineSet
 
 
Thanks for any assistance that can be provided.
BLINS_Main - 0008.LSP
回复

使用道具 举报

27

主题

126

帖子

99

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
135
发表于 2022-7-5 18:36:59 | 显示全部楼层
I got the angle portion working, and if AINS variable is set to 0.
 
Now, it is down to the portion of if AINS variable is set to 1, that it would move to the nearest point based on the baseline. This could either be done by moving the block after insertion or the node point prior to insertion. I've been trying different ways to get it to work.
回复

使用道具 举报

27

主题

126

帖子

99

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
135
发表于 2022-7-5 18:47:11 | 显示全部楼层
I've been attempting something along the lines of the code below, to no avail.
 
  1.                      (if (= AIns 1)    ;If Adjust Insert = 1, move node to location of nearest wall line.                         ((if BLINSBaselineSet                         (progn                           (setq count 0)                           (while (< count (sslength BLINSBaselineSet))       ; WHILE the length of the set (pointSet) is less than the counter (cnt)                             (setq enamed (ssname BLINSBaselineSet cnt))        ; use the SSName function to assign the value from the counter to the (pointSet) variable                             (setq nearpt (vlax-curve-getClosestPointTo enamed myPoint))           ; declare the point (pt) variable                             (setq count (+ count 1))                             );end while                           );end progn                         )                     (vla-move epoint pt nearpt)                     (setq closestpt nearpt)                     ))
 
Trying to get the nearest location from the node to the line selection set. Then moving the node from the location spot to that nearest point.
 
I've been getting errors of: "bad argument type: VLA-OBJECT" or "bad argument type: 2D/3D point: nil"
回复

使用道具 举报

27

主题

126

帖子

99

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
135
发表于 2022-7-5 19:04:54 | 显示全部楼层
I've gotten this LISP close to done. Working with one node point, I got it to work, thought it was done. Then when testing with more node points, getting... undesirable results.
 
I put in 3 of the same type of node for block to insert on. First one came in perfect. Second one appears, but then is deleted. The third never appears. I also put in a node for a ceiling light block, that the location of won't be adjusted. The block comes in extremely stretched for some odd reason.
 
I've attached a sample drawing and update of current LISP.
BLI Test.dwg
BLINS_Main - 0015.LSP
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 23:34 , Processed in 0.357042 second(s), 60 queries .

© 2020-2025 乐筑天下

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