乐筑天下

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

[编程交流] Error : bad argument type: 2D/

[复制链接]

8

主题

37

帖子

30

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 17:10:02 | 显示全部楼层 |阅读模式
hello everyone, i'm trying a lisp called branch to creat a takeoff for ducts.but the problem is that when i select the lines its giving me an Error : bad argument type: 2D/3D point: nil. plz help me.
  1. (vl-load-com)(defun C:BD (/ ang1 ang2 ent1 ent2 ent3 ep1 ep3 ipt1 ipt2 ipt21   mp1 mp3 obj1 obj2 obj3 pt1 pt2 pt3 sp1 sp3)(setq ent1 (entsel "\nSelect first line >>")     ent2 (entsel "\nSelect second line >>")     ent3 (entsel "\nSelect third line >>")     obj1 (vlax-ename->vla-object (car ent1))     obj2 (vlax-ename->vla-object (car ent2))     obj3 (vlax-ename->vla-object (car ent3))     )(setq sp1  (vlax-curve-getstartpoint obj1)     ep1  (vlax-curve-getendpoint obj1)     mp1  (mapcar (function (lambda (a b) (/ (+ a b) 2))) sp1 ep1)     sp3  (vlax-curve-getstartpoint obj3)     ep3  (vlax-curve-getendpoint obj3)     mp3  (mapcar (function (lambda (a b) (/ (+ a b) 2))) sp3 ep3)     ipt1 (vlax-invoke obj1 'intersectwith obj3 0)     ipt2 (vlax-invoke obj2 'intersectwith obj3 0)     ang1 (angle ipt1 mp1)     ang2 (angle ipt2 ipt1)     pt1  (polar ipt1 ang1 100)     pt2  (polar ipt2 ang1 100)     pt3  (polar ipt1 ang2 100)     )    (command "_.break" ent1 "f" "_non" pt1 "_non" ipt1)    (command "line" "_non" pt1 "_non" pt2 "")    (command "line" "_non" pt1 "_non" pt3 "")(princ))
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 17:27:23 | 显示全部楼层
You need to be sure is that the first & the second lines selected should intersect with the third line.
Besides that, the three new variables that represents new coordinate points (pt1 , pt2 and pt3) should also be placed on the same curve object (line as in you example) to allow the command break slice them into tow pieces.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:32:38 | 显示全部楼层
The code reminded of the repetition in code, just me I try to use library defuns for consistency.
 
  1. ; library routine for midpoint of a line loaded at start up; note a pline need to use getpointatdist.(defun midptL (obj )(mapcar (function (lambda (a b) (/ (+ a b) 2)))(vlax-curve-getstartpoint obj) (vlax-curve-getendpoint obj)) ; mapcar) ; defun; using posted code(setq mp1 (midptL obj1))(setq mp3 (midptL obj3))
回复

使用道具 举报

8

主题

37

帖子

30

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 17:42:41 | 显示全部楼层
 
thanx tharwat.. now i know whats the problem.
回复

使用道具 举报

8

主题

37

帖子

30

银币

初来乍到

Rank: 1

铜币
40
发表于 2022-7-5 17:58:44 | 显示全部楼层
 
thanx bigal for ur reply. i dont know anything about lisp writing. so i dont know how to use your code to solve the problem.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 18:08:23 | 显示全部楼层
 
Excellent, you are welcome.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:17:27 | 显示全部楼层
Xpr0 if you find your self when starting a code project that you need to repeat maybe 5-6 lines of code a lot you can make them a defun then you can generally just "CALL" them from 1 line through out the code. The example was to find the mid pt of a line or pline you add this defun to say Acaddoc.lsp then you only need (setq pt (midpt obj)) in your new code. As your code gets bigger 200 lines etc using little defuns saves a lot of typing time and reduces any typo errors.
 
The best example is http://www.lee-mac.com who has a vast library of useful little functions and you will see his defun code in lots of posts here.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 09:28 , Processed in 0.408357 second(s), 66 queries .

© 2020-2025 乐筑天下

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