Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Undo command

76 views
Skip to first unread message

Tony Tanzillo

unread,
Nov 29, 2002, 12:46:04 AM11/29/02
to
"farnaz" <farn...@hotmail.com> wrote in message news:f1282...@WebX.maYIadrTaRb...
> Is there a way to undo other than using "sendcommand"?

Not with AutoCAD alone, but you can do this using the
AcadXTransactionManager class from AcadX.arx.

http://www.caddzone.com/acadx


Alfred NESWADBA

unread,
Nov 29, 2002, 5:06:55 AM11/29/02
to
set an "Undo Mark" before your vb/a makes changes and then you can undo it

- alfred -

In article <f1282...@WebX.maYIadrTaRb>, farn...@hotmail.com says...

Alfred NESWADBA

unread,
Dec 3, 2002, 1:15:16 AM12/3/02
to
sorry fro the late answer,

within vb:

ThisDrawing.StartUndoMark
'<do your code>
ThisDrawing.EndUndoMark

where i'm used to have these statements within general functions which run at
the beginning and at the end of application-specific functions, also
controlling setvar's and settings like activelayer, activeucs, ...

- alfred -

In article <f128...@WebX.maYIadrTaRb>, farn...@hotmail.com says...
> Then I can undo it from VBA? Could u show me a small example?
>

Alfred NESWADBA

unread,
Dec 4, 2002, 5:33:25 PM12/4/02
to
i have to say, that was my mistake, i always used it only to give the user the
ability, after my functions where running, to make all undone with one call, i
saw no problem to undo it also within the app-code, yet. sorry

- alfred -

In article <f128...@WebX.maYIadrTaRb>, farn...@hotmail.com says...

> Sorry, I still don't get it. I tried putting marks as u mentioned. Then how do I undo? By using sendCommand? Cus send command doesn't work until I stop VBA from running.
>

Mike Tuersley

unread,
Dec 5, 2002, 9:51:18 AM12/5/02
to
Use copies of the circles, do your intersection thing and erase the
copies...all the while the original circles remain in place.

===============================
Mike Tuersley
PhD @ CADalyst's AutoCAD Clinic
http://www.cadonline.com

James Belshan

unread,
Dec 5, 2002, 11:20:29 AM12/5/02
to
This isn't answering your original question, but it might help you...
If you are only dealing with 2 circles, and not more general shapes, the
area could be found mathematically, without having to use new ACAD objects.
The code below was borrowed from the web and is an example of one way to do
an area calculation. It has not been checked against all possible
combinations of circle centers, radii, etc.....

James


Option Explicit

Function area_circle_intersect(oC1 As AcadCircle, oC2 As AcadCircle) As
Double
' assumption: circles are in same XY plane in WCS

' Disclaimer: this routine is provided as an example only. It is not
guaranteed
' to run correctly or to be fit for any given service.
' USE AT YOUR OWN RISK

Dim cen1 As Variant, cen2 As Variant
Dim r1 As Double, r2 As Double
Dim x1 As Double, x2 As Double
Dim y1 As Double, y2 As Double
Dim dcen As Double, rmin As Double, rmax As Double
Const pi As Double = 3.14159265

cen1 = oC1.Center: cen2 = oC2.Center
x1 = cen1(0): x2 = cen2(0)
y1 = cen1(1): y2 = cen2(1)
r1 = abs(oC1.Radius): r2 = abs(oC2.Radius) ' just in case negative
radii are possible
If r1 > r2 Then
rmin = r2
rmax = r1
Else
rmin = r1
rmax = r2
End If

dcen = Sqr((x1 - x2) ^ 2 + (y1 - y2) ^ 2) 'dist between centers

If dcen >= rmin + rmax Then 'circles too far apart to share any area
area_circle_intersect = 0
ElseIf (rmin + dcen) <= rmax Then 'smaller circle completely inside
bigger circle
area_circle_intersect = pi * rmin ^ 2
Else 'circles intersect at 2 points
'formula from
http://mathworld.wolfram.com/Circle-CircleIntersection.html
area_circle_intersect = r1 ^ 2 * acos((dcen ^ 2 + r1 ^ 2 - r2 ^ 2) /
(2 * dcen * r1)) _
+ r2 ^ 2 * acos((dcen ^ 2 + r2 ^ 2 - r1 ^ 2) / (2 * dcen * r2)) _
- 0.5 * Sqr((-dcen + r1 + r2) * (dcen + r1 - r2) * (dcen - r1 + r2)
* (dcen + r1 + r2))
End If

End Function

Function acos(X As Double) As Double
'from VBA help section on "derived math functions"
acos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function

Sub circle_area_example()
Dim circle1 As AcadCircle, circle2 As AcadCircle
Dim cen1(0 To 2) As Double, cen2(0 To 2) As Double
Dim r1 As Double, r2 As Double

'experiment with different radii, x and y values
cen1(0) = 0 'x of first circle
cen1(1) = 0 'y of first circle
cen2(0) = 67 'x of second circle
cen2(1) = 0 'y of second circle
r1 = 50 'radius of first circle
r2 = 20 'radius of second circle

Set circle1 = ThisDrawing.ModelSpace.AddCircle(cen1, r1)
Set circle2 = ThisDrawing.ModelSpace.AddCircle(cen2, r2)
MsgBox "Intersection area = " & area_circle_intersect(circle1, circle2)

End Sub


0 new messages