.NET

Reply
*James Stergar
Message 1 of 2 (119 Views)

How do you create a custom crosshair when inserting a block reference?

119 Views, 1 Replies
12-01-2005 12:15 PM
I've seen other Acad applications that put a circle around a crosshair to
represent the bounding area of a block reference when placing it. I've read
through everything in the Acad Managed Class Reference help file and cannot
find a way. Can somebody point me in the right direction?

Thanks in advance,

James
*Bobby C. Jones
Message 2 of 2 (119 Views)

Re: How do you create a custom crosshair when inserting a block reference?

12-08-2005 01:53 PM in reply to: *James Stergar
I'm not sure about changing the crosshair, but you can drag a jig around the
cursor. This example drags a circle.

using System;

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.Geometry;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.GraphicsInterface;

using Autodesk.AutoCAD.ApplicationServices;

namespace AU2005.AcadApi

{

//Pages 12 & 13

//New class derrived from the DrawJig class

public class JigExample : DrawJig

{

#region private member fields

private Point3d previousCursorPosition;

private Point3d currentCursorPosition;

private Entity entityToDrag;

#endregion



[CommandMethod("StartJig")]

public void StartJig()

{

//Initialize cursor position

//Use the geometry library to create a new 3d point object

previousCursorPosition = new Point3d (0,0,0);

entityToDrag = new Circle(new Point3d(0,0,0), new Vector3d (0,0,1), 6);

Application.DocumentManager.MdiActiveDocument.Editor.Drag(this);

}



//You must override this method

protected override SamplerStatus Sampler(JigPrompts prompts)

{

//Get the current cursor position

PromptPointResult userFeedback = prompts.AcquirePoint();

currentCursorPosition = userFeedback.Value;

if (CursorHasMoved())

{

//Get the vector of the move

Vector3d displacementVector =
currentCursorPosition.GetVectorTo(previousCursorPosition);

//Transform the circle to the new location

entityToDrag.TransformBy(Matrix3d.Displacement(displacementVector));

//Save the cursor position

previousCursorPosition = currentCursorPosition;

return SamplerStatus.OK;

}

else

{

return SamplerStatus.NoChange;

}

}



//You must override this method

protected override bool WorldDraw(WorldDraw draw)

{

draw.Geometry.Draw(entityToDrag);

return true;

}



private bool CursorHasMoved ()

{

return !(currentCursorPosition == previousCursorPosition);

}

}

}


--
Bobby C. Jones
http://www.acadx.com

"James Stergar" wrote in message
news:5027068@discussion.autodesk.com...
I've seen other Acad applications that put a circle around a crosshair to
represent the bounding area of a block reference when placing it. I've read
through everything in the Acad Managed Class Reference help file and cannot
find a way. Can somebody point me in the right direction?

Thanks in advance,

James

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community