DrawJig模仿Move时能否不显示原对象
用lisp可以轻松实现。
(defun C:TEST (/ DATA GRR GRRPT KEY LOOP OBJECTS PT SS)
;; by carrot1983 2020.09.29
(setq SS (ssget))
(setq PT (getpoint "\n指定点:"))
(setq OBJECTS (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS)))))
(setq LOOP t)
(while LOOP
(setq GRR (grread t 15 2))
(setq KEY (car GRR))
(setq DATA (cadr GRR))
(cond ((= KEY 5)
(setq GRRPT DATA)
(foreach O OBJECTS
(vla-move O (vlax-3d-point PT) (vlax-3d-point GRRPT))
)
) ;_移动
((or (= KEY 3) (= DATA 13))
(setq LOOP NIL)
) ;_3左击 13回车 表示确认
((member KEY '(12 25))
(redraw)
(setq LOOP NIL)
) ;_右键退出
)
(setq PT GRRPT) ;_新基点
)
(redraw)
)
如果用drawjig 怎么修改以下代码。实现不显示原对象?
public class MoveJig : DrawJig
{
protected Point3d basePt;
protected Entity[] entities;
public MoveJig(Entity[] entities, Point3d basePt)
{
this.entities = entities;
this.basePt = basePt;
}
public Matrix3d Displacement { get; private set; }
protected override SamplerStatus Sampler(JigPrompts prompts)
{
var options = new JigPromptPointOptions("\nSecond point: ");
options.UserInputControls = UserInputControls.Accept3dCoordinates;
options.BasePoint = basePt;
options.UseBasePoint = true;
options.Cursor = CursorType.RubberBand;
var result = prompts.AcquirePoint(options);
if (basePt.DistanceTo(result.Value) < Tolerance.Global.EqualPoint)
return SamplerStatus.NoChange;
Displacement = Matrix3d.Displacement(result.Value - basePt);
return SamplerStatus.OK;
}
protected override bool WorldDraw(WorldDraw draw)
{
var geo = draw.Geometry;
if (geo != null)
{
geo.PushModelTransform(Displacement);
foreach (var ent in entities) geo.Draw(ent);
geo.PopModelTransform();
}
return true;
}
}
public void Test()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var selection = ed.GetSelection();
if (selection.Status != PromptStatus.OK) return;
var ptResult = ed.GetPoint("\nBase point: ");
if (ptResult.Status != PromptStatus.OK) return;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity[] entities = new Entity;
for (int i = 0; i < selection.Value.Count; i++)
{
entities = (Entity)tr.GetObject(selection.Value.ObjectId, OpenMode.ForRead);
}
var jig = new MoveJig(entities, ptResult.Value.TransformBy(ed.CurrentUserCoordinateSystem));
var result = ed.Drag(jig);
if (result.Status == PromptStatus.OK)
{
foreach (var ent in entities)
{
ent.UpgradeOpen();
ent.TransformBy(jig.Displacement);
}
}
tr.Commit();
}
}
}
var geo = draw.Geometry;if (geo != null){//geo.PushModelTransform(Displacement);foreach (var ent in entities)ente. draw()//geo.PopModelTransform();}return true; carrot1983 发表于 2021-3-16 01:21
把原位置的先隐藏,这个我有思考过,但是,我看JIG的代码中没有这个东西。所以没头绪。
方法可行的 最近写了几段代码都是这样做的 如果要修改动态块参数 就要用deepclone否则最终变换后夹点位置不对 本帖最后由 brainstorm 于 2020-11-18 23:29 编辑
找到办法了:
[*]假如 entityToBeJig 是要被jig的对象
[*]先克隆 entityToBeJig, 不要加入数据库
[*]设置entityToBeJig visible 属性为false
[*]然后用jig拖动新克隆的实体
[*]拖拽结束后,dispose新掉克隆的实体
[*]按实际效果变换entityToBeJig ,把可见性设为true
个人见解:关键你这个是moveJig,不是CreatEntity,好像SamplerStatus过程在鼠标确定之前,你不能修改原始对象,
我觉得moveJig不显示原对象,有点难
楼下大神来解答https://cdn.jsdelivr.net/gh/hishis/forum-master/public/images/patch.gif cad 自己的移动命令都显示 估计很难 Lisp 轻松实现的功能,到.net的时候困难真不少。有没有高人出来指点一二。 这样行么 但是图元多的时候可能会慢 brainstorm 发表于 2020-10-17 13:28
这样行么 但是图元多的时候可能会慢
一楼的代码就是这样子的。 找到办法了 可以把原图像的透明度变成100%,这样就不显示了。:D
页:
[1]
2