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

Mirror entity and Extrusion direction relative to UCS problem.

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
875 Views, 5 Replies

Mirror entity and Extrusion direction relative to UCS problem.

I'm trying to make my custom command that mirrors all the entities (lines, blocks, etc.).

 

I used this:

http://through-the-interface.typepad.com/through_the_interface/2008/10/mirroring-autoc.html

 

I have one problem. After mirroring the line or polyline if I show list of parameters (LIST command) I have this:

Extrusion direction relative to UCS: X= 0.0000 Y= 0.0000 Z= -1.0000

 

The problem is that I cannot then stretch this line if I select line and block in one time.

 

Can anyone help me? How can I get rid of this "Extrusion ...".

 

With simple mirror I doesn't have this problem.

5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Anyone can help me?

Message 3 of 6
Anonymous
in reply to: Anonymous

simple mirror is 2d mirror, what you are doing here is 3d mirroring, that's why you get opposite extrusion direction, which is the same as normal vector of the object

 

you can try something like this:

 

 

        Dim ent2 As Line = ent.Clone

        ent2.TransformBy(Matrix3d.Mirroring(New Line3d(New Point3d, New Point3d(0, 1, 0))))
        ent2.Normal = ent.Normal

 

 

Message 4 of 6
Anonymous
in reply to: Anonymous

It doesn't work for me.

 

Here is my code:

 

        public ObjectId MirrorEntity(ObjectId id, Point3d firstPoint, Point3d secondPoint)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            DocumentLock dl = doc.LockDocument(DocumentLockMode.ProtectedAutoWrite, null, null, true);
            using (dl)
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    try
                    {
                        Entity ent = tr.GetObject(id, OpenMode.ForRead) as Entity;
                        Entity me = ent.Clone() as Entity;

                        Line3d line = new Line3d(firstPoint.Add(this.BasePoint3d.GetAsVector()), secondPoint.Add(this.BasePoint3d.GetAsVector()));
                        
                        Matrix3d mm = Matrix3d.Mirroring(line);
                        me.TransformBy(mm);

                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                        ObjectId newId = btr.AppendEntity(me);
                        tr.AddNewlyCreatedDBObject(me, true);
                        tr.Commit();
                        return newId;
                    }
                    catch (Autodesk.AutoCAD.Runtime.Exception ex)
                    {
                        Utilities.ErrorMessage("\nException!\n " + ex.Message);
                        tr.Abort();
                        return ObjectId.Null;
                    }
                }
            }
        }

 

Message 5 of 6
Anonymous
in reply to: Anonymous

You are not setting the normal to the value of the original entity, that can make the difference.

Message 6 of 6
Anonymous
in reply to: Anonymous

I tried, but I'm getting error that Normal property is read-only.

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