<?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: iLogic to Retrieve Path And File of a Model on a Drawing in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/8903861#M99463</link>
    <description>&lt;P&gt;Hi, look at the following code maybe I can help you. With it you can access the model document from the drawing view.&lt;BR /&gt;I used a view selection method. You can select the view through the item or otherwise if you need it.&lt;BR /&gt;I hope this helps. regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oView&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingView&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;SelectionFilterEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kDrawingViewFilter&lt;/SPAN&gt;, &lt;SPAN&gt;"Seleccione Vista"&lt;/SPAN&gt;)
&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oView&lt;/SPAN&gt; &lt;SPAN&gt;Is&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt; &lt;SPAN&gt;Exit&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;
	
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oModelDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Document&lt;/SPAN&gt; = &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;ReferencedDocumentDescriptor&lt;/SPAN&gt;.&lt;SPAN&gt;ReferencedDocument&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oViewModelName&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;oModelDoc&lt;/SPAN&gt;.&lt;SPAN&gt;DisplayName&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oFullFilePath&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;oModelDoc&lt;/SPAN&gt;.&lt;SPAN&gt;FullFileName&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oFolderPath&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;Left&lt;/SPAN&gt;(&lt;SPAN&gt;oFullFilePath&lt;/SPAN&gt;, (&lt;SPAN&gt;InStrRev&lt;/SPAN&gt;(&lt;SPAN&gt;oFullFilePath&lt;/SPAN&gt;, &lt;SPAN&gt;"\"&lt;/SPAN&gt;, - 1, &lt;SPAN&gt;vbTextCompare&lt;/SPAN&gt;) - 1))

&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"DisplayName: "&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;oViewModelName&lt;/SPAN&gt;)
&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"FullFilename: "&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;oFullFilePath&lt;/SPAN&gt;)
&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"FolderPath: "&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;oFolderPath&lt;/SPAN&gt; )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2019 14:14:17 GMT</pubDate>
    <dc:creator>Sergio.D.Suárez</dc:creator>
    <dc:date>2019-07-11T14:14:17Z</dc:date>
    <item>
      <title>iLogic to Retrieve Path And File of a Model on a Drawing</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/8903743#M99456</link>
      <description>&lt;P&gt;Hi Forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I get the path and file of a model inside an idw?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felix Cortes&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 13:31:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/8903743#M99456</guid>
      <dc:creator>felix.cortes5K3Y2</dc:creator>
      <dc:date>2019-07-11T13:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Retrieve Path And File of a Model on a Drawing</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/8903861#M99463</link>
      <description>&lt;P&gt;Hi, look at the following code maybe I can help you. With it you can access the model document from the drawing view.&lt;BR /&gt;I used a view selection method. You can select the view through the item or otherwise if you need it.&lt;BR /&gt;I hope this helps. regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oView&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingView&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;SelectionFilterEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kDrawingViewFilter&lt;/SPAN&gt;, &lt;SPAN&gt;"Seleccione Vista"&lt;/SPAN&gt;)
&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oView&lt;/SPAN&gt; &lt;SPAN&gt;Is&lt;/SPAN&gt; &lt;SPAN&gt;Nothing&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt; &lt;SPAN&gt;Exit&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;
	
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oModelDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Document&lt;/SPAN&gt; = &lt;SPAN&gt;oView&lt;/SPAN&gt;.&lt;SPAN&gt;ReferencedDocumentDescriptor&lt;/SPAN&gt;.&lt;SPAN&gt;ReferencedDocument&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oViewModelName&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;oModelDoc&lt;/SPAN&gt;.&lt;SPAN&gt;DisplayName&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oFullFilePath&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;oModelDoc&lt;/SPAN&gt;.&lt;SPAN&gt;FullFileName&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oFolderPath&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;Left&lt;/SPAN&gt;(&lt;SPAN&gt;oFullFilePath&lt;/SPAN&gt;, (&lt;SPAN&gt;InStrRev&lt;/SPAN&gt;(&lt;SPAN&gt;oFullFilePath&lt;/SPAN&gt;, &lt;SPAN&gt;"\"&lt;/SPAN&gt;, - 1, &lt;SPAN&gt;vbTextCompare&lt;/SPAN&gt;) - 1))

&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"DisplayName: "&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;oViewModelName&lt;/SPAN&gt;)
&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"FullFilename: "&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;oFullFilePath&lt;/SPAN&gt;)
&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"FolderPath: "&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;oFolderPath&lt;/SPAN&gt; )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 14:14:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/8903861#M99463</guid>
      <dc:creator>Sergio.D.Suárez</dc:creator>
      <dc:date>2019-07-11T14:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Retrieve Path And File of a Model on a Drawing</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/8903888#M99464</link>
      <description>&lt;P&gt;Felix,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use the ModelDocument code snippet from Advanced Drawing API. This will retrieve the model associated to the drawing. If there's more than one model, it will pick the first one. If there is more than one model, you can use the ModelDocument(View) snippet and this will let you define the view name and it will retrieve the model associated to the view. Once the model is retrieved, which is a document object, you can get different properties such as Displayname, FillFileName, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2019-07-11_9-18-35.jpg" style="width: 214px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/656556iC47DB4BC4F0FB9E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="2019-07-11_9-18-35.jpg" alt="2019-07-11_9-18-35.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So the code will look something like this. Hope that helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DanV&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #800000;"&gt;doc&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;ThisDrawing&lt;/SPAN&gt;.&lt;SPAN style="color: #800080;"&gt;ModelDocument&lt;/SPAN&gt; &lt;SPAN style="color: #808080;"&gt;'from the Model Document snippet&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Show&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;doc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;FullDocumentName&lt;/SPAN&gt;) &lt;SPAN style="color: #808080;"&gt;'use FullDocumentName to get path &amp;amp; file name&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Show&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;doc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;DisplayName&lt;/SPAN&gt;) &lt;SPAN style="color: #808080;"&gt;'use to get the file name only&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN style="color: #800000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 14:25:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/8903888#M99464</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-11T14:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Retrieve Path And File of a Model on a Drawing</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/9137697#M102961</link>
      <description>&lt;P&gt;Hi DanV,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add a sheet, based on an existing sheet format, for the part/assembly in my drawing.&lt;/P&gt;&lt;P&gt;The snippet you suggest fetches the file path, but how would I insert it into the code below, to fulfill the function I require? Any guidance would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'Set a reference to the sheet format named "C size, 4 view"
Dim oFormat As SheetFormat
Try
oFormat = oDrawDoc.SheetFormats.Item("C size, 4 view")
Catch
MessageBox.Show("Error: C size, 4 view might not exist.", "iLogic")
Return
End Try

'Open the model document invisible
Dim oModel As Document
oModel = ThisApplication.Documents.Open("C:\TEMP\block.ipt", False)

'Create a new sheet based on the sheet format using the specified model
Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat, oModel)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Nov 2019 09:29:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/9137697#M102961</guid>
      <dc:creator>tjvz85</dc:creator>
      <dc:date>2019-11-10T09:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Retrieve Path And File of a Model on a Drawing</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/9139775#M103001</link>
      <description>&lt;P&gt;Hello tjvz85,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if I understand your request. Can you give me more detail as to what you are looking to do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code that you have there will create a new sheet using the "C Size, 4 View" sheet format. It will use the block.ipt as the model for the sheet format. So when it first starts, there is no model yet. It's a blank sheet therefore this is no model path to retrieve.&amp;nbsp; Then it will look for the block.ipt in C:\temp and use that as the model for the sheet format. The block.ipt is hard coded into the rule. Are you asking if you can be prompted for the model? If so, you can do something like this. Hopefully that's what you are looking for. If not, repost and let's try again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #808080;"&gt;' Set a reference to the drawing document.&lt;/SPAN&gt;
&lt;SPAN style="color: #808080;"&gt;' This assumes a drawing document is active.&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oDrawDoc&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;DrawingDocument&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;oDrawDoc&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;ActiveDocument&lt;/SPAN&gt;

&lt;SPAN style="color: #808080;"&gt;'Set a reference to the sheet format named "C size, 4 view"&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oFormat&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;SheetFormat&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Try&lt;/SPAN&gt;
	&lt;SPAN style="color: #800000;"&gt;oFormat&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;oDrawDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;SheetFormats&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Item&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"C size, 4 view"&lt;/SPAN&gt;)
&lt;SPAN style="color: #ff0000;"&gt;Catch&lt;/SPAN&gt;
	&lt;SPAN style="color: #800000;"&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Show&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"Error: C size, 4 view might not exist."&lt;/SPAN&gt;, &lt;SPAN style="color: #008080;"&gt;"iLogic"&lt;/SPAN&gt;)
	&lt;SPAN style="color: #ff0000;"&gt;Return&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Try&lt;/SPAN&gt;

&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;openfiledia&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;New&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;OpenFileDialog&lt;/SPAN&gt;()
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;strModelFile&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;String&lt;/SPAN&gt;

&lt;SPAN style="color: #ff0000;"&gt;With&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;openfiledia&lt;/SPAN&gt;
	.&lt;SPAN style="color: #800000;"&gt;Filter&lt;/SPAN&gt; = &lt;SPAN style="color: #008080;"&gt;"Autodesk Inventor Part|*.ipt|Autodesk Inventor Assembly|*.iam"&lt;/SPAN&gt;
	.&lt;SPAN style="color: #800000;"&gt;Multiselect&lt;/SPAN&gt; = &lt;SPAN style="color: #ff0000;"&gt;False&lt;/SPAN&gt;
	&lt;SPAN style="color: #808080;"&gt;'if user cancelled, exit this subroutine&lt;/SPAN&gt;
	&lt;SPAN style="color: #ff0000;"&gt;If&lt;/SPAN&gt; .&lt;SPAN style="color: #800000;"&gt;ShowDialog&lt;/SPAN&gt;() = &lt;SPAN style="color: #800000;"&gt;DialogResult&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Cancel&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Then&lt;/SPAN&gt;
		&lt;SPAN style="color: #ff0000;"&gt;Exit&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Sub&lt;/SPAN&gt;
	&lt;SPAN style="color: #ff0000;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;If&lt;/SPAN&gt;
	
	&lt;SPAN style="color: #800000;"&gt;strModelFile&lt;/SPAN&gt; = .&lt;SPAN style="color: #800000;"&gt;FileName&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;With&lt;/SPAN&gt;

&lt;SPAN style="color: #808080;"&gt;'Open the model document invisible&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oModel&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Document&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;oModel&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Documents&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Open&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;strModelFile&lt;/SPAN&gt;, &lt;SPAN style="color: #ff0000;"&gt;False&lt;/SPAN&gt;)

&lt;SPAN style="color: #808080;"&gt;'Create a new sheet based on the sheet format using the specified model&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;oSheet&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Sheet&lt;/SPAN&gt;
&lt;SPAN style="color: #800000;"&gt;oSheet&lt;/SPAN&gt; = &lt;SPAN style="color: #800000;"&gt;oDrawDoc&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;Sheets&lt;/SPAN&gt;.&lt;SPAN style="color: #800000;"&gt;AddUsingSheetFormat&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;oFormat&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;oModel&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 18:20:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/9139775#M103001</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-11T18:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic to Retrieve Path And File of a Model on a Drawing</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/9143319#M103044</link>
      <description>&lt;P&gt;Hi DanV,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is this:&lt;/P&gt;&lt;P&gt;We create new drawings for every part or assembly and we use the same template.&lt;/P&gt;&lt;P&gt;For parts, there will only be one sheet per drawing, but for assemblies, we add a sheet for a production specific partslist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add the sheet for the assembly file that is on the first sheet.&lt;/P&gt;&lt;P&gt;I have code (written by Curtis Waguespack) to check the Views on the sheet to see whether a part or assembly has been placed and then call a specific function. But I wanted to see if I can rather just check the file placed in the drawing, determine whether it is a part or assembly, and then place the second sheet if it is an assembly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below checks the views, if they are of an assembly, it checks if the model file has a Design view named colour and the writes the colour to a custom iproperty that I use in the title block. If we can't just verify whether the referenced file is an assembly, I would like to run through the views and place the sheet, based on existing Sheet Format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your further assistance.&lt;/P&gt;&lt;PRE&gt;Sub Main 
	' Get the active drawing document. 
	Dim oDoc As DrawingDocument 
	oDoc = ThisApplication.ActiveDocument 
	
	Dim oSheet As Sheet
	oSheet = oDoc.ActiveSheet	
	
	Dim oViews As DrawingViews
	Dim oView As DrawingView
	

	'get the collection of view on the sheet
	oViews = oSheet.DrawingViews		
	
	' Iterate through the views on the sheet
	For Each oView In oViews	
		
		Dim docDesc As DocumentDescriptor 
		docDesc = oView.ReferencedDocumentDescriptor  
		
		' Verify that the drawing view is of an assembly. 
		If docDesc.ReferencedDocumentType &amp;lt;&amp;gt; kAssemblyDocumentObject Then 
			Continue For
		End If  
		
		' Get the component definition for the assembly. 
		Dim asmDef As AssemblyComponentDefinition 
		asmDef = docDesc.ReferencedDocument.ComponentDefinition 
		
		'define view rep collection
		Dim oViewReps As DesignViewRepresentations
		oViewReps = asmDef.RepresentationsManager.DesignViewRepresentations
		
		oColourViewRepFound = False
		For Each oViewRep In oViewReps
			If oViewRep.Name = "Colour" Then
				oColourViewRepFound = True 
			End If
		Next
		
		If oColourViewRepFound = True Then
			Call ProcessAssemblyColor(oView, asmDef.Occurrences) 
		End If
	Next

End Sub 



Private Sub ProcessAssemblyColor(drawView As DrawingView, _ 
                                 Occurrences As ComponentOccurrences) 
   ' Iterate through the current collection of occurrences. 
   Dim occ As ComponentOccurrence 
   For Each occ In Occurrences 
      ' Check to see if this occurrence is a part or assembly. 
      If occ.DefinitionDocumentType = kPartDocumentObject Then 

         ' Get the render style of the occurrence. 
         Dim color As RenderStyle 
         Dim sourceType As StyleSourceTypeEnum 
         color = occ.GetRenderStyle(sourceType)  
		If color.name IsNot Nothing Then
		 iProperties.Value("Custom", "Lackierung") = color.name
		 Exit For
	 	End If
			

      End If 
   Next 
End Sub&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Nov 2019 08:51:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-to-retrieve-path-and-file-of-a-model-on-a-drawing/m-p/9143319#M103044</guid>
      <dc:creator>tjvz85</dc:creator>
      <dc:date>2019-11-13T08:51:36Z</dc:date>
    </item>
  </channel>
</rss>

