Visual Basic Customization

Visual Basic Customization

Reply
*Dan
Message 1 of 6 (135 Views)

Extract Text string from Field

135 Views, 5 Replies
09-27-2004 12:29 PM
I have learned how to create a field in VB using the Object Id, but I am struggling with how to extract the string itself from a field, place it into the clipboard, to be copied into another application (Excel). Thank you, Dan
*Ed Jobe
Message 2 of 6 (135 Views)

Re: Extract Text string from Field

09-27-2004 01:32 PM in reply to: *Dan
Use the TextString property to get what was evaluated. If there is other text besides the field, use the standard string manipulation functions (e.g. InStr) to extract the field info from the TexString. -- ---- Ed ---- "Dan" wrote in message news:41586a3f_3@newsprd01... > I have learned how to create a field in VB using the Object Id, but I am > struggling with how to extract the string itself from a field, place it into > the clipboard, to be copied into another application (Excel). > > > Thank you, > Dan > >
*Dan
Message 3 of 6 (135 Views)

Re: Extract Text string from Field

09-28-2004 08:26 AM in reply to: *Dan
I understand how to truncate text to get what I want from the text string, but I have not figured out how to get the string from the field yet. I know how to get the field expression. I must be overlooking something: Sub CaptureFieldText() ' Create the selection set Dim ssetObj As AcadSelectionSet Dim point(0 To 2) As Double Dim fText As AcadText ' Not sure if this is the right object for the field Dim sysVarName As String Dim sysVarData As String sysVarName = "CTAB" sysVarData = "Model" ThisDrawing.SetVariable sysVarName, sysVarData Set ssetObj = ThisDrawing.SelectionSets.Add("capField") point(0) = -100: point(1) = 525.221859: point(2) = 0 ssetObj.SelectAtPoint point For Each fText In ssetObj 'Here is where I wanted to place code to extract string from field Next fText ThisDrawing.SelectionSets.Item("capField").Delete Set Layout = Nothing Set fText = Nothing End Sub Any help is appreciated. I am sure there are better habits, and coding could be optimized, flame awway. I am still very new at this, Thanks, Dan "Ed Jobe" wrote in message news:415878f2$1_1@newsprd01... > Use the TextString property to get what was evaluated. If there is other > text besides the field, use the standard string manipulation functions (e.g. > InStr) to extract the field info from the TexString. > > -- > ---- > Ed > ---- > "Dan" wrote in message > news:41586a3f_3@newsprd01... > > I have learned how to create a field in VB using the Object Id, but I am > > struggling with how to extract the string itself from a field, place it > into > > the clipboard, to be copied into another application (Excel). > > > > > > Thank you, > > Dan > > > > > >
*Dan
Message 4 of 6 (135 Views)

Re: Extract Text string from Field

09-28-2004 02:36 PM in reply to: *Dan
Figured it out, Thanks. AcadEntity works with FIELD. Thats what I was looking for. Got my code working now. Have a great week, Dan "Dan" wrote in message news:415982b6$1_2@newsprd01... > I understand how to truncate text to get what I want from the text string, > but I have not figured out how to get the string from the field yet. I know > how to get the field expression. > > I must be overlooking something: > > Sub CaptureFieldText() > > ' Create the selection set > Dim ssetObj As AcadSelectionSet > Dim point(0 To 2) As Double > Dim fText As AcadText ' Not > sure if this is the right object for the field > Dim sysVarName As String > Dim sysVarData As String > sysVarName = "CTAB" > sysVarData = "Model" > ThisDrawing.SetVariable sysVarName, sysVarData > Set ssetObj = ThisDrawing.SelectionSets.Add("capField") > point(0) = -100: point(1) = 525.221859: point(2) = 0 > ssetObj.SelectAtPoint point > For Each fText In ssetObj > > 'Here is where I wanted to place code to extract string from field > > Next fText > ThisDrawing.SelectionSets.Item("capField").Delete > Set Layout = Nothing > Set fText = Nothing > End Sub > > Any help is appreciated. I am sure there are better habits, and coding could > be optimized, flame awway. > I am still very new at this, > > Thanks, > Dan > > "Ed Jobe" wrote in message > news:415878f2$1_1@newsprd01... > > Use the TextString property to get what was evaluated. If there is other > > text besides the field, use the standard string manipulation functions > (e.g. > > InStr) to extract the field info from the TexString. > > > > -- > > ---- > > Ed > > ---- > > "Dan" wrote in message > > news:41586a3f_3@newsprd01... > > > I have learned how to create a field in VB using the Object Id, but I am > > > struggling with how to extract the string itself from a field, place it > > into > > > the clipboard, to be copied into another application (Excel). > > > > > > > > > Thank you, > > > Dan > > > > > > > > > > > >
Member
leeraybone7272
Posts: 3
Registered: ‎01-02-2008
Message 5 of 6 (135 Views)

Re: Extract Text string from Field

04-21-2010 02:45 AM in reply to: *Dan
I am too struggling to extract the string form the field could you please advise on how you accomplished this.

Thanks in Advance

Lee
Active Member
danranderson327
Posts: 7
Registered: ‎04-21-2010
Message 6 of 6 (135 Views)

Re: Extract Text string from Field

04-21-2010 08:34 AM in reply to: *Dan
Well Lee,
Thinking back, it should be something as simple as the following:

{code}
Sub FindFieldTextString()
Dim entText As AcadEntity
Dim Pt As Variant

ThisDrawing.Utility.GetEntity entText, Pt, vbCr & "Select text entity:"
If TypeOf entText Is AcadText Or TypeOf entText Is AcadMText Then
MsgBox entText.TextString
End If

End Sub
{code}
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.