乐筑天下

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

[编程交流] Changing Z-values for Mep Wire

[复制链接]

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 06:58:10 | 显示全部楼层 |阅读模式
Hi,
 
I've created a lisp routine to universally change all Z-values to zero for vertexes of electrical wires.
 
This has worked beautifully, up until now that is.
 
In the attached file I get 'exception occured'. Even worse, my routine seems to eliminate vertexes at times
 
I think this may be caused by the extreme values och X and Y coord.
 
Other than that, I'm essentially stuck....
 
  1. (defun c:ELZ (/ SelectionSet SelectionLength CurrentEntity CurrentObject CoordList CoordLength)  (princ "\nElevation Zero") (vl-load-com)  (setq OldOsMode (getvar "OSMODE"))  (setvar "OSMODE" 0)  (setq SelectionSet (ssget "x" '((0 . "AECB_WIRE"))))  (setq SelectionLength (sslength SelectionSet))  (princ SelectionLength)  (setq i 0)  (repeat SelectionLength(setq CurrentEntity (ssname SelectionSet i) i (1+ i))(setq CurrentObject (vlax-ename->vla-object CurrentEntity))(setq CurrentLocation (vlax-get CurrentObject 'Location))(setq CurrentLocation (subst 0.0 (nth 2 CurrentLocation) CurrentLocation))(vlax-put CurrentObject 'Location CurrentLocation)(setq CoordList (vlax-get CurrentObject 'Coordinates)) (setq CoordLength (/ (length CoordList) 3))(setq CurrentNormal (list 0.0 0.0 1.0))(vlax-put CurrentObject 'Normal CurrentNormal)(setq j 2)(repeat CoordLength (setq CoordList (LM:SubstNth 0.0 j CoordList)) (vlax-put CurrentObject 'Coordinates CoordList) (setq j (+ 3 j)))  )(princ)(setvar "OSMODE" OldOsMode))(defun LM:SubstNth ( a n l / i )   (setq i -1)   (mapcar '(lambda ( x ) (if (= (setq i (1+ i)) n) a x)) l))
test.dwg
回复

使用道具 举报

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 08:28:49 | 显示全部楼层
Ok, so I've continued troubleshooting the file above and it seems that it has to do with the mep object having vertex duplicates
 
The issue alltogether arises from the line
 
  1. (vlax-put CurrentObject 'Coordinates Coordlist)
 
I've also tried
 
  1. (vla-put-coordinates CurrentObject Coordlist)
 
After converting the coordlist to a safearray variant
 
It seems alltogether that the Coordinates for the object is somewhat corrupted, as I'm not allowed to edit the list or variant
 
Any tips?
 
P.s. you probably need mep object enabler to see anything in the attached dwg
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 10:05 , Processed in 0.917824 second(s), 67 queries .

© 2020-2025 乐筑天下

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