.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

execute a command immediately (synchronously) with sendcommand

3 REPLIES 3
Reply
Message 1 of 4
ACDC09
1857 Views, 3 Replies

execute a command immediately (synchronously) with sendcommand

Hi all,

What I'm doing now is the following, and what I eventually want is to rotate the UCS 90dgree on the X access, and draw something(easer than rotating the solid ;)).

function1()
{
solid3d.box();
sendcommand("_usc x 90 ");
solid3d.cylinder();
}

When I call this function the two solids are first drawn and the the sendcommand is executed, the sendcommand is doing what SendStringToExecute does. But in the Devolopers Guide [click|http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer%27s%20Guide/index.html]
states you need to execute a command immediately (synchronously), you should:

Can someone send me an example of how to do this in C#, I saw already many threads about this subject but didn't find my answer.
Any help or suggestions is welcome.

Thanks
3 REPLIES 3
Message 2 of 4
SOMAR_engineering
in reply to: ACDC09

I don't know C#, but in VB using send command would be done like this:

Imports Autodesk.AutoCAD.Interop

Public Sub function1()

Dim ObjAcad As AcadApplication = DirectCast(GetObject(, "AutoCAD.Application.18"), AcadApplication)
ObjAcad.ActiveDocument.SendCommand("_ucs" & vbCr & "x" & vbCr "90" & vbCr)

End Sub

Note: I am using Acad 2010, thus the "18" in "AutoCAD.Application.18". I was running Acad 2007 before and it was version "17". You would need to reference your version of Acad.

Sorry if this is not a help. Perhaps someone else could post the C# code for what you want.

Will
Message 3 of 4
cadMeUp
in reply to: ACDC09

In C#:
{code}
Document curDoc = AcApp.DocumentManager.MdiActiveDocument;
AcadDocument curAcadDoc = (AcadDocument)curDoc.AcadDocument;
curAcadDoc.SendCommand("_.ucs x 90 ");
{code}

Alternately, without using 'SendCommand', you could use this to rotate the current ucs by 90 along the X axis:
{code}
Document curDoc = AcApp.DocumentManager.MdiActiveDocument;
Editor ed = curDoc.Editor;
CoordinateSystem3d curUcs = ed.CurrentUserCoordinateSystem.CoordinateSystem3d;
double radRotAng = (90 / (double)180) * Math.PI;
Vector3d xAxis = curUcs.Xaxis;
Vector3d yAxis = curUcs.Yaxis.RotateBy(radRotAng, xAxis);
Vector3d zAxis = curUcs.Zaxis.RotateBy(radRotAng, xAxis);

ed.CurrentUserCoordinateSystem = Matrix3d.Identity;
ed.CurrentUserCoordinateSystem =
Matrix3d.AlignCoordinateSystem(Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,
curUcs.Origin, xAxis, yAxis, zAxis);
{code}
Message 4 of 4
ACDC09
in reply to: ACDC09

Thanks for your answers, I think I will just stick to rotate the ucs without the sendcommand method.

ok I mange now to rotate the ucs, but when I draw the cylinder in code it still in the same orientation before rotating the ucs. And when I draw the cylinder in autocad I get a rotated cylinder.

I got the answer for this, after rotating the ucs and drwaing a sloid you need to add
{code}
solid3d.TransformBy(ed.CurrentUserCoordinateSystem);
{code}

I hoop this can help some one else.

Edited by: ACDC09 on Sep 5, 2009 2:15 PM Edited by: ACDC09 on Sep 6, 2009 5:14 PM

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost