Hickoz_bro 发表于 2022-7-6 22:46:22

VBA - 'Splinedit' eq

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

SEANT 发表于 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.

Hickoz_bro 发表于 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.

SEANT 发表于 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

Hickoz_bro 发表于 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.

SEANT 发表于 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.

Hickoz_bro 发表于 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.

Hickoz_bro 发表于 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?

BlackBox 发表于 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:
 

(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!

BlackBox 发表于 2022-7-6 23:23:40

 
Not sure how to cancel from VBA . I would imagine there's an exit, or quit method, no?
 
页: [1] 2
查看完整版本: VBA - 'Splinedit' eq