Snap Angle function

Snap Angle function

Anonymous
Not applicable
1,557 Views
5 Replies
Message 1 of 6

Snap Angle function

Anonymous
Not applicable
Hi,

I want to get the crosshair angle I set in my model space using the SNAPANG command in my .NET assembly.
As per the ObjectARX managed class documentation there is a SNAPANGLE() function that returns the crosshair angle in the ViewPortTableRecord class but I dont see that method in that class when I checked using SharpDevelop class browser.

I'm using AutoCAD 2008

I have included the following:

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Windows;
using Autodesk.AutoCAD.Colors;

Is there any thing else I need to include? or Is that method not available anymore.

Has anyone successfully accessed the crosshair angle previously?

Thanks,
Rav Edited by: sriva041 on Jun 2, 2010 10:22 PM
0 Likes
1,558 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
ViewportTableRecord has a SnapAngle property, not a method.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:[email protected]...
Hi,

I want to get the crosshair angle I set in my model space using the SNAPANG
command in my .NET assembly.
As per the ObjectARX managed class documentation there is a SNAPANGLE() function
that returns the crosshair angle in the ViewPortTableRecord class but I dont see
that method in that class when I checked using SharpDevelop class browser.

I'm using AutoCAD 2008

I have included the following:

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Windows;
using Autodesk.AutoCAD.Colors;

Is there any thing else I need to include? or Is that method not available
anymore.

Has anyone successfully accessed the crosshair angle previously?

Thanks,
Rav

Edited by: sriva041 on Jun 2, 2010 10:22 PM
0 Likes
Message 3 of 6

chiefbraincloud
Collaborator
Collaborator
technically, it is a property, as opposed to a function, but I have used it. attached image shows my object browser window.

I skipped over ACAD 2008, but I am pretty sure I wrote the routine when I was on 2007, so it should be there.
Dave O.                                                                  Sig-Logos32.png
0 Likes
Message 4 of 6

Anonymous
Not applicable
Thanks for all the replies!

Here is what I found in the OjectArx 2008, Arx_mgd help file:


AcDbViewport::snapAngle Function

double
snapAngle() const;

This function returns the snap angle setting (in radians) for the viewport.

The snap angle is within the UCS XY plane, with zero being the UCS X axis and positive angles going counterclockwise when looking down the UCS Z axis towards the UCS origin.

For more information about snap angle, see SNAPANG in Appendix B (System Variables) of the AutoCAD Command Reference and SNAP in the AutoCAD Command Reference.

The snap angle value is used for the eighth DXF group code 1040 in the "ACAD" appId xdata attached to the viewport.

The documentation notes this under the list of managed members. I could never find it though using intellisense
0 Likes
Message 5 of 6

Anonymous
Not applicable
Suppose you set the snap angle using the SNAPANG command, is there a way to read this angle using the snapangle property?

I can only set the angle but when I read the property I always get 0 rad eventhough i have set the angle using SNAPANG, here is the code I use to set the angle:

double angle = temp_Angle; //public variable temp_angle
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Database db = ed.Document.Database;
Transaction trans = db.TransactionManager.StartTransaction();
using(trans)
{
ViewportTable vpTbl;
vpTbl = trans.GetObject(db.ViewportTableId,OpenMode.ForWrite) as ViewportTable;
ViewportTableRecord vpTblRec = trans.GetObject(vpTbl["*Active"],OpenMode.ForWrite) as ViewportTableRecord;
//vpTblRec.SnapEnabled = true;
vpTblRec.SnapAngle = angle;
//ed.WriteMessage(vpTblRec.SnapAngle.ToString());
ed.UpdateTiledViewportsFromDatabase();
trans.Commit();
}

So I want to know if anyone has managed to read the SNAPANG angle from .NET

Thanks
0 Likes
Message 6 of 6

chiefbraincloud
Collaborator
Collaborator
call Editor.UpdateTiledViewportsInDatabase() before attempting to read the value. (my code calls it just before I start the transaction to open the record)
Dave O.                                                                  Sig-Logos32.png
0 Likes