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

mirror with copy

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
568 Views, 7 Replies

mirror with copy

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
7 REPLIES 7
Message 2 of 8
ceorl
in reply to: Anonymous

I'm having the same issue. Were you able to find a solution, and would you mind sharing it?

Ceorl
Message 3 of 8
foruma000256
in reply to: Anonymous

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
Message 4 of 8
Bryco
in reply to: Anonymous

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)
Message 5 of 8
ceorl
in reply to: Anonymous

that make sense, jvj, thanks.

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

Ceorl
Message 6 of 8
Bryco
in reply to: Anonymous

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.
Message 7 of 8
ceorl
in reply to: Anonymous

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
Message 8 of 8
Bryco
in reply to: Anonymous

[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]

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