<?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: Attach SurfaceTextureSymbol to DiameterGeneralDimension in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3820412#M131575</link>
    <description>&lt;P&gt;Try below VBA code if it works for you, say you have an active drawing document with a diameter dimension on the active sheet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub AttachSurfaceTextureSymbolToDim()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet
    
    Dim oDim As DiameterGeneralDimension
    Set oDim = oSheet.DrawingDimensions(1)
    
    Dim oGI As GeometryIntent
    Set oGI = oSheet.CreateGeometryIntent(oDim, oDim.Text.RangeBox.MinPoint)
    
    Dim oCol As ObjectCollection
    Set oCol = ThisApplication.TransientObjects.CreateObjectCollection
    
    oCol.Add ThisApplication.TransientGeometry.CreatePoint2d(12, 12)
    oCol.Add oGI
    
    Dim oText As SurfaceTextureSymbol
    Set oText = oSheet.SurfaceTextureSymbols.Add(oCol, kBasicSurfaceType, True, , , "Roughness")
End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2013 08:12:19 GMT</pubDate>
    <dc:creator>YuhanZhang</dc:creator>
    <dc:date>2013-04-02T08:12:19Z</dc:date>
    <item>
      <title>Attach SurfaceTextureSymbol to DiameterGeneralDimension</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3820090#M131574</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;After learning Inventor 2010 VBA over past year, I was able to create almost every macro I need for my work (print/convert all, drawing/part copy, automatic dimensioning etc...), mostly thanks to excellent built-in help in Inventor and plenty of very useful examples on internet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But one important thing, which I cannot accomplish (or find anywhere) is to &lt;STRONG&gt;automatically create surface texture symbol and ATTACH it to diameter dimension&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Problem is with &lt;STRONG&gt;defining geometry Intent to attach surface texture symbol to&lt;/STRONG&gt;. I am not able to get text extension line data (DiameterGeneralDimension object only has .dimensionline which is linesegment2D inside of hole geometry curve).&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Only way I found, to create surface texture where I want it (under center of text on extension line), is If I create surface texture symbol&amp;nbsp;&lt;EM&gt;manually&lt;/EM&gt;, attach it to this point and then, by using selectset, I can get intent to which surface texture leader(1) is attached to. Then I can use this Intent to create another surface texture on the same spot. (Which is obviously not useful for automation)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;So my question is:&lt;/STRONG&gt;&lt;/U&gt; &lt;EM&gt;&lt;STRONG&gt;Is it possible to attach surface texture symbol to dimension text extension line using VBA?&lt;/STRONG&gt; &lt;STRONG&gt;&amp;nbsp;And if so, How?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bellow is Function I use to create surface texture with ladder near dimension text (best I was able to achieve without error)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Function Pridej_drsnost_ke_kote(ByVal oPrumer_Kota  As DrawingDimension)
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    Dim oActiveSheet As sheet
    Set oActiveSheet = oDrawDoc.ActiveSheet

    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry

    Dim oLeaderPoints As ObjectCollection
    Set oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

     Call oLeaderPoints.Add(oTG.CreatePoint2d(oPrumer_Kota.Text.Origin.x + 0.5,    oPrumer_Kota.Text.Origin.y - 1.5))
     Call oLeaderPoints.Add(oTG.CreatePoint2d(oPrumer_Kota.Text.Origin.x + 0.8, oPrumer_Kota.Text.Origin.y - 1.8))

    Dim oSymbol As SurfaceTextureSymbol
    Set oSymbol = oActiveSheet.SurfaceTextureSymbols.Add(oLeaderPoints, kMaterialRemovalRequiredSurfaceType, False, False, False, "1,6")
    
End Function&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This is the result which I would like to achieve:&lt;/P&gt;&lt;P&gt;&lt;IMG align="center" border="0" title="SurfaceTextureSymbol.png" alt="SurfaceTextureSymbol.png" src="https://forums.autodesk.com/t5/image/serverpage/image-id/49704i797EFAB13BA76E66/image-size/medium?v=mpbl-1&amp;amp;px=-1" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2013 19:36:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3820090#M131574</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-01T19:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Attach SurfaceTextureSymbol to DiameterGeneralDimension</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3820412#M131575</link>
      <description>&lt;P&gt;Try below VBA code if it works for you, say you have an active drawing document with a diameter dimension on the active sheet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub AttachSurfaceTextureSymbolToDim()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet
    
    Dim oDim As DiameterGeneralDimension
    Set oDim = oSheet.DrawingDimensions(1)
    
    Dim oGI As GeometryIntent
    Set oGI = oSheet.CreateGeometryIntent(oDim, oDim.Text.RangeBox.MinPoint)
    
    Dim oCol As ObjectCollection
    Set oCol = ThisApplication.TransientObjects.CreateObjectCollection
    
    oCol.Add ThisApplication.TransientGeometry.CreatePoint2d(12, 12)
    oCol.Add oGI
    
    Dim oText As SurfaceTextureSymbol
    Set oText = oSheet.SurfaceTextureSymbols.Add(oCol, kBasicSurfaceType, True, , , "Roughness")
End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2013 08:12:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3820412#M131575</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2013-04-02T08:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Attach SurfaceTextureSymbol to DiameterGeneralDimension</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3821333#M131576</link>
      <description>&lt;P&gt;Thank you for excelent tip &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt; Using text.rangebox never came into my mind.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sadly, at least in Inventor 2010, your solution works only if dimension text is in few specific positions. If I compare this example to clock dial, then add surface texture to diameter dimension only works, if text is located in ranges 1 to 3 or 7 to 9 o'clock. In all other position metod SurfaceTextureSymbols.Add failed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; But this is only minor setback, because it is no problem to move dimension text to where i want it, add surface texture symbol (STS) and finaly move text back to original position. Also if I move text, so its&amp;nbsp;X axis is aligned with drawing X axis then I can simply measure text width and place STS in middle, which is exactly what I wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Only thing which remain unclear to me is, how to update drawing, that after moving dimension to its original position STS moves with it? (In code below i create another dimension and then delete it, to update drawing).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code should do exactly what I wanted to achieve in my original post:&lt;/P&gt;&lt;PRE&gt;Sub AttachSurfaceTextureSymbolToDim()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As sheet
    Set oSheet = oDoc.ActiveSheet
    
    Dim oDim As DiameterGeneralDimension
    Set oDim = oSheet.DrawingDimensions(1)
    
    Dim oDimTextPoint As Point2d
    Set oDimTextPoint = oDim.Text.Origin
    
    Dim oDimIntent As GeometryIntent
    Set oDimIntent = oDim.Intent
    
    With ThisApplication.TransientGeometry
        
        oDim.Text.Origin = .CreatePoint2d(oDimIntent.Geometry.CenterPoint.x + 10, oDimIntent.Geometry.CenterPoint.y)
    
        Dim TextCenterPoint As Point2d
        Set TextCenterPoint = .CreatePoint2d(((oDim.Text.RangeBox.MinPoint.x + oDim.Text.RangeBox.MaxPoint.x) / 2) + 0.2, oDim.Text.RangeBox.MinPoint.y)
        
        Dim oGI As GeometryIntent
        Set oGI = oSheet.CreateGeometryIntent(oDim, TextCenterPoint)
        
        Dim oCol As ObjectCollection
        Set oCol = ThisApplication.TransientObjects.CreateObjectCollection
    
        oCol.Add .CreatePoint2d(TextCenterPoint.x, TextCenterPoint.y - 0.1)
        oCol.Add oGI
    
    End With
    
    Dim oText As SurfaceTextureSymbol
    Set oText = oSheet.SurfaceTextureSymbols.Add(oCol, kMaterialRemovalRequiredSurfaceType, False, False, False, "1,6")
    
    oDim.Text.Origin = oDimTextPoint
     
    'I am doing this part below only because I don't know how to update drawing, to move surface texture symbol into right position
    Set oDim = oSheet.DrawingDimensions.GeneralDimensions.AddDiameter(oDimTextPoint, oDimIntent)
    oDim.Delete
     
End Sub&lt;/PRE&gt;&lt;P&gt;Once more Thank You&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2013 20:18:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3821333#M131576</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-02T20:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Attach SurfaceTextureSymbol to DiameterGeneralDimension</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3821573#M131577</link>
      <description>&lt;P&gt;It looks wierd that add a surface texture symbol fails because of dimension text orientation, can you attach data that can reproduce the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To update a drawing document you can call DrawingDocument.Update.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2013 03:02:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3821573#M131577</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2013-04-03T03:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Attach SurfaceTextureSymbol to DiameterGeneralDimension</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3822536#M131578</link>
      <description>&lt;P&gt;It is definitely weird.&lt;/P&gt;&lt;P&gt;I added an example with 18 dimensions in attachment (It is meant for use with your code from post 2, by changing oSheet.DrawingDimensions number from 1 to 18).&lt;/P&gt;&lt;P&gt;From 18 dimensions&amp;nbsp;works on my system only 4&amp;nbsp;(1,7,13,14), all other failed. I tested it on Inventor Professional 2010 SP2; SP3; SP4 (build 284, relase date 06/23/211) running on Windows 7 Ultimate 64 bit. On all service pack which I tested, I have the same result (except above mentioned 4 dimensions)...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error: Run-time error '-2147467259 (8004005)': Method 'Add' of object 'Surface TextureSymbols' failed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also update drawing by using thisdrawing.update (or update2) didn't work, because Surface Texture Symbol didn't move into right position, till I create something new on drawing. (Or move view, or edit TitleBlock, or do something similar). It seems like .update did not affect surface texture symbols.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2013 19:00:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3822536#M131578</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-03T19:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Attach SurfaceTextureSymbol to DiameterGeneralDimension</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3840177#M131579</link>
      <description>&lt;P&gt;Yes, the RangeBox currently could not work for the dimension text which is not vertical/horizontal alignment. And I think we need new property for dimension text to get the box of it for attach a leader to. But for now a workaround might be to change the dimension style to have dimension text alignment to be horizontal/vertical.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the DrawingDocument.Update does not work, can you try Sheet.Update?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2013 02:21:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/attach-surfacetexturesymbol-to-diametergeneraldimension/m-p/3840177#M131579</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2013-04-08T02:21:57Z</dc:date>
    </item>
  </channel>
</rss>

