乐筑天下

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

[编程交流] VBA - 'Splinedit' eq

[复制链接]

13

主题

51

帖子

38

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 22:46:22 | 显示全部楼层 |阅读模式
Hi all,
 
I'm new to VBA in AutoCAD I've played with Inventor VBA a bit, but the API appears to be drastically different.
 
I need to manipulate existing splines on a drawing by joining them together via VBA. To achieve this manually, the user would use the command SPLINEDIT and go from there. What is the equivalent, or how do I access the command in VBA?
 
Any suggestions would be greatly appreciated.
 
Thanks and Regards
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 22:52:44 | 显示全部楼层
There isn’t much spline related functionality exposed via the ActiveX API in vanilla AutoCAD.  I think a “ThisDrawing.SendCommand” targeting SPLINEDIT is the most viable option.  
 
AutoLisp, .NET, and ARX are much better equipped for spline manipulation.
回复

使用道具 举报

13

主题

51

帖子

38

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 22:55:10 | 显示全部楼层
ActiveX? Forgive my ignorance, but I'm using VBA, how is that related to ActiveX API?
 
Either way I had started along the path of "ThisDrawing.SendCommand" expecting that would be the case, but I'm finding it really difficult to call on a selection set that I've defined earlier.
 
I have a selection set (called SSetTemp) and it contains one single spline. How do I call that into the "SendCommand"? Once I've started the "SendCommand" I can't call my VBA object SSetTemp, and I can't figure out how to recall the selection set from command line.
 
Thanks for your help.
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 23:01:34 | 显示全部楼层
The ActiveX (or COM) is just the name of the interface used to expose various bits of functionality to VBA. The “various bits”, unfortunately, aren’t all that plentiful.
 
 
 
Here was a way to use a SelectOnScreen call. I’m not sure how useful that “Previous” method would be with other (more automated) selection modes.
 
 
 
http://www.cadtutor.net/forum/showthread.php?19349
回复

使用道具 举报

13

主题

51

帖子

38

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 23:06:04 | 显示全部楼层
Thanks for that. Do you have any reference information regarding splines etc in LISP?
 
The piece of code I'm trying to write, in essence, will combine multiple splines (arranged end to end) into single splines, creating a loop. however there are many loops on the page.
 
My plan was to do something like this:
 
for each spline on thisdoc.modelspace
    splinedit.join (All)
next spline
 
(excuse the home made syntax)
 
So, in VBA I can easily do a "for each" but I can't do a splinedit.
In LISP, I don't know how to do a 'for each' or a splinedit.
 
So, If you have info on 'for each' or 'splinedit' in LISP, I'd greatly appreciate it.
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 23:09:56 | 显示全部楼层
Sadly, it is not that easy in VBA.  Lisp has a much better connection with the AutoCAD command line so, conceivably, would make the SPLINEDIT implementation easier.  I don’t know enough autolisp to make an attempt, though.
 
Perhaps a post should be made in the AutoLISP, Visual LISP & DCL section to entice one of the guru’s there to take a look.
回复

使用道具 举报

13

主题

51

帖子

38

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 23:10:42 | 显示全部楼层
No worries.. I'll give the SendCommand another go (just found something that might be useful) then I'll take a look at the LISP threads. Thanks again for your help.
回复

使用道具 举报

13

主题

51

帖子

38

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 23:15:37 | 显示全部楼层
Okay... Getting warmer... How do I cancel the active command OR (preferably) get the prompt displayed in the command line?
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 23:21:14 | 显示全部楼层
 
 
 
From AutoCAD open the Visual LISP Integrated Developement Environment using the VLIDE command. Then hit F1 to open the Developer Documentation - two sources:


  • DXF Reference > ENTITIES > SPLINE
  • ActiveX and VBA Reference > Object Model > Document > ModelSpace > Spline
The latter being similar to the VBAIDE's Object Browser.
 
 
Sadly, it is not that easy in VBA. Lisp has a much better connection with the AutoCAD command line so, conceivably, would make the SPLINEDIT implementation easier. I don’t know enough autolisp to make an attempt, though.
 
Perhaps a post should be made in the AutoLISP, Visual LISP & DCL section to entice one of the guru’s there to take a look.
</blockquote> 
Nawww... Occasionally we make house calls. :wink:
(^^ Yeah, right... I'm no Guru, but I think I can help ^^)
 
Perhaps this will help accomplish the task at hand:
 
  1. (defun JoinSplines ( / ss) ;; Example function call: (JoinSplines) (while (/= nil (setq ss (ssget '((0 . "SPLINE")))))   (command "._join" (ssname ss 0) ss "")) (princ))
 
The problem being that this will only work with a co-located group of splines.
 
More specifically... if one were, for example, to have two groups of splines and you selected all of them, only the group first selected would join (hence the included while loop, which will permit the user to do this task for each co-located group).
 
If you have an alternative example using either VBA, or VB.NET I *might* be able to port it to Auto/Visual LISP for you, as most of my development is done with ActiveX COM API via Visual LISP. I just don't work with Splines enough to know of a better way at the moment.
 
Hope this helps!
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 23:23:40 | 显示全部楼层
 
Not sure how to cancel from VBA . I would imagine there's an exit, or quit method, no?
 
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 06:17 , Processed in 0.517869 second(s), 72 queries .

© 2020-2025 乐筑天下

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