乐筑天下

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

[编程交流] rotate3d Lisp, Need help

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 19:45:44 | 显示全部楼层 |阅读模式
Hello everyone!
 
I want to make lisp, that will use "rotate3d" command.
After you select some block, you can press "x", "y" or "z" (several times), and lisp will rotate this block using insertion point as base point by 90 deg. clockwise (around corresponding axis), and when you finish rotating you press Enter and exit from lisp.
For example, you select some block and then press "x" three times, block rotated by 270 deg. around X axis, then press "z" two times, and block rotated by 180 deg., then press Enter and exit from lisp.
 
Is it possible, maybe there are some similar lisps?  
If anyone could give advice it would be greatly appreciated.
Thank you in advance.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:50:42 | 显示全部楼层
Welcome to CADTutor Ascension.
         
        This seemed interesting - try the following:
  1. (defun c:3dbr ( / ang axs bpt ent obj )   (while       (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect block to rotate: ")))           (cond               (   (= 7 (getvar 'errno))                   (princ "\nMissed, try again.")               )               (   (/= 'ename (type ent)) nil)               (   (/= "INSERT" (cdr (assoc 0 (entget ent))))                   (princ "\nPlease select a block.")               )               (   (setq obj (vlax-ename->vla-object ent)                         bpt (vlax-get obj 'insertionpoint)                         ang (/ pi 2.0)                   )                   (princ "\nRotate about [X/Y/Z] : ")                   (while                       (setq axs                           (cdr                               (assoc (grread nil 10)                                  '(                                       ((2 120) 1.0 0.0 0.0)                                       ((2 088) 1.0 0.0 0.0)                                       ((2 121) 0.0 1.0 0.0)                                       ((2 089) 0.0 1.0 0.0)                                       ((2 122) 0.0 0.0 1.0)                                       ((2 090) 0.0 0.0 1.0)                                   )                               )                           )                       )                       (vlax-invoke obj 'rotate3d bpt (mapcar '+ bpt axs) ang)                   )               )           )       )   )   (princ))(vl-load-com) (princ)
 
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 19:52:20 | 显示全部楼层
Lee Mac, Thank you so much for your quick response!
It's exactly what i needed, You make my day!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:55:47 | 显示全部楼层
You're welcome! - It was fun to write
回复

使用道具 举报

1

主题

475

帖子

481

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 19:59:56 | 显示全部楼层
Nicely coded, Lee.
 
 
Henrique
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 20:03:19 | 显示全部楼层
 
Thank you Henrique
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 20:06:17 | 显示全部楼层
I think i catch the meaning. Try to implement other ideas with similar approach
回复

使用道具 举报

40

主题

177

帖子

100

银币

后起之秀

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

铜币
248
发表于 2022-7-5 20:08:32 | 显示全部楼层
Nicely code,thanks lee
 
I want rotate 3DSolid like this ,not a block, can do?
回复

使用道具 举报

15

主题

243

帖子

228

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-5 20:13:41 | 显示全部楼层
 
as per usual, was hoping to hear your explanation of your process in this while loop if at all possible and time allowing
This one is using grread, it appears, short of transformation matricies I haven't seen anything looking quite as abstract. Hoping you could decipher for me..
回复

使用道具 举报

0

主题

301

帖子

301

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-5 20:15:06 | 显示全部楼层
bhull,
 
Actually quite simple.
 
The loop determines if you entered either x , y or z. (asccii "x") -> 120  (ascii "X") ->88 etc.
 
So as soon as you press the "x" key, for example,  Variable axs is set to (1.0 0.0 0.0)
You then add this value to the base point of the object.  Rotation is fixed at 90 degrees.
 
So your 3 arguments to the 'rotate3d method are bpt, the value calculated with mapcar and finally your angle.
 
ymg
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 00:43 , Processed in 0.512379 second(s), 72 queries .

© 2020-2025 乐筑天下

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