乐筑天下

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

[编程交流] Can't change line coordin

[复制链接]

17

主题

72

帖子

55

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-5 18:09:37 | 显示全部楼层 |阅读模式
I'm trying to increase a vertical line height by fixing the point with the lowest Y coordinate
 
  1. (defun c:inclength ( / trama e o s x z y w obj patternName a b ponto1 ponto2 diferenca processo)   (if (setq s (ssget "_:L" '((0 . "LINE"))))       (repeat (setq i (sslength s))           (setq e (ssname s (setq i (1- i)))                 x (entget e)                 trama (cdr (assoc 2 x))                          ponto1 (caddr (assoc 10 x)) ;gets Y coordinate of the lowest point                          ponto2 (caddr (assoc 11 x)) ;gets Y coordinate of highest point           )                                (setq diferenca (+ ponto1 9.4)) ;sets the length in coordinate                                                        (entmod (subst diferenca ponto2 x)) ;this doesn't work                       )   )   (princ))
 
I've made some prin1's to check diferenca, ponto1 and ponto2 value and they are all right, I think the problem is on entmod, which doesn't work somehow, and i'm also not getting any kind of error by autocad
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:47:16 | 显示全部楼层
A few points:
 


  • entmod doesn't error when unsuccessful, it will return nil.
  • LINE entities do not contain DXF group 2, so your variable trama will always be nil
  • Nothing will be substituted within the DXF data by your subst expression, as the DXF data is an association list and hence will only contain lists; your subst expression is attempting to substitute numerical values which are not present as distinct items in the list. You should instead construct a new DXF group to be substituted for the appropriate endpoint.
回复

使用道具 举报

17

主题

72

帖子

55

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
85
发表于 2022-7-5 18:57:49 | 显示全部楼层
Yes, trama is a variable i forgot (i take pieces of previous code and modify them to spare work)
 
But, entmod didnt return nil anyways.
 
Something like this maybe?
  1. (entmod (subst (cons 11 (pontoinicial diferenca 0.0) ) (assoc 11 x) x))
 
where pontoinicial is the X coordinate and diferenca the Y coordinate i want to change. I've worked around the problem for now
 
Thank you very much, you're always of such help.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:12:35 | 显示全部楼层
 
But in this case the entmod expression is successful, as you are supplying it with valid data - no substitution is made by subst, so the supplied list (i.e. the original DXF data) is returned and supplied to entmod.
 
It may not always be the end point (DXF 11) which holds the highest y-coordinate.
 
Your current code will also error as pontoinicial is not a valid function; you should use the list function instead (no need for cons, as you are not constructing a dotted pair).
 
You're welcome.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 20:15 , Processed in 0.489786 second(s), 60 queries .

© 2020-2025 乐筑天下

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