Inventor General Discussion

Inventor General Discussion

Reply
New Member
Misael_Ramalho
Posts: 2
Registered: ‎06-09-2011
Message 1 of 4 (1,223 Views)
Accepted Solution

iLogic - Sheet Metal (Flat Pattern)

1223 Views, 3 Replies
04-09-2012 10:45 AM

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:

 

iLogic_1.JPG

 

iLogic_2.JPG

 

After of click "OK" appears Inventor Fatal Error and close the software.

 

Can anyone help me?

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

 

*Expert Elite*
Curtis_Waguespack
Posts: 2,934
Registered: ‎03-08-2006
Message 2 of 4 (1,222 Views)

Re: iLogic - Sheet Metal (Flat Pattern)

04-09-2012 10:51 AM in reply to: Misael_Ramalho

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

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





New Member
Misael_Ramalho
Posts: 2
Registered: ‎06-09-2011
Message 3 of 4 (1,194 Views)

Re: iLogic - Sheet Metal (Flat Pattern)

04-10-2012 05:27 AM in reply to: Curtis_Waguespack

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:

 

iLogic_1.JPG

 

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:

 

iLogic_2.JPG

 

This error occurs because the Sheet Metal file is being saved in Assembly environment?

 

You know how to solve?

 

Thanks,

 

M_Ramalho

*Expert Elite*
Curtis_Waguespack
Posts: 2,934
Registered: ‎03-08-2006
Message 4 of 4 (1,174 Views)

Re: iLogic - Sheet Metal (Flat Pattern)

04-10-2012 01:27 PM in reply to: Misael_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

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.