<?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: Logical type of Active Inv Doc (if TryCast is a best bet) in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215130#M87980</link>
    <description>&lt;PRE&gt;Sub Test()
Dim app As Application
Dim Doc As Document
Dim CompDef As ComponentDefinition
Dim MsgBody As String

Set app = ThisApplication
Set Doc = app.ActiveDocument

Select Case Doc.DocumentType
Case Is = DocumentTypeEnum.kPartDocumentObject
    MsgBody = "Part File"
    Set CompDef = Doc.ComponentDefinition
    If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part Factory"
    If CompDef.IsiPartMember Then MsgBody = "Multi-config Part Member"
Case Is = DocumentTypeEnum.kDrawingDocumentObject
    MsgBody = "Plain Drawing File"
    Dim DocM As Document
    If Doc.ReferencedDocuments.Count &amp;gt; 0 Then
        Set DocM = Doc.ReferencedDocuments.Item(1)
        Set CompDef = DocM.ComponentDefinition
        Select Case DocM.DocumentType
        Case Is = DocumentTypeEnum.kPartDocumentObject
            MsgBody = "Part Drawing File"
            If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part drawing Factory"
            If CompDef.IsiPartMember Then MsgBody = "Multi-config Part drawing Member"
        Case Id = DocumentTypeEnum.kAssemblyDocumentObject
            MsgBody = "Assy Drawing File"
            If CompDef.IsiPartFactory Then MsgBody = "Multi-config Assy drawing Factory"
            If CompDef.IsiPartMember Then MsgBody = "Multi-config Assy drawing Member"
        End Select
    End If
Case Is = DocumentTypeEnum.kAssemblyDocumentObject
    MsgBody = "Assy File"
    Set CompDef = Doc.ComponentDefinition
    If CompDef.IsiAssemblyFactory Then MsgBody = "Multi-config Assy Factory"
    If CompDef.IsiAssemblyMember Then MsgBody = "Multi-config Assy Member"
End Select
MsgBox (MsgBody)

End Sub&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Aug 2018 20:53:37 GMT</pubDate>
    <dc:creator>clutsa</dc:creator>
    <dc:date>2018-08-21T20:53:37Z</dc:date>
    <item>
      <title>Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8213626#M87943</link>
      <description>&lt;P&gt;I'm playing around with iLogic trying to find best way to get logical type of active document.&lt;/P&gt;&lt;P&gt;I mean&amp;nbsp;those logical types:&lt;/P&gt;&lt;P&gt;3D-models&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Generic Part&lt;/LI&gt;&lt;LI&gt;Generic Assembly&lt;/LI&gt;&lt;LI&gt;Generic Drawing&lt;/LI&gt;&lt;LI&gt;iPart Factory&lt;/LI&gt;&lt;LI&gt;iPart Member&lt;/LI&gt;&lt;LI&gt;iAssy Factory&lt;/LI&gt;&lt;LI&gt;iAssy Member&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;2D-drawings&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Generic Drawing (not based on&amp;nbsp;any&amp;nbsp;3D-model)&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Exploded View Drawing&lt;/LI&gt;&lt;LI&gt;(Single) Part Drawing&lt;/LI&gt;&lt;LI&gt;(Single) Assembly Drawing&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Multi-configuration Part Drawing (based on iPart Member or iPart Factory)&amp;nbsp;&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Multi-configuration Assembly Drawing&amp;nbsp;(based on iAssy Member or iAssy Factory)&amp;nbsp;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I 've achieved my goal to about 75%. There are problems with Generic Drawing (object not set to an instance of an object) and both multi-config drawings (I'm a bit confused by depth of object tree and can't find how to get object types for i- factories and members).&lt;/P&gt;&lt;P&gt;My current version of code is:&lt;/P&gt;&lt;PRE&gt;Dim partDoc As PartDocument = TryCast(ThisDoc.Document, PartDocument)
Dim assyDoc As AssemblyDocument = TryCast(ThisDoc.Document, AssemblyDocument)
Dim drwDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
Dim MsgBody As String

If (partDoc IsNot Nothing) Then
	oCompDef=partDoc.ComponentDefinition	
	If (oCompDef.iPartFactory IsNot Nothing) Then
		MsgBody="iPart Factory"		
	Else If (oCompDef.iPartMember IsNot Nothing) Then
		MsgBody="iPart Member"
	Else 
		MsgBody="Generic Part"
	End If
Else If (assyDoc IsNot Nothing) Then
	oCompDef=assyDoc.ComponentDefinition
	If (oCompDef.iAssemblyFactory IsNot Nothing) Then
		MsgBody="iAssy Factory"
	Else If (oCompDef.iAssemblyMember IsNot Nothing) Then
		MsgBody="iAssy Member"
	Else 
		MsgBody="Generic Assembly"
	End If	
Else If (drwDoc IsNot Nothing) Then	
	Dim ModelExt As String = TryCast (IO.Path.GetExtension(ThisDrawing.ModelDocument.FullFileName).ToLower, String)		
	If ModelExt=".ipn" Then
		MsgBody="Exploded view drawing"
	Else If ModelExt=".ipt" Then
		MsgBody="Part drawing"
		' If ??? Then MsgBody="Multi-config Part drawing"
	Else If ModelExt=".iam" Then
		MsgBody="Assembly drawing"
		' If ??? Then MsgBody="Multi-config Assy drawing"	
	Else	
		MsgBody="Generic Drawing"
	End If	
Else
	MsgBody="UnknownDoc" 
End If
MsgBox (MsgBody,,"Type of active doc is:")&lt;/PRE&gt;&lt;P&gt;Can somebody help me with this, please&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 11:14:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8213626#M87943</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2018-08-21T11:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8214435#M87967</link>
      <description>&lt;P&gt;Would any of this info help you?&lt;/P&gt;&lt;PRE&gt;Sub Test()
Dim app As Application
Dim Doc As Document
Dim CompDef As ComponentDefinition
Dim PartType As String

Set app = ThisApplication
Set Doc = app.ActiveDocument
Set CompDef = Doc.ComponentDefinition
iPartFac = CompDef.IsiPartFactory
iPartMem = CompDef.IsiPartMember

Select Case Doc.DocumentType
Case Is = DocumentTypeEnum.kPartDocumentObject
    PartType = "Part File"
Case Is = DocumentTypeEnum.kDrawingDocumentObject
    PartType = "Drawing File"
'Case Is .... keep going with these
End Select

End Sub&lt;/PRE&gt;&lt;P&gt;Those may be easier then what you're doing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know you'll have to have some error trapping but that should be a good start.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 15:53:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8214435#M87967</guid>
      <dc:creator>clutsa</dc:creator>
      <dc:date>2018-08-21T15:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8214491#M87968</link>
      <description>&lt;P&gt;This will probably match more to what you had started.&lt;/P&gt;&lt;PRE&gt;Sub Test()
Dim app As Application
Dim Doc As Document
Dim CompDef As ComponentDefinition
Dim MsgBody As String

Set app = ThisApplication
Set Doc = app.ActiveDocument

Select Case Doc.DocumentType
Case Is = DocumentTypeEnum.kPartDocumentObject
    MsgBody = "Part File"
    Set CompDef = Doc.ComponentDefinition
    If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part Factory"
    If CompDef.IsiPartMember Then MsgBody = "Multi-config Part Member"
Case Is = DocumentTypeEnum.kDrawingDocumentObject
    MsgBody = "Plain Drawing File"
    Dim DocM As Document
    Set DocM = Doc.ReferencedDocuments.Item(1)
    Set CompDef = DocM.ComponentDefinition
    Select Case DocM.DocumentType
    Case Is = DocumentTypeEnum.kPartDocumentObject
        MsgBody = "Part Drawing File"
        If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part drawing Factory"
        If CompDef.IsiPartMember Then MsgBody = "Multi-config Part drawing Member"
    Case Id = DocumentTypeEnum.kAssemblyDocumentObject
        MsgBody = "Assy Drawing File"
        If CompDef.IsiPartFactory Then MsgBody = "Multi-config Assy drawing Factory"
        If CompDef.IsiPartMember Then MsgBody = "Multi-config Assy drawing Member"
    End Select
Case Is = DocumentTypeEnum.kAssemblyDocumentObject
    MsgBody = "Assy File"
    Set CompDef = Doc.ComponentDefinition
    If CompDef.IsiAssemblyFactory Then MsgBody = "Multi-config Assy Factory"
    If CompDef.IsiAssemblyMember Then MsgBody = "Multi-config Assy Member"
End Select
MsgBox (MsgBody)

End Sub&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Aug 2018 16:13:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8214491#M87968</guid>
      <dc:creator>clutsa</dc:creator>
      <dc:date>2018-08-21T16:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215003#M87974</link>
      <description>&lt;P&gt;Thanks. The only weak place - attempt to execute this on empty (without reference to 3Dmodel) drawing -&lt;/P&gt;&lt;P&gt;Run-time error '5':&amp;nbsp;Invalid procedure call or argument.&lt;/P&gt;&lt;P&gt;How would you recommend to&amp;nbsp;treat such errors?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 19:59:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215003#M87974</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2018-08-21T19:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215130#M87980</link>
      <description>&lt;PRE&gt;Sub Test()
Dim app As Application
Dim Doc As Document
Dim CompDef As ComponentDefinition
Dim MsgBody As String

Set app = ThisApplication
Set Doc = app.ActiveDocument

Select Case Doc.DocumentType
Case Is = DocumentTypeEnum.kPartDocumentObject
    MsgBody = "Part File"
    Set CompDef = Doc.ComponentDefinition
    If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part Factory"
    If CompDef.IsiPartMember Then MsgBody = "Multi-config Part Member"
Case Is = DocumentTypeEnum.kDrawingDocumentObject
    MsgBody = "Plain Drawing File"
    Dim DocM As Document
    If Doc.ReferencedDocuments.Count &amp;gt; 0 Then
        Set DocM = Doc.ReferencedDocuments.Item(1)
        Set CompDef = DocM.ComponentDefinition
        Select Case DocM.DocumentType
        Case Is = DocumentTypeEnum.kPartDocumentObject
            MsgBody = "Part Drawing File"
            If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part drawing Factory"
            If CompDef.IsiPartMember Then MsgBody = "Multi-config Part drawing Member"
        Case Id = DocumentTypeEnum.kAssemblyDocumentObject
            MsgBody = "Assy Drawing File"
            If CompDef.IsiPartFactory Then MsgBody = "Multi-config Assy drawing Factory"
            If CompDef.IsiPartMember Then MsgBody = "Multi-config Assy drawing Member"
        End Select
    End If
Case Is = DocumentTypeEnum.kAssemblyDocumentObject
    MsgBody = "Assy File"
    Set CompDef = Doc.ComponentDefinition
    If CompDef.IsiAssemblyFactory Then MsgBody = "Multi-config Assy Factory"
    If CompDef.IsiAssemblyMember Then MsgBody = "Multi-config Assy Member"
End Select
MsgBox (MsgBody)

End Sub&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Aug 2018 20:53:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215130#M87980</guid>
      <dc:creator>clutsa</dc:creator>
      <dc:date>2018-08-21T20:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215835#M87989</link>
      <description>&lt;P&gt;shame on me ...&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 06:21:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215835#M87989</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2018-08-22T06:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215876#M87990</link>
      <description>&lt;P&gt;Extensive testing revealed issues with Assy Drawing&lt;/P&gt;&lt;PRE&gt;Case Is = DocumentTypeEnum.kPartDocumentObject
            MsgBody = "Part Drawing File"
            If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part drawing Factory"
            If CompDef.IsiPartMember Then MsgBody = "Multi-config Part drawing Member"
Case &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Id&lt;/STRONG&gt;&lt;/FONT&gt; = DocumentTypeEnum.kAssemblyDocumentObject&lt;/PRE&gt;&lt;P&gt;If replace "Id" with "Is"&amp;nbsp;then "Public member 'IsiPartFactory' on type 'AssemblyComponentDefinition' not found." &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@F462EEC827775DA92CB03B7FC147D389/emoticons/1f61e.png" alt=":disappointed_face:" title=":disappointed_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 06:56:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8215876#M87990</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2018-08-22T06:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8216290#M88003</link>
      <description>&lt;P&gt;Got it - should be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sub Test()
Dim app As Application
Dim Doc As Document
Dim CompDef As ComponentDefinition
Dim MsgBody As String

Set app = ThisApplication
Set Doc = app.ActiveDocument

Select Case Doc.DocumentType
Case DocumentTypeEnum.kPartDocumentObject
    MsgBody = "Part File"
    Set CompDef = Doc.ComponentDefinition
    If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part Factory"
    If CompDef.IsiPartMember Then MsgBody = "Multi-config Part Member"
Case DocumentTypeEnum.kDrawingDocumentObject
    MsgBody = "Plain Drawing File"
    Dim DocM As Document
    If Doc.ReferencedDocuments.Count &amp;gt; 0 Then
        Set DocM = Doc.ReferencedDocuments.Item(1)
        Set CompDef = DocM.ComponentDefinition
        Select Case DocM.DocumentType
        Case DocumentTypeEnum.kPartDocumentObject
            MsgBody = "Part Drawing File"
            If CompDef.IsiPartFactory Then MsgBody = "Multi-config Part drawing Factory"
            If CompDef.IsiPartMember Then MsgBody = "Multi-config Part drawing Member"
        Case DocumentTypeEnum.kAssemblyDocumentObject
            MsgBody = "Assy Drawing File"
            If CompDef.Is&lt;FONT color="#FF0000"&gt;iAssembly&lt;/FONT&gt;Factory Then MsgBody = "Multi-config Assy drawing Factory"
            If CompDef.Is&lt;FONT color="#FF0000"&gt;iAssembly&lt;/FONT&gt;Member Then MsgBody = "Multi-config Assy drawing Member"
        End Select
    End If
Case DocumentTypeEnum.kAssemblyDocumentObject
    MsgBody = "Assy File"
    Set CompDef = Doc.ComponentDefinition
    If CompDef.IsiAssemblyFactory Then MsgBody = "Multi-config Assy Factory"
    If CompDef.IsiAssemblyMember Then MsgBody = "Multi-config Assy Member"
End Select
MsgBox (MsgBody)

End Sub&lt;/PRE&gt;&lt;P&gt;Anyway solution is yours.. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 11:12:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8216290#M88003</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2018-08-22T11:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: Logical type of Active Inv Doc (if TryCast is a best bet)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8216718#M88013</link>
      <description>&lt;P&gt;Oops. I caught it in the assembly section itself but missed it in the drawing/assembly section. Sorry. Thank you for the solution and posting the correct code.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 13:45:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/logical-type-of-active-inv-doc-if-trycast-is-a-best-bet/m-p/8216718#M88013</guid>
      <dc:creator>clutsa</dc:creator>
      <dc:date>2018-08-22T13:45:30Z</dc:date>
    </item>
  </channel>
</rss>

