i have created a block with n attribute.
i insert the block with attribute filled with fields.
I send the commande "Regen" for update field.
Now i want to add a rectangle in the block définition.
I use GeometricExtents.
it works fine only when then the rotation is 0 and UCS on UCSW.
how i can create the line with the 4 points ? I want the line include all entity in my block def.
I joined a zip with :
2.dwg is the XRef in 3.dwg
My bloc show info from xref (2.dwg).
in the dwg. the bloc contain a line. The libe i manualy added when i create the blockreccord
You mention you want to add the rectangle in the block definition, but GeometricExtents is only returned on Entities, so if your block doesn't contain too many entities, you can open the block definition, iterate through all ObjectIds, open each entity and check its extents.
Another approach would be to retrieve the extents of the block reference, apply the inverse transformation of the block reference to that extents, so you would have it express in block definition space.
i have to use your second solution.
I use attribut with field.
The field is fiiled when i insert the block in my dwg.
So i need to insert my bloc and use GeometricExtend for retrieve the extend point.
But it work when i have a the World UCS or User UCS (but only with then UCS in a plane of the editor.).
I Dont know how to calculate the correct POint for create my line when i retrieve point in UCS with a different angle other than 0 or 180 ( angle from UCS and the view in editor.)
here a saple of my code :
'Création du Rectangle Dim ext As Extents3d ext = RefBloc.GeometricExtents ext.TransformBy(Ed.CurrentUserCoordinateSystem.Inv
erse()) ''test affichage du carré : Dim Newrec As New Autodesk.AutoCAD.DatabaseServices.Polyline Newrec.AddVertexAt(0, New Point2d(-5, 5), 0, 0, 0) Newrec.AddVertexAt(1, New Point2d((System.Math.Abs(ext.MaxPoint.X - ext.MinPoint.X) / RefBloc.ScaleFactors.X) + 5, 5), 0, 0, 0) Newrec.AddVertexAt(2, New Point2d((System.Math.Abs(ext.MaxPoint.X - ext.MinPoint.X) / RefBloc.ScaleFactors.X) + 5, (-(System.Math.Abs(ext.MaxPoint.Y - ext.MinPoint.Y)) / RefBloc.ScaleFactors.Y) - 5), 0, 0, 0) Newrec.AddVertexAt(3, New Point2d(-5, (-System.Math.Abs(ext.MaxPoint.Y - ext.MinPoint.Y) / RefBloc.ScaleFactors.Y) - 5), 0, 0, 0) Newrec.Closed = True Newrec.Layer = "0" tr = db.TransactionManager.StartTransaction Dim btr As BlockTableRecord = tr.GetObject(DefBloc.ObjectId, OpenMode.ForWrite) btr.AppendEntity(Newrec) tr.AddNewlyCreatedDBObject(Newrec, True) tr.Commit()
Ths prob : GeometricExtents return 2 points in UCW i need to translate for create a line in my BlockDefinition.
here a dwg sample.
The first BlockDefinition is generated on UCW the second with UCS. --> The line is not egal ...
i show on the dwg the UCS i use for launch my command.
I have renamed the first blockdefinition . (My command reset the BlockDefinition is already exist in database)