why two CAD blockreference's shape is different

why two CAD blockreference's shape is different

wokeyiyognshenme
Advocate Advocate
700 Views
6 Replies
Message 1 of 7

why two CAD blockreference's shape is different

wokeyiyognshenme
Advocate
Advocate

in the dwg,two blockreference  has same name ,same rotation.

 

but why do they have different shape, different basepoint ?

blockreference.png

0 Likes
Accepted solutions (1)
701 Views
6 Replies
Replies (6)
Message 2 of 7

_gile
Consultant
Consultant

Hi,

The block on the left does not lies on the XY plane, its normal is: 0.0168726, 0.0, 0.999858 (slightly rotated on Y axis).

The Rotation property of a block reference is measuered about the X axis of the Object Corrdinate System (OCS).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 7

wokeyiyognshenme
Advocate
Advocate

 How to reproduce this problem。

do you mean

1。first,  set a ocs, forexamble, its Zaxis is (a,b,c).

2。second ,insert a blockreference in the OCS ?

 

I DON'T know how to draw. could you give a Operation video ---Screen recording。

 

thank you .

0 Likes
Message 4 of 7

_gile
Consultant
Consultant



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 7

wokeyiyognshenme
Advocate
Advocate

great!!!

thank your very much.

 

another problem:

 

the left blockreference is not drawed in wcs.

how to get the four point(X,Y,z) of the rectangle in wcs

0 Likes
Message 6 of 7

_gile
Consultant
Consultant
Accepted solution

@wokeyiyognshenme  a écrit :

the left blockreference is not drawed in wcs.

how to get the four point(X,Y,z) of the rectangle in wcs


You can either get the coordinates of the polyline by exploding the block reference or from the block definition.

        public static Point3dCollection GetPolylineCoordinates(Polyline pline)
        {
            var points = new Point3dCollection();
            for (int i = 0; i < pline.NumberOfVertices; i++)
            {
                points.Add(pline.GetPoint3dAt(i));
            }
            return points;
        }

        private static Point3dCollection GetPolylineCoordinatesByExploding(BlockReference br)
        {
            var entitySet = new DBObjectCollection();
            br.Explode(entitySet);
            var points = new Point3dCollection();
            foreach (Entity entity in entitySet)
            {
                if (entity is Polyline pline)
                {
                    points = GetPolylineCoordinates(pline); 
                }
                entity.Dispose();
            }
            return points;
        }

        private static Point3dCollection GetPolylineCoordinatesFromBlockDefinition(BlockReference br)
        {
            var btr = (BlockTableRecord)br.BlockTableRecord.GetObject(OpenMode.ForRead);
            var points = new Point3dCollection();
            foreach (ObjectId id in btr)
            {
                if (id.ObjectClass.Name == "AcDbPolyline")
                {
                    var pline = (Polyline)id.GetObject(OpenMode.ForRead);
                    foreach (Point3d point in GetPolylineCoordinates(pline))
                    {
                        points.Add(point.TransformBy(br.BlockTransform));
                    }
                }
            }
            return points;
        }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 7 of 7

wokeyiyognshenme
Advocate
Advocate

thankyou very much

0 Likes