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

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

1 REPLY 1
Reply
Message 1 of 2
Anonymous
268 Views, 1 Reply

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

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
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

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

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