乐筑天下

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

[编程交流] lisp routine to modify X, Y an

[复制链接]

18

主题

81

帖子

63

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 15:47:15 | 显示全部楼层 |阅读模式
hey all,
 
i am trying to figure out a way to be able to take a block and change the x y and z axis from one value to another. for example something i currently have would be a tag that has a value of 48.000 for all three axis. i want to take that and change it to a different value of lets say 96.000.
 
does anyone know of a lisp that would be out there that would be able to do this rather than selecting what you want to change going to properties and changing each axis one at a time. i just find that this is a little slow and would like to find another way to do it.  any and all help is appreciated.
 
thank you
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:03:10 | 显示全部楼层
If you set your block definitions to 'scale uniformly' then you'd only need to fill in the X value.
回复

使用道具 举报

18

主题

81

帖子

63

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 16:04:40 | 显示全部楼层
i hear what you are saying, sadly the company that i work for has blocked us from changing that. or in other words i can change it today but that is something that they change back at the end of the day. so that is another reason that i want to come up with something to bypass that so i dont have to set that each day that i go into a drawing.
 
thank you for the information
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:21:34 | 显示全部楼层
Here's a quick one:
  1. (defun c:foo (/ i s) (if (and (not (initget 2))   (setq i (getreal "\nEnter block scale: "))   (setq s (ssget ":L" '((0 . "insert"))))     )   (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))     (entmod (mapcar '(lambda (x)                 (if (member (car x) '(41 42 43))                   (cons (car x) i)                   x                 )               )              (entget b)      )     )   ) ) (princ))
 
This might be a better if your blocks have attributes:
  1. (defun c:foo (/ i s) (if (and (not (initget 2))   (setq i (getreal "\nEnter block scale: "))   (setq s (ssget ":L" '((0 . "insert"))))     )   (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))     (foreach c '("X" "Y" "Z")(vl-catch-all-apply 'vlax-put (list b (read (strcat c "ScaleFactor")) i))     )   ) ) (princ))(vl-load-com)
回复

使用道具 举报

18

主题

81

帖子

63

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 16:29:40 | 显示全部楼层
ronjonp***
 
this works awsome. being that i really only use two scales (48.000 and 96.000) would it be possible to have this set to select the object and type in the command and have it auto set to either one of those numbers. so for example being that the command name "foo"
 
if it was "foo48" to scale any selected objects to 48.000 and "foo96"  to scale to 96.000. just a thought.
 
but thank you very much for helping with this either way this is going to help me for sure. thank you again
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:35:06 | 显示全部楼层
Try this .. will remember last scale used.
  1. (defun c:foo (/ i s) (or (setq i (getenv "ScaleIt")) (setq i "48.")) (if (and (not (initget 2))   (setq i (cond ((getreal (strcat "\nEnter block scale[]: ")))                 ((read i))           )   )   (setq s (ssget ":L" '((0 . "insert"))))   (setenv "ScaleIt" (vl-princ-to-string i))     )   (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))     (foreach c '("X" "Y" "Z")(vl-catch-all-apply 'vlax-put (list b (read (strcat c "ScaleFactor")) i))     )   ) ) (princ))(vl-load-com)
回复

使用道具 举报

18

主题

81

帖子

63

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 16:39:43 | 显示全部楼层
 
 
 
this is awsome! now i am trying to run thru what you wrote to understand it a little more so i can learn how to write this stuff slowly. where would it be at when you say that it will remember last?
 
thanks
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:52:23 | 显示全部楼层
 
The GETENV and SETENV portions get and set (in the registry) the number used.
  1. (defun c:foo (/ i s) [b](or (setq i (getenv "ScaleIt")) (setq i "48."))[/b] (if (and (not (initget 2))   (setq i (cond ((getreal (strcat "\nEnter block scale[]: ")))                 ((read i))           )   )   (setq s (ssget ":L" '((0 . "insert"))))   [b](setenv "ScaleIt" (vl-princ-to-string i))[/b]     )   (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))     (foreach c '("X" "Y" "Z")(vl-catch-all-apply 'vlax-put (list b (read (strcat c "ScaleFactor")) i))     )   ) ) (princ))(vl-load-com)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-6 15:02 , Processed in 0.576414 second(s), 69 queries .

© 2020-2025 乐筑天下

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