乐筑天下

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

[编程交流] new to lispsss, need a rewrite

[复制链接]
djw

2

主题

8

帖子

6

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 10:50:21 | 显示全部楼层 |阅读模式
This works good but, I would like to have the 2 objects rotate clockwise..not Counter clockwise
 
(defun c:90R( / e f p a b c i)
(vl-load-com)
(setvar "cmdecho" 1)
(setq e (vlax-ename->vla-object (car (entsel "\nSelect object: "))))
(setq f (vlax-ename->vla-object (car (entsel "\nSelect object: "))))
(setq p (getpoint "\nSelect rotation point: "))
(setq a 1 ; Number of revolutions
b 1 ; Degrees per increment (must be a factor of 90)
c 01 ; Delay between incremental rotation
i 0) ;
(if (= 0 (rem (setq d (/ 90 b)) -1))
(while (
(repeat d
(vla-rotate e (vlax-3d-point p) (* (/ pi 180.0) b))
(vla-rotate f (vlax-3d-point p) (* (/ pi 180.0) b))
(vl-cmdf "delay" c "regen")
)
(setq i (1+ i))
)
)
)
回复

使用道具 举报

8

主题

1647

帖子

1647

银币

初来乍到

Rank: 1

铜币
36
发表于 2022-7-6 10:57:47 | 显示全部楼层
You will get a better and faster response if you post in the correct area of the forum.
 
Question moved to the Lisp section.
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:02:50 | 显示全部楼层
Just change your angle to a negative number. Hell, make 180. -180.
回复

使用道具 举报

51

主题

481

帖子

457

银币

后起之秀

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

铜币
262
发表于 2022-7-6 11:06:49 | 显示全部楼层
djw
Try to use # button to paste your code to be readable as a code
 
  1. LIKE THIS
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 11:15:35 | 显示全部楼层
Hi
Here it goes,
  1. (defun c:90R( / e f p a b c i)(vl-load-com)(setvar "angdir" 1)(setvar "cmdecho" 1)(setq e (vlax-ename->vla-object (car (entsel "\nSelect object: "))))(setq f (vlax-ename->vla-object (car (entsel "\nSelect object: "))))(setq p (getpoint "\nSelect rotation point: "))(setq a 1 ; Number of revolutionsb 1 ; Degrees per increment (must be a factor of 90)c 01 ; Delay between incremental rotationi 0) ; (if (= 0 (rem (setq d (/ 90 b)) -1))(while (< i a)(repeat d(vla-rotate e (vlax-3d-point p) (* (/ pi 180.0) b))(vla-rotate f (vlax-3d-point p) (* (/ pi 180.0) b))(vl-cmdf "delay" c "regen"))(setq i (1+ i))))(setvar "angdir" 0))
 
Regards
Tharwat
回复

使用道具 举报

51

主题

481

帖子

457

银币

后起之秀

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

铜币
262
发表于 2022-7-6 11:19:11 | 显示全部楼层
Check Red code
Why did you select object 2 times (e and f)
  1. (defun c:90R( / e f p a b c i) (vl-load-com) [color=red](defun *error* (msg)[/color][color=red]   (and uFlag (vla-EndUndoMark doc))[/color][color=red]   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")[/color][color=red]       (princ (strcat "\n** Error: " msg " **")))[/color][color=red]   (princ)[/color][color=red])[/color][color=red](setq OldCMDEcho (getvar "cmdecho") ; Save System Variable[/color] (setvar "cmdecho" 1) (setq e (vlax-ename->vla-object (car (entsel "\nSelect object: ")))         f (vlax-ename->vla-object (car (entsel "\nSelect object: ")))         p (getpoint "\nSelect rotation point: ")         a 1 ; Number of revolutions         b 1 ; Degrees per increment (must be a factor of 90)         c 01 ; Delay between incremental rotation         i 0) ; (if (= 0 (rem (setq d (/ 90 b)) -1))   (while (< i a)     (repeat d       (vla-rotate e (vlax-3d-point p) (* (/ pi 180.0) b))       (vla-rotate f (vlax-3d-point p) (* (/ pi 180.0) b))       (vl-cmdf "delay" c "regen")       )    (setq i (1+ i))     )   )      [color=red](setvar "cmdecho" OldCMDEcho) ; restore System Variable[/color][color=#ff0000]      (princ)[/color] )
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:28:24 | 显示全部楼层
Why this?
 
  1. [color=red](and uFlag (vla-EndUndoMark doc))[/color]
 
Or was it just a copy/paste job from my code?
回复

使用道具 举报

51

主题

481

帖子

457

银币

后起之秀

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

铜币
262
发表于 2022-7-6 11:30:16 | 显示全部楼层
Seems like that but there was a code line I didnt paste.
 
  1. (setq uFlag (vla-EndUndoMark doc))
 
Any way welcome back
回复

使用道具 举报

djw

2

主题

8

帖子

6

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 11:35:43 | 显示全部楼层
Thought I was post’n in the correct place? AutoCAD Forums> AutoCAD Customization> AutoLISP, Visual LISP & DCL
Anyhow think U-all for the reply’s.. Alanjt (–180) seems to work,
just try’n to learn, could you translate to plane English?
(vla-rotate e (vlax-3d-point p) (* (/ pi 180.0) b))
 
“(vla-rotate e” =Selected object
e
 
 
“(vlax-3d-point p)”=get 3D x y z of Selected object
e, what doses the “p” do?
 
 
“(* (/ pi 180.0) b))”= ???? 180 = Counter clockwise
-180 clockwise ??????
 
ya I know just try’n to learn..
Asos2000, object 2? Rotating two objects @ the same time..
thanks again…
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:40:17 | 显示全部楼层
 
Read the help file on vlax-3D-point, it creates a variant ( 3-element array of doubles ) from the point 'p'.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 16:52 , Processed in 0.433977 second(s), 72 queries .

© 2020-2025 乐筑天下

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