Page 1 of 1

Change length of line

Posted: 06 Jul 2018, 10:59
by StefanChrist
Hello,

I would like to change the end point of a line within a block. So I assigned a new end point to the line, but the changes are not visible. According properties like the length of the line seem to be fine.

How can I change the end point of a line within a block?

Thanks in advance!

Re: Change length of line

Posted: 06 Jul 2018, 17:20
by support
Hello Stefan,

After changing some entity within a block, you need to call a CADImage.Converter.Loads() method for this entity and the CADBlock object. For example:

Code: Select all

cadImage.Converter.Loads(cadLine);
cadImage.Converter.Loads(cadBlock);
When the block is inserted into a drawing as INSERT entity, you need to call the CADImage.Converter.Loads() also for the CADInsert object and call a CADImage.GetExtents() method to recalculate extents of the drawing.

Mikhail

Re: Change length of line

Posted: 09 Jul 2018, 10:06
by StefanChrist
Hello Mikhail,

thank you for the answer. After adding your code and also calling loads for the INSERT identity, the line is drawn correctly. There is just an issue with the selection when updating the line. I modified the x-value of the end-point of this line, but now the selection is messed up.

Image

The left part of the line was the original line before changing the length.

How can I fix this?

Re: Change length of line

Posted: 10 Jul 2018, 18:00
by support
Hello Stefan,

The problem is that the boundaries of the modified block are remain the same in spite of the fact that you called a CADImage.Converter.Loads() method for BLOCK and INSERT objects. The given problem should be fixed in the source code of CAD .NET library, we haven't found a workaround for it so far.

Mikhail

Re: Change length of line

Posted: 12 Jul 2018, 18:12
by support
Hello Stefan,

CAD .NET development team is already working on the bug fix which will be available in the next version of the library. Could you please tell what CAD .NET version you are using?

Mikhail

Re: Change length of line

Posted: 13 Jul 2018, 09:11
by StefanChrist
Hello Mikhail,

thank you for your reply. We are currently using version 11.2.0.61205. As far as I know we paid for some modifications within the library, so I am not sure if it's an official release.

Thanks,
Stefan

Re: Change length of line

Posted: 13 Jul 2018, 18:30
by support
Hello Stefan,

Your company purchased a special version of CAD .NET 11.2 which includes the export to DWG. For your information, the DWG export is officially supported starting from version 12.1.

The bug with reloading of blocks is already fixed, we may add the bug fix to version 11.2 or, if you are willing to upgrade, version 12.

Mikhail

Re: Change length of line

Posted: 12 Dec 2018, 12:40
by StefanChrist
Hello Mikhail,

after upgrading to v12 (12.2.40) I tried if it is now possible to change the length of an entity afterwards, but the result is still the same. The line is shown with the new length, but the selection is still wrong.

Code: Select all

  Private Sub AddLine()
    Dim Line As CADLine = New CADLine
    Line.Point = New DPoint(My.Settings.P1X, My.Settings.P1Y, 0)
    Line.Point1 = New DPoint(My.Settings.P2X, My.Settings.P2Y, 0)
    Line.Color = Color.Blue

    Dim block As New CADBlock
    cadImage.Converter.Loads(block)
    block.Converter.Loads(Line)
    block.AddEntity(Line)

    Dim insert As New CADInsert
    insert.Point = New DPoint(0, 0, 0)
    insert.Block = block
    cadImage.Converter.Loads(insert)
    cadImage.Layouts(0).AddEntity(insert)

    'Change line length
    Line.Point1 = New DPoint(300, 0, 0)
    cadImage.Converter.Loads(Line)
    cadImage.Converter.Loads(block)
    cadImage.Converter.Loads(insert)
    cadImage.GetExtents()
  End Sub
Image

Re: Change length of line

Posted: 13 Dec 2018, 10:22
by support
Hello Stefan,

You can use the following code to update the line inside insert:

Code: Select all

cadImage.Converter.Loads(Line) 
        cadImage.Converter.Loads(block) 
        cadImage.SetNewPosEntity(0, 0, 0, insert)

Re: Change length of line

Posted: 13 Dec 2018, 11:17
by StefanChrist
With SetNewPosEntity the following happens:

- the entity gets selected automatically (at least markers show up)
- the selection is still wrong
- the new size is not taken into account when the drawing gets resized

Best regards,
Stefan Christ

Re: Change length of line

Posted: 13 Dec 2018, 16:11
by support
Hello Stefan

We were unable to reproduce your mistake, everything works correct on our computers. I've sent a demo project along with some tips to your e-mail address, please check if it works correctly for you.

Re: Change length of line

Posted: 14 Dec 2018, 10:07
by StefanChrist
Hello,

with your demo project I was able to solve the issue. It is neccessary to call "GetExtents" after adding the line, before manipulating it. In my example I was resizing the line before calling GetExtents, which won't work.

Thank you for your help!

Best regards,
Stefan