iLogic to extract characters from Description iproperty

iLogic to extract characters from Description iproperty

Saqib.Iqbal
Enthusiast Enthusiast
3,189 Views
3 Replies
Message 1 of 4

iLogic to extract characters from Description iproperty

Saqib.Iqbal
Enthusiast
Enthusiast

I am working on custom table for steel lines for my company and i want to extract steel line ENDS from description in iproperties to my custom table.

 

For example: 1/2 steel line description is: 1/2"_HYDLINE_LENGTH" TL_E1_END1_E2_END2

 

I was able to extract steel line size from description using: 

Left(iProperties.Value("Project", "Description"),3)

 

But Now, i am having hard time to extract END1 and END2 from description. For END2 in description.

 

Any help would be appreciated.

 

Thank you in advance.

0 Likes
Accepted solutions (1)
3,190 Views
3 Replies
Replies (3)
Message 2 of 4

Saqib.Iqbal
Enthusiast
Enthusiast

PLEASE NOTE THAT END1 AND END2 CHARACTERS ARE CHANGEABLE, MEANS END1 AND END2 ARE DEPENDS ON FITTING NAME WHICH CAN BE OF DIFFERENT SIZE, E.G 12FORFS OR 08MORFS OR 04MORB, ETC.



@Saqib.Iqbal wrote:

I am working on custom table for steel lines for my company and i want to extract steel line ENDS from description in iproperties to my custom table.

 

For example: 1/2 steel line description is: 1/2"_HYDLINE_LENGTH" TL_E1_END1_E2_END2

 

I was able to extract steel line size from description using: 

Left(iProperties.Value("Project", "Description"),3)

 

But Now, i am having hard time to extract END1 and END2 from description. For END2 in description.

 

Any help would be appreciated.

 

Thank you in advance.


0 Likes
Message 3 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Saqib.Iqbal,

 

Try below iLogic code to get END1 and END2. For testing purpose, desc variable is hard coded to "1/2_HYDLINE_LENGTH TL_E1_END1_E2_END2".  You can change it to iProperty of description.

 

Sub Main()
	Dim desc As String 
desc = "1/2_HYDLINE_LENGTH TL_E1_END1_E2_END2"
'desc = iProperties.Value("Project", "Description") Dim Indexes As List(Of Integer) = GetIndexes(desc, "_") Dim end1 As String = desc.Substring(Indexes(3) + 1, Indexes(4) - Indexes(3) - 1) MessageBox.Show(end1, "Result of end1") Dim end2 As String = desc.Substring(Indexes(5) + 1, desc.Length - Indexes(5) - 1) MessageBox.Show(end2, "Result of end2") End Sub Private Function GetIndexes(ByVal SearchWithinThis As String, ByVal SearchForThis As String) As List(Of Integer) Dim Result As New List(Of Integer) Dim i As Integer = SearchWithinThis.IndexOf(SearchForThis) While (i <> -1) Result.Add(i) i = SearchWithinThis.IndexOf(SearchForThis, i + 1) End While Return Result End Function

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 4 of 4

Saqib.Iqbal
Enthusiast
Enthusiast

@chandra.shekar.g THANK YOU SO MUCH. It works like charm.

 

I have accepted that as a solution.


@chandra.shekar.g wrote:

@Saqib.Iqbal,

 

Try below iLogic code to get END1 and END2. For testing purpose, desc variable is hard coded to "1/2_HYDLINE_LENGTH TL_E1_END1_E2_END2".  You can change it to iProperty of description.

 

Sub Main()
	Dim desc As String 
desc = "1/2_HYDLINE_LENGTH TL_E1_END1_E2_END2"
'desc = iProperties.Value("Project", "Description") Dim Indexes As List(Of Integer) = GetIndexes(desc, "_") Dim end1 As String = desc.Substring(Indexes(3) + 1, Indexes(4) - Indexes(3) - 1) MessageBox.Show(end1, "Result of end1") Dim end2 As String = desc.Substring(Indexes(5) + 1, desc.Length - Indexes(5) - 1) MessageBox.Show(end2, "Result of end2") End Sub Private Function GetIndexes(ByVal SearchWithinThis As String, ByVal SearchForThis As String) As List(Of Integer) Dim Result As New List(Of Integer) Dim i As Integer = SearchWithinThis.IndexOf(SearchForThis) While (i <> -1) Result.Add(i) i = SearchWithinThis.IndexOf(SearchForThis, i + 1) End While Return Result End Function

Thanks and regards,


 

Have a good day.

0 Likes