Page 1 of 1

read value off entities

Posted: 25 Mar 2020, 21:11
by ditel
Good morning
For our development we use vb.net to load and display a dxf file in a picture box.
We use the following command


Public vDrawing As CADImage
CADImage.CreateImageByExtension(OpenFileDialog1.FileName)
vDrawing.LoadFromFile(OpenFileDialog1.FileName)


Our question is with the vDrawing(CADimage) object we can read in a local variable the data refer to
Start point, end point,and polypoints data from each entities?

we can read some data value like this

value=vDrawing.CurrentLayout.Entities(0).EntName
value=vDrawing.CurrentLayout.Entities(0).EntType

we need use a diferent object instead of CADImage

thank you very much

Re: read value off entities

Posted: 25 Mar 2020, 22:05
by support
Hello,

Not every single entity has StartPoint, EndPoint or PolyPoints property, it depends on the CADEntity.EntType value. So, prior to reading the entity data, you need to check the entity type through the EntType property, convert the CADEntity object to a corresponding entity type (CADLine, CADPolyLine, etc.) and write the result of conversion to a variable of this entity type:

Code: Select all

If vDrawing.CurrentLayout.Entities(0).EntType = EntityType.Line Then
    Dim vLine As CADLine
    vLine = CType(vDrawing.CurrentLayout.Entities(0), CADLine)
End If
or

Code: Select all

If vDrawing.CurrentLayout.Entities(0).EntType = EntityType.Line Then
    Dim vLine As CADLine = vDrawing.CurrentLayout.Entities(0)
End If
Mikhail

Re: read value off entities

Posted: 26 Mar 2020, 11:31
by ditel
Thank you very much

Mikhail