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

How to create a good rectangle for a block with GeometricExtents

6 REPLIES 6
Reply
Message 1 of 7
AubelecBE
618 Views, 6 Replies

How to create a good rectangle for a block with GeometricExtents

HI,

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

6 REPLIES 6
Message 2 of 7

Hi There,

 

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.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

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.Inverse())
        ''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.

 

 

Message 4 of 7

Try to replace:

ext.TransformBy(Ed.CurrentUserCoordinateSystem.Inverse())

 

 with:

ext.TransformBy(RefBloc.BlockTransform.Inverse())

 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 7

.. sorry, not working....

 

 

Message 6 of 7


@AubelecBE wrote:

.. sorry, not working....

 


Then I do not understand what you're trying to get. And what is the connection between GeometricExtents and UCS?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 7 of 7

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)

 

++

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