Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic - Sheet Metal (Flat Pattern)

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Misael_Ramalho
4106 Views, 3 Replies

iLogic - Sheet Metal (Flat Pattern)

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?

3 REPLIES 3
Message 2 of 4

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

 

Message 3 of 4

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

Message 4 of 4

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report