Mirror entity and Extrusion direction relative to UCS problem.

Mirror entity and Extrusion direction relative to UCS problem.

Anonymous
Not applicable
1,329 Views
5 Replies
Message 1 of 6

Mirror entity and Extrusion direction relative to UCS problem.

Anonymous
Not applicable

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.

0 Likes
1,330 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Anyone can help me?

0 Likes
Message 3 of 6

Anonymous
Not applicable

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

 

 

0 Likes
Message 4 of 6

Anonymous
Not applicable

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;
                    }
                }
            }
        }

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

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

0 Likes
Message 6 of 6

Anonymous
Not applicable

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

0 Likes