- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
i have a Problem with the following code. If i change a sheetmetal part in an assembly, i get this message:
Fehler in Regel: Flaeche_Zuschnitt in Dokument: test1.ipt
Das COM-Objekt des Typs "Inventor._DocumentClass" kann nicht in den Schnittstellentyp "Inventor.PartDocument" umgewandelt werden. Dieser Vorgang konnte nicht durchgeführt werden, da der QueryInterface-Aufruf an die COM-Komponente für die Schnittstelle mit der IID "{29F0D463-C114-11D2-B77F-0060B0F159EF}" aufgrund des folgenden Fehlers nicht durchgeführt werden konnte: Schnittstelle nicht unterstützt (Ausnahme von HRESULT: 0x80004002 (E_NOINTERFACE)).
What is wrong with that code?
Thanks in advance.
Regards
Martin
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
If oDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Dim oDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
If Not oDef.HasFlatPattern Then
oDef.Unfold()
End If
Dim oFlatPattern As FlatPattern = oDef.FlatPattern
'Dim dArea As Double = Round(oFlatPattern.TopFace.Evaluator.Area,4) 'use this one for cm^2
'Dim dArea As Double = Round(oFlatPattern.TopFace.Evaluator.Area * 0.00107639104,4) 'use this one for ft^2
'Dim dArea As Double = Round(oFlatPattern.TopFace.Evaluator.Area * 100,4) 'use this one for mm^2
Dim dArea As Double = Round(oFlatPattern.TopFace.Evaluator.Area * 0.0001,3) 'use this one for m^2
iProperties.Value("Custom", "Flaeche_Zuchnitt") = dArea
iProperties.Value("Custom", "Einheit") = "QM"
currentStyle = SheetMetal.GetActiveStyle()
If (currentStyle = ("AL 0,5")) Then
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Looks like you might be missing the lower part of your code (If Then … Nothing!), but off the top of my head, it looks like you’re assigning ThisApplication.ActiveDocument to a oDoc. The problem with that, from the Assembly level, is that the Active Document would be of the AssemblyDocumentType, and not the PartDocumentType.
The AssemblyDocument Type has subtype or SheetMetalComponentDefinition.
If you have that rule set up in an individual part (meaning that it isn’t an external rule), you should try using ‘ThisDoc.Document’ instead of ThisApplication.ActiveDocument.
If my solution worked or helped you out, please don't forget to hit the kudos button
iLogicCode Injector: goo.gl/uTT1IB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
your solution works but only if i work with assemblies. If i work with a steelmetall plate i get a mistake that the Parameter Flaeche_Zuchnitt is missing.
Thanks in advance
Regards
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You’re going to have to tell me more about how you’re using this rule.
Is this an external or internal rule that you are running from the top (Assembly) level?
Is this a rule that is being ran from the Part level?
Provide more information about how you are trying to use this, when it breaks, and when it doesn’t break.
----
If my solution worked or helped you out, please don't forget to hit the kudos button
iLogicCode Injector: goo.gl/uTT1IB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for answer megajerk,
the rule is external - it runs by "before save". If i open only a part, the rule runs ok. If i open a assembly and Change a part in the assembly - i get that message.
Below is the hole rule.
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
If oDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Dim oDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
If Not oDef.HasFlatPattern Then
oDef.Unfold()
End If
Dim oFlatPattern As FlatPattern = oDef.FlatPattern
'Dim dArea As Double = Round(oFlatPattern.TopFace.Evaluator.Area,4) 'use this one for cm^2
'Dim dArea As Double = Round(oFlatPattern.TopFace.Evaluator.Area * 0.00107639104,4) 'use this one for ft^2
'Dim dArea As Double = Round(oFlatPattern.TopFace.Evaluator.Area * 100,4) 'use this one for mm^2
Dim dArea As Double = Round(oFlatPattern.TopFace.Evaluator.Area * 0.0001,3) 'use this one for m^2
iProperties.Value("Custom", "Flaeche_Zuchnitt") = dArea
iProperties.Value("Custom", "Einheit") = "QM"
currentStyle = SheetMetal.GetActiveStyle()
If (currentStyle = ("AL 0,5")) Then
iProperties.Value("Custom", "Benennung") = "Aluminium-Blech formatlos"
iProperties.Value("Custom", "Abmessung") = "0,5mm"
iProperties.Value("Custom", "Dicke") = "t=0,5"
iProperties.Value("Custom", "Artikelnr") = "H50-000-001"
End If
currentStyle = SheetMetal.GetActiveStyle()
If (currentStyle = ("AL 1,5")) Then
iProperties.Value("Custom", "Benennung") = "Aluminium-Blech formatlos"
iProperties.Value("Custom", "Abmessung") = "1,5mm"
iProperties.Value("Custom", "Dicke") = "t=1,5"
iProperties.Value("Custom", "Artikelnr") = "H50-000-001"
End If
currentStyle = SheetMetal.GetActiveStyle()
If (currentStyle = ("AL 2,0")) Then
iProperties.Value("Custom", "Benennung") = "Aluminium-Blech formatlos"
iProperties.Value("Custom", "Abmessung") = "2,0mm"
iProperties.Value("Custom", "Dicke") = "t=2,0"
iProperties.Value("Custom", "Artikelnr") = "H50-000-002"
End If
currentStyle = SheetMetal.GetActiveStyle()
If (currentStyle = ("AL 3,0")) Then
iProperties.Value("Custom", "Benennung") = "Aluminium-Blech formatlos"
iProperties.Value("Custom", "Abmessung") = "3,0mm"
iProperties.Value("Custom", "Dicke") = "t=3,0"
iProperties.Value("Custom", "Artikelnr") = "H50-001-008"
End If
currentStyle = SheetMetal.GetActiveStyle()
If (currentStyle = ("St 1,5")) Then
iProperties.Value("Custom", "Benennung") = "Stahl-Blech, S235JR"
iProperties.Value("Custom", "Abmessung") = "2000x1000x1,5mm"
iProperties.Value("Custom", "Dicke") = "t=1,5"
iProperties.Value("Custom", "Artikelnr") = "H50-000-043"
End If
currentStyle = SheetMetal.GetActiveStyle()
If (currentStyle = ("St 2,5")) Then
iProperties.Value("Custom", "Benennung") = "Stahl-Blech, S235JR"
iProperties.Value("Custom", "Abmessung") = "2000x1000x2,5mm"
iProperties.Value("Custom", "Dicke") = "t=2,5"
iProperties.Value("Custom", "Artikelnr") = "H50-000-041"
End If
End If
Thank you for your help!
Regards Martin