Evaluate the next type of entity - Visual Basic .NET

Evaluate the next type of entity - Visual Basic .NET

Anonymous
Not applicable
1,015 Views
7 Replies
Message 1 of 8

Evaluate the next type of entity - Visual Basic .NET

Anonymous
Not applicable

Hello,

 

I need to generate a code that evaluates if the current entity is a line and if the next entity is also a line. I'm using the following code, but I can not get the result I want.

 

Please, excuse my mistakes. I'm learning.

 

For i As Integer = 0 To align1.Entities.Count - 1

Dim enti As AlignmentEntity = align1.Entities.GetEntityByOrder(i)
If (enti.EntityType = AlignmentEntityType.Line) Then
Dim nextenti As Integer = enti.EntityAfter
Dim nextentity As AlignmentEntity = align1.Entities.Item(nextenti)
If (nextentity.EntityType = AlignmentEntityType.Line) Then
pipqce(i) = 1
pipqcn(i) = 1
End If
Continue For
End If

Next i

Can someone help me with an example .net code. 

 

Thank you very much.

 

Best regards.

 

Mauro Vega

 

AutoCAD Civil 3D 2018.1

Intel Core i7-6700HQ CPU 2.6 GHZ

32 GB RAM 2133 MHz

NVIDIA Quadro M3000M

Windows 10 Pro 64 Bits

0 Likes
Accepted solutions (1)
1,016 Views
7 Replies
Replies (7)
Message 2 of 8

TiStars
Advisor
Advisor
for getting next Entity, I will use

Dim nextentity As AlignmentEntity = align1.Entities.GetEntityByOrder(i+1)

天涯海角的山姆


您认为此帖子是否有用?欢迎为此帖点赞。

您的问题是否已得到解答?请点击“接受解答”按钮。


EESignature



0 Likes
Message 3 of 8

TiStars
Advisor
Advisor

I tried in C# with this:
AlignmentEntity aliEntiNext = align1.Entities.EntityAtId(aliEnti.EntityAfter);

I don't know if "align1.Entities.Item(nextenti)" works or not, but in C#, I can get Entity by align1.Entities.EntityAtId() Method. And then I can get EntityType of it.


天涯海角的山姆


您认为此帖子是否有用?欢迎为此帖点赞。

您的问题是否已得到解答?请点击“接受解答”按钮。


EESignature



Message 4 of 8

TiStars
Advisor
Advisor

alignEntityType.PNG


天涯海角的山姆


您认为此帖子是否有用?欢迎为此帖点赞。

您的问题是否已得到解答?请点击“接受解答”按钮。


EESignature



0 Likes
Message 5 of 8

Anonymous
Not applicable

Hello TiStars,

 

Thanks for your help.

 

When using this code

AlignmentEntity aliEntiNext = align1.Entities.EntityAtId(aliEnti.EntityAfter)

 

The following error occurs:

The exception occurred Autodesk.Civil.EntityNotFoundException.
HResult=0x80131500
Message = NoNextAlignmentEntity,

I do not know what may be happening.

 

Best regards.

 

Mauro Vega

 

AutoCAD Civil 3D 2018.1

Intel Core i7-6700HQ CPU 2.6 GHZ

32 GB RAM 2133 MHz

NVIDIA Quadro M3000M

Windows 10 Pro 64 Bits

0 Likes
Message 6 of 8

TiStars
Advisor
Advisor
Accepted solution

Hi mvege,

Does the next Entity exist? or the error occurs from the beginning?

when i = align1.Entities.Count -1, there will be no more Entity behind the current one.

so I am afraid this

For i As Integer = 0 To align1.Entities.Count - 1


will have to be changed to

For i As Integer = 0 To align1.Entities.Count - 2

  


天涯海角的山姆


您认为此帖子是否有用?欢迎为此帖点赞。

您的问题是否已得到解答?请点击“接受解答”按钮。


EESignature



Message 7 of 8

Anonymous
Not applicable

Hello TiStars,

 

Thanks for your help.

 

Best regards.

 

Mauro Vega

 

AutoCAD Civil 3D 2018.1

Intel Core i7-6700HQ CPU 2.6 GHZ

32 GB RAM 2133 MHz

NVIDIA Quadro M3000M

Windows 10 Pro 64 Bits

0 Likes
Message 8 of 8

TiStars
Advisor
Advisor
My pleasure Mauro.

天涯海角的山姆


您认为此帖子是否有用?欢迎为此帖点赞。

您的问题是否已得到解答?请点击“接受解答”按钮。


EESignature



0 Likes