<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Field and linked object in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6502398#M8695</link>
    <description>&lt;P&gt;Thanks for your help !&lt;/P&gt;&lt;P&gt;Hereunder the code, most important lines are in bold.&lt;/P&gt;&lt;P&gt;Last question : once I the object is selected, how can I display its properties in the AutoCAD Properties dialog box ? Exactly like when I click on an object, its properties and grips are displayed. If I Highlight and Select the object (VBA), it is highlighted. It is also selected in VBA-side, but not in user-side.&lt;/P&gt;&lt;PRE&gt;Sub Find_object_by_field()
'Zoom on the object concerned by the selected field&lt;BR /&gt;
Dim oSel As AcadSelectionSet
Dim oTxt As AcadMText
Dim oObjectId As Variant
Dim oObj As AcadObject
Dim ObjType As String
Dim txtField As String

Dim varPointMin As Variant
Dim varPointMax As Variant

Dim point1(0 To 2) As Double
Dim point2(0 To 2) As Double

Const cstMargeZoom = 0.6

On Error Resume Next
ThisDrawing.SelectionSets("oSel").Delete
On Error GoTo 0

ThisDrawing.SelectionSets.Add ("oSel")

Set oSel = ThisDrawing.SelectionSets("oSel")

'Select the object
oSel.SelectOnScreen
Set oObj = oSel(0)
ObjType = TypeName(oObj)

'Test if the selected object is a Text or MText&lt;BR /&gt;if ObjType = "IAcadText" Or ObjType = "IAcadMText" Then
    txtField = oObj.FieldCode
    MsgBox (txtField)
Else
MsgBox ("Select a text")
Exit Sub
End If

&lt;STRONG&gt;'From the text, extract the Object Id&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;varObjId = Val(Split(Split(txtField, "_ObjId")(1), "&amp;gt;")(0))&lt;/STRONG&gt;
&lt;STRONG&gt;'Find the object&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;For Each objacad In ThisDrawing.ModelSpace

If objacad.ObjectID = varObjId Then
ReDim ssobjs(0) As AcadEntity
Set ssobjs(0) = objacad
oSel.AddItems ssobjs
oSel.Highlight (True)&lt;/STRONG&gt;
'Zoom on the object&lt;BR /&gt;objacad.GetBoundingBox varPointMin, varPointMax

point1(0) = varPointMin(0)
point1(1) = varPointMin(1)
point1(2) = 0
point2(0) = varPointMax(0)
point2(1) = varPointMax(1)
point2(2) = 0

ZoomWindow point1, point2
ZoomScaled cstMargeZoom, acZoomScaledRelative
 
Exit For
End If
Next objacad

End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Aug 2016 08:15:33 GMT</pubDate>
    <dc:creator>TONELLAL</dc:creator>
    <dc:date>2016-08-16T08:15:33Z</dc:date>
    <item>
      <title>Field and linked object</title>
      <link>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6487644#M8693</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have some drawings with a lot of fields in tables. I'm looking for a way to retrieve the object from the field, is it possible ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example :&lt;/P&gt;&lt;P&gt;I have lines in my drawing. For each one I've created a field to extract the length in a table. Now, I would know which line has its length written in the 3rd row of my table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 13:59:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6487644#M8693</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2016-08-09T13:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Field and linked object</title>
      <link>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6487930#M8694</link>
      <description>&lt;P&gt;Here are the steps you need to do.&lt;/P&gt;&lt;P&gt;First, select the text in the cell that contains the field. It will contain text that is formatted like this "%&amp;lt;\AcObjProp Object(%&amp;lt;\_ObjId 8796088073328&amp;gt;%).Length \f "%lu6"&amp;gt;%".&lt;/P&gt;&lt;P&gt;Use string functions to extract the ObjectID number from the text string.&lt;/P&gt;&lt;P&gt;Loop through the AcadEntity objects in modelspace (or ps) examining the ObjectID property to find the right entity.&lt;/P&gt;&lt;P&gt;Once you have id'd it, add it to a selectionset or highlight it.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 15:13:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6487930#M8694</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2016-08-09T15:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Field and linked object</title>
      <link>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6502398#M8695</link>
      <description>&lt;P&gt;Thanks for your help !&lt;/P&gt;&lt;P&gt;Hereunder the code, most important lines are in bold.&lt;/P&gt;&lt;P&gt;Last question : once I the object is selected, how can I display its properties in the AutoCAD Properties dialog box ? Exactly like when I click on an object, its properties and grips are displayed. If I Highlight and Select the object (VBA), it is highlighted. It is also selected in VBA-side, but not in user-side.&lt;/P&gt;&lt;PRE&gt;Sub Find_object_by_field()
'Zoom on the object concerned by the selected field&lt;BR /&gt;
Dim oSel As AcadSelectionSet
Dim oTxt As AcadMText
Dim oObjectId As Variant
Dim oObj As AcadObject
Dim ObjType As String
Dim txtField As String

Dim varPointMin As Variant
Dim varPointMax As Variant

Dim point1(0 To 2) As Double
Dim point2(0 To 2) As Double

Const cstMargeZoom = 0.6

On Error Resume Next
ThisDrawing.SelectionSets("oSel").Delete
On Error GoTo 0

ThisDrawing.SelectionSets.Add ("oSel")

Set oSel = ThisDrawing.SelectionSets("oSel")

'Select the object
oSel.SelectOnScreen
Set oObj = oSel(0)
ObjType = TypeName(oObj)

'Test if the selected object is a Text or MText&lt;BR /&gt;if ObjType = "IAcadText" Or ObjType = "IAcadMText" Then
    txtField = oObj.FieldCode
    MsgBox (txtField)
Else
MsgBox ("Select a text")
Exit Sub
End If

&lt;STRONG&gt;'From the text, extract the Object Id&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;varObjId = Val(Split(Split(txtField, "_ObjId")(1), "&amp;gt;")(0))&lt;/STRONG&gt;
&lt;STRONG&gt;'Find the object&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;For Each objacad In ThisDrawing.ModelSpace

If objacad.ObjectID = varObjId Then
ReDim ssobjs(0) As AcadEntity
Set ssobjs(0) = objacad
oSel.AddItems ssobjs
oSel.Highlight (True)&lt;/STRONG&gt;
'Zoom on the object&lt;BR /&gt;objacad.GetBoundingBox varPointMin, varPointMax

point1(0) = varPointMin(0)
point1(1) = varPointMin(1)
point1(2) = 0
point2(0) = varPointMax(0)
point2(1) = varPointMax(1)
point2(2) = 0

ZoomWindow point1, point2
ZoomScaled cstMargeZoom, acZoomScaledRelative
 
Exit For
End If
Next objacad

End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 08:15:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6502398#M8695</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2016-08-16T08:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Field and linked object</title>
      <link>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6504075#M8696</link>
      <description>&lt;P&gt;VBA can't do what you want. It will only highlight. You have to set the PickFirstSelectionSet using lisp. You can run the lisp from your vba though. Make sure this is the last line. "ent" is the AcadEntity that you want to select.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ThisDrawing.SendCommand "(sssetfirst nil (setq ss (ssadd (handent """ &amp;amp; ent.Handle &amp;amp; """))))" &amp;amp; vbCrLf&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 21:10:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6504075#M8696</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2016-08-16T21:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Field and linked object</title>
      <link>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6504767#M8697</link>
      <description>Ok !&lt;BR /&gt;I already have a selectionset containing the object, so I don't think I need to use Pickfirstselectionset ?&lt;BR /&gt;I don't see difference between :&lt;BR /&gt;&lt;BR /&gt;ThisDrawing.SendCommand "(sssetfirst nil (setq ss (ssadd (oObj """ &amp;amp; ent.Handle &amp;amp; """))))" &amp;amp; vbCrLf, where oObj is the AcadEntity to select&lt;BR /&gt;And&lt;BR /&gt;oSel.Highlight (True), where oSel is the selectionset containing only oObj&lt;BR /&gt;&lt;BR /&gt;Alain&lt;BR /&gt;******************************************************************************************&lt;BR /&gt;CONFIDENTIALITY NOTICE&lt;BR /&gt;This e-mail and any attachment are confidential and may be privileged or otherwise protected from disclosure. It is solely intended for the person(s) named above. If you are not the intended recipient, any reading, use, disclosure, copying or distribution of all or parts of this e-mail or associated attachments is strictly prohibited. If you are not an intended recipient, please notify the sender immediately by replying to this message or by telephone and delete this e-mail and any attachments permanently from your system.</description>
      <pubDate>Wed, 17 Aug 2016 08:21:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6504767#M8697</guid>
      <dc:creator>TONELLAL</dc:creator>
      <dc:date>2016-08-17T08:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Field and linked object</title>
      <link>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6505442#M8698</link>
      <description>&lt;P&gt;The PickFirstSelectionSet is a spectial set containing the objects that are highlighted and gripped, So you have to set it to contain the objects you want. The two lines you showed look like they should both do the same thing, but as I mentioned before, vba won't do it. It has never worked. In vba, the PickFirstSelectionSet property is read-only. So, you have to use lisp.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, you can remove the code dealing with the selection set you created. Especially if you're only ever going to deal with one entity.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 14:09:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/field-and-linked-object/m-p/6505442#M8698</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2016-08-17T14:09:32Z</dc:date>
    </item>
  </channel>
</rss>

