马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Using OSnap functionality during a Jig in .Net By Philippe Leefsma
Q:
I would like to take advantage of my OSNAP settings while jigging my entity, so it looks like it sticks to the closest snapped point while user is still moving the cursor.
I was trying to use some of the Editor selection methods, but it doesn't seem to work.
A:
The Editor functionalities such as selections cannot be performed while the jig is running.
A solution to implement this requirement is to set the osnap options before starting the jig, to “End Point” for example. That can be done programmatically as well using the OSMODE system variable. Then inside your jig use a PointMonitor to get the snapped point.
Here is an example of my Jig class that illustrates that. A full sample is available as attachment:
- class CoSnapJig : EntityJig
- {
- private Point3d _previousPos;
- private Point3d _position;
- private Editor _ed;
- public CoSnapJig(): base(new DBText())
- {
- _ed = Application.DocumentManager.MdiActiveDocument.Editor;
- DBText dbTxt = (DBText)Entity;
- dbTxt.TextString = "Jigged DBText";
- _ed.PointMonitor +=
- new PointMonitorEventHandler(ed_PointMonitor);
- }
- void ed_PointMonitor(object sender, PointMonitorEventArgs e)
- {
- _position = e.Context.ComputedPoint;
- }
- public new Entity Entity
- {
- get
- {
- return base.Entity;
- }
- }
- protected override SamplerStatus Sampler(JigPrompts prompts)
- {
- JigPromptPointOptions options =
- new JigPromptPointOptions("\nSpecify position: ");
- options.UserInputControls = UserInputControls.NoZeroResponseAccepted;
- options.Cursor = CursorType.Crosshair;
- PromptPointResult promptRes = prompts.AcquirePoint(options);
- if (_previousPos == promptRes.Value)
- return SamplerStatus.NoChange;
- _previousPos = promptRes.Value;
- return SamplerStatus.OK;
- }
- protected override bool Update()
- {
- DBText oTxt = (DBText)Entity;
- oTxt.Position = _position;
- return true;
- }
- public PromptStatus Run()
- {
- PromptResult promptResult =
- Application.DocumentManager.MdiActiveDocument.Editor.Drag(this);
- return promptResult.Status;
- }
- }
osnapjig.zip
|