乐筑天下

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

[编程交流] 计算新i的问题

[复制链接]

59

主题

327

帖子

268

银币

后起之秀

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

铜币
295
发表于 2022-7-6 12:00:01 | 显示全部楼层 |阅读模式
啊。。
 
这是我的代码:
 
  1. (defun c:test (/ )
  2. (setq entity (car (entsel "\nSelect a block: ")))
  3. (if entity
  4.    (progn
  5.      (setq data (entget entity))
  6.    
  7.      (if (= (cdr (assoc 0 data)) "INSERT")
  8. (progn   
  9.   (setq block_ins (cdr (assoc 10 ent_data))
  10.    
  11. block_scx (cdr (assoc 41 ent_data))
  12.    
  13. block_rot (cdr (assoc 42 ent_data))
  14.    
  15. block_rot (cdr (assoc 50 ent_data))
  16.   )
  17. (setq point1 (polar block_ins (+ block_rot (* 0.5 pi)) 150))
  18. (command "_.insert" "w1" point1 block_scx block_scy block_rot)
  19. )
  20.      )
  21.    )
  22. )
  23. (princ)
  24. )

 
这就是为什么会发生:在一个图形中,我有一个块,第一个或原点块。我在它旁边再划一个街区,要么在同一条基线上离它不远,要么在同一条基线上离它不远。两者之间的距离应为150mm。
 
我想没有什么困难,但我一直坚持这样做:
 
 
我会在其中添加带有initget/keyword的选项(左/右),但我甚至没有走那么远。
 
有人能把我踢向正确的方向吗?我不需要完整的Lisp程序,只是解释如何做到这一点。
 
谢谢
马可。
130009vgvzgnn6q2gzn7mm.jpg
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 12:12:06 | 显示全部楼层
ent_数据不应该是数据吗-大卫
回复

使用道具 举报

59

主题

327

帖子

268

银币

后起之秀

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

铜币
295
发表于 2022-7-6 12:20:06 | 显示全部楼层
 
哎呀。。。是的:我想我是真的瞎了。
这个呢?
 
  1. block_rot (cdr (assoc 42 ent_data))
  2.    
  3. block_rot (cdr (assoc 50 ent_data))

 
相同变量名的两倍。。。。
 
我现在又在做了。。。
Tnx的回复。
回复

使用道具 举报

59

主题

327

帖子

268

银币

后起之秀

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

铜币
295
发表于 2022-7-6 12:32:54 | 显示全部楼层
这不是最方便的发帖方式,但要求“内联”这对我来说很好。
 
  1. ; anyone that can help me?
  2. ; thank you
  3. ; I want to place a block 150mm beside an allready placed block.
  4. ; Same angle, same scale.
  5. ; But I want to reach the goal not by getting complete routine.
  6. ; So only the kick in my %$# is enough (I hope)
  7. ;
  8. ; Some parts I base on another routine, so not all of it is clear to me.
  9. ; I have marked them with a "?"...
  10. (defun c:test (/ ); creating the function -> I must fill in the local variables when ready wrinting routine
  11. ; set some variables
  12. (setq  entity (car (entsel "\nSelect a block: ")) ; get the info from the block allready placed
  13. data (entget entity)    ; get "?" out of entity and put it in data
  14. block_ins (cdr (assoc 10 data))   ; get the insertionpoint of the block allready placed
  15.       ; why not block_ins (cdr (assoc 10 entity)) ?
  16.       ; Because of the entget thingy...
  17.       ; I'll go to the Alisp manual I have to explore that.
  18. block_scx (cdr (assoc 41 data))   ; get the scale in x direction of the block allready placed
  19. block_scy (cdr (assoc 42 data))   ; get the scale in y direction of the block allready placed
  20. block_rot (cdr (assoc 50 data))   ; get the rotation of the block allready placed
  21.       ; I believe I have to turn this in to degrees (?)
  22. block_rot_dgr (/ (* block_rot 180.0) pi) ; Like this.
  23. ); end of the setq
  24. ; I have the info I need from the existing block.
  25. ; Now set the new insertion point, called pt1
  26. (setq dist (Getdist "\nDistance?  :")  ; Get distance by prompt
  27. ; this is where I mess things up:
  28. ; pt1 (polar block_ins (+ block_rot_dgr (* 0.5 pi)) dist); ==> does not work
  29. ; pt1 (polar block_ins (* 0.5 pi) dist); no good either...
  30. pt1 (polar block_ins (* 1 pi) dist); no good either...
  31. ; AArrgghh - HOw to get that point ??
  32. ); end of the setq
  33. (setvar "osmode" 0); just to turn off quickly for command function
  34. (command "_.insert" "w1" pt1 block_scx block_scy block_rot_dgr)
  35. (princ)
  36. ); end of function
回复

使用道具 举报

59

主题

327

帖子

268

银币

后起之秀

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

铜币
295
发表于 2022-7-6 12:49:43 | 显示全部楼层
我有一个自己的派对。。。
 
  1. pt1 (polar block_ins (+ block_rot (* 0.5 pi)) dist)

 
... 就是这样。。。
回复

使用道具 举报

59

主题

327

帖子

268

银币

后起之秀

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

铜币
295
发表于 2022-7-6 12:50:48 | 显示全部楼层
这就是我想到的。
 
  1. ;;; Addblock.lsp by MarcoW on CadTutor
  2. ;;; Written 21-12-2009
  3. ;;; To place a block next to another with same rotation and scaling
  4. ;;;
  5. ;;; Any improvements or comments are more than welcome!
  6. (defun c:addblock (/        newblock    entity      data
  7.     block_ins   block_scx   block_scy   block_rot
  8.     block_rot_dgr    dist        pt1
  9.     pt2        oldosmode   side
  10.    )
  11. (setq newblock      (cdr (assoc 2 (entget (car (entsel "\nSelect object to place (new block): " )))))
  12. entity       (car (entsel "\nSelect an allready placed block:"))
  13. data       (entget entity)
  14. block_ins     (cdr (assoc 10 data))
  15. block_scx     (cdr (assoc 41 data))
  16. block_scy     (cdr (assoc 42 data))
  17. block_rot     (cdr (assoc 50 data))
  18. block_rot_dgr (/ (* block_rot 180.0) pi)
  19. dist       (getdist "\nDistance?  : ")
  20. pt1       (polar block_ins (+ block_rot (* 0.5 pi)) dist)
  21. pt2       (polar block_ins (+ block_rot (* 1.5 pi)) dist)
  22. oldosmode     (getvar "osmode")
  23. )
  24. (setvar "osmode" 0)
  25. (initget "L R")
  26. (setq
  27.    side (getkword
  28.    "\nOn wich side do you want the new block? (L/R) <R>:  "
  29. )
  30. )
  31. (cond
  32.    ((= side "L")
  33.     (command "_.insert" newblock pt2 block_scx block_scy block_rot_dgr)
  34.    )     ;
  35.    (t
  36.     (command "_.insert" newblock pt1 block_scx block_scy block_rot_dgr)
  37.    )
  38. )
  39. (setvar "osmode" oldosmode)
  40. (princ)
  41. )

 
目前:问题已解决。
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 13:00:27 | 显示全部楼层
为什么不复制一下呢-大卫
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 10:12 , Processed in 0.326003 second(s), 69 queries .

© 2020-2025 乐筑天下

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