Hello to all,
I created the iLogic Rule below for Sheet Metal template:
InventorVb.DocumentUpdate()
mass = iProperties.Mass
If (mass > 0) then
Parameter.Value("LARGURA") = SheetMetal.FlatExtentsWidth
Parameter.Value("COMPRIMENTO") = SheetMetal.FlatExtentsLength
Parameter.Value("AREA") = SheetMetal.FlatExtentsArea
Else
Parameter.Value("LARGURA") = 0
Parameter.Value("COMPRIMENTO") = 0
Parameter.Value("AREA") = 0
End If
iLogicVb.UpdateWhenDone = True
When creating a new individual files, everything works perfectly. But when creating a new Sheet Metal file in Assembly environment, the following message appears:
After of click "OK" appears Inventor Fatal Error and close the software.
Can anyone help me?
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi M_Ramalho,
I think the error is occuring because the rule is looking for parameters that do not exist until your sheet metal part has a flat pattern present. You can add a conditional statement to check for an existing flatpattern before running the rule.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
a quick example:
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
'ensure this part has a flat pattern
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oDoc.ComponentDefinition
If oSMDef.FlatPattern Is Nothing Then
'tell the user there is no flat pattern
MessageBox.Show("This file has no flat pattern", "iLogic")
Else
'tell the user there is a flat pattern
MessageBox.Show("This file does have a flat pattern", "iLogic")
end
Hi Curtis_Waguespack
I thank you for your cooperation... but still I'm with problems.
I'm using your code sample for you sent me...
When create a new Sheet Metal file in Assembly environment, through the Create Component command, when click in save two files will saved, the assembly and the Sheet Metal file that was created in Assembly environment, as shown in picture below:
When I click OK appears the error mesage:
iLogic Rule Error in rule: RMDIMENSION, in document: AAA.ipt
Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
As shown in picture below:
This error occurs because the Sheet Metal file is being saved in Assembly environment?
You know how to solve?
Thanks,
M_Ramalho
Hi M_Ramalho,
I think your original issue was the lack of a flat pattern definition, but I introduced another issue with my example. In that example I used:
oDoc = ThisApplication.ActiveDocument
I should have used:
oDoc = ThisDoc.Document
I also noticed that when I copy and pasted the example before I missed the ending IF. Here is a correct example. I apologize for any confusion I caused.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim oDoc As PartDocument oDoc = ThisDoc.Document 'ensure this part has a flat pattern Dim oSMDef As SheetMetalComponentDefinition oSMDef = oDoc.ComponentDefinition If oSMDef.FlatPattern Is Nothing Then 'tell the user there is no flat pattern MessageBox.Show("This file has no flat pattern", "iLogic") Else 'tell the user there is a flat pattern MessageBox.Show("This file does have a flat pattern", "iLogic") end if