.NET

Reply
*GPaolo
Message 1 of 8 (182 Views)

mirror with copy

182 Views, 7 Replies
05-25-2006 06:08 AM
i need to mirror some entity around then x-axis and the function work.

But when list entity i can see that the UCS is 0,0,-1 and this is incorrect.

Some hlep?

Many thank's

GPaolo



Public Function MirrorCopyEnt(ByVal objid As AcDb.ObjectId, _

ByVal pref1() As Double, ByVal pref2() As Double, Optional ByVal layer As
String = "-1") As AcDb.ObjectId

Dim tm As DBTransMan = HmDotNet.HmTool.TransactionManager

Dim myT As AcDb.Transaction = tm.StartTransaction

Try

Dim entity As AcDb.Entity = myT.GetObject(objid, AcDb.OpenMode.ForRead,
False)

Dim TrasMat As AcGe.Matrix3d

Dim p1 As AcGe.Point3d = New AcGe.Point3d(pref1(0), pref1(1), pref1(2))

Dim p2 As AcGe.Point3d = New AcGe.Point3d(pref2(0), pref2(1), pref2(2))

Dim LineAxis As AcGe.Line3d = New AcGe.Line3d(p1, p2)

TrasMat = AcGe.Matrix3d.Mirroring(LineAxis)

Dim myent As AcDb.Entity = entity.GetTransformedCopy(TrasMat)

myT.Commit()

Return HmDotNet.HmTool.hmInsEnt(myent)

Catch ex As Exception

MessageBox.Show(ex.Message & " " & ex.ToString)

Finally

myT.Dispose()

End Try

End Function
Active Member
ceorl
Posts: 7
Registered: ‎11-13-2006
Message 2 of 8 (182 Views)

Re: mirror with copy

08-28-2008 06:28 AM in reply to: *GPaolo
I'm having the same issue. Were you able to find a solution, and would you mind sharing it?

Ceorl
Distinguished Contributor
foruma000256
Posts: 216
Registered: ‎01-28-2004
Message 3 of 8 (182 Views)

Re: mirror with copy

09-02-2008 09:25 AM in reply to: *GPaolo
Mirror simply creates the same entity with a negative normal, hince the 0,0,-1 scale. (Normal: the top of a piece of paper, Negative Normal: the bottom of that same piece of paper)

you would have to change the scale, rotate, move and copy the object piece by piece to avoid negative normals. Not a prefered process, so live with it. IF negative normals get in your way, then you will have to work around 'mirror'.

jvj
Distinguished Contributor
Bryco
Posts: 525
Registered: ‎10-25-2005
Message 4 of 8 (182 Views)

Re: mirror with copy

09-02-2008 06:35 PM in reply to: *GPaolo
I think you can say there is a 2d mirror and a 3d mirror.
A 2d mirror involves a redrawing of the piece rather than flipping it's normal. I use the plane method with no problem
Cs = ed.CurrentUserCoordinateSystem.CoordinateSystem3d;
Pn = new Plane(Cs.Origin, Cs.Zaxis);
Vector3d V = Cs.Xaxis;
Plane P = new Plane(M1, V);
transMat = Matrix3d.Mirroring(P)
Active Member
ceorl
Posts: 7
Registered: ‎11-13-2006
Message 5 of 8 (182 Views)

Re: mirror with copy

09-03-2008 02:09 PM in reply to: *GPaolo
that make sense, jvj, thanks.

Bryco,
May I ask where your M1 variable came from?

Ceorl
Distinguished Contributor
Bryco
Posts: 525
Registered: ‎10-25-2005
Message 6 of 8 (182 Views)

Re: mirror with copy

09-04-2008 07:37 AM in reply to: *GPaolo
M1 is a user picked point, part of a drawjig. I found the way to make the jig work is to get the user to pick a point, mirror the object or objects using a plane with origin M1 and vector being the ucs x-axis. Then you rotate it about the m1 point using (90deg- Ang)*2. This, like cad doesn't mess with the normal, for that matter a block having a xscale of -1 doesnt mean the normal is going to minus at all.
Active Member
ceorl
Posts: 7
Registered: ‎11-13-2006
Message 7 of 8 (182 Views)

Re: mirror with copy

09-11-2008 09:49 AM in reply to: *GPaolo
Bryco, I hate to ask, but I've been struggling with mirroring objects. My intent is to mirror everything in modelspace with the exception of xrefs. I'd prefer to do this at the database level, but right now, I'd settle for just about any solution, except interop (i guess I shouldn't be too picky, huh. I already know how to handle the interop approach).

Do you have anything in the way of good example you wouldn't mind sharing?

Thank you,
Ceorl
Distinguished Contributor
Bryco
Posts: 525
Registered: ‎10-25-2005
Message 8 of 8 (182 Views)

Re: mirror with copy

09-12-2008 01:24 AM in reply to: *GPaolo
[code]
[CommandMethod("mnn")]
public void Mirror()
{
Document doc=acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = HostApplicationServices.WorkingDatabase;
ObjectId id = ed.GetEntity("\nPick ent:").ObjectId;
using(Transaction tr=db.TransactionManager.StartTransaction())
{
Entity ent = tr.GetObject(id, OpenMode.ForWrite) as Entity;
CoordinateSystem3d cs=ed.CurrentUserCoordinateSystem.CoordinateSystem3d;
Plane pn = new Plane(cs.Origin, cs.Yaxis);
Matrix3d m = Matrix3d.Mirroring(pn);
ent.TransformBy(m);
tr.Commit();
}
}
[/code]
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.