Problem accessing Part files's iLogic rule from an iLogic rule in Assembly file.

Problem accessing Part files's iLogic rule from an iLogic rule in Assembly file.

Anonymous
Not applicable
896 Views
6 Replies
Message 1 of 7

Problem accessing Part files's iLogic rule from an iLogic rule in Assembly file.

Anonymous
Not applicable

Dear all,

I have an Assembly file which consists of a part file containing 2 rules. When I try to access a rule from Assembly files using,

iLogicVB.RunRule("PartFile_Name:1","Rule_1")

Suprisingly this error shows up.

 

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.PartFeatures'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DA33F1A5-7C3F-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

The Rule_1 in part file changes the sweep feature. I would like to change the paramteres used in the sweep feature from assembly files iLogic rule.

 

can any one please help me!

 

Thanks a lot in advance.

Regards,

Yatish.

 

0 Likes
Accepted solutions (1)
897 Views
6 Replies
Replies (6)
Message 2 of 7

FINET_Laurent
Advisor
Advisor

Morning,

 

I have a similar issue not long ago..

 

Here is the correct way :

 

iLogicVb.Automation.RunRule("Document", "RuleName")

 

You'll have to declare the document tho, something like this maybe :

 

Dim oDoc As Document

For Each oDoc In ThisApplication.Documents.VisibleDocuments
	If oDoc.DisplayName = "Vertical baffle 1.iam" Then
		iLogicVb.Automation.RunRule(oDoc, "RuleName")
	End If
Next

 

Regards,


FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hallo @FINET_Laurent  Thank you for the solution.

The problem still arises for one of the two rules.

Rule_1: 

 

MessageBox.Show("Test_Message","Title")

 

Rule_2:

'Do Something
Dim
oSweep As SweepFeature = oCompDef.Features.SweepFeatures.AddUsingPath(oProfile, oPath, kJoinOperation
'Do Something

I've used this code in a rule in Assembly file:

Dim oDoc As Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
	If oDoc.DisplayName = "Part1.ipt" Then
		iLogicVb.Automation.RunRule(oDoc, "Rule_1")
		iLogicVb.Automation.RunRule(oDoc, "Rule_2")
	End If
Next

 The Error still shows up at the Rule_2.

 

Regards,

Yatish.

0 Likes
Message 4 of 7

FINET_Laurent
Advisor
Advisor

This may be about the rule 2 itself.

Can you post the full code for that rule ? (If not confidential)

 

Regards,


FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 5 of 7

Anonymous
Not applicable

Hey @FINET_Laurent  Here is the code for rule#2. I have changed the names for some reasons.

 

'Rule#2

Dim
oFeatures As PartFeatures oFeatures = ThisApplication.ActiveDocument.ComponentDefinition.Features
If Feature.IsActive("Sweep") = True Then oFeatures("Sweep").Delete End If Dim oPartDoc As PartDocument = ThisDoc.Document Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition ' Create a profile. Dim oSketch1 As Sketch = oCompDef.Sketches.Item("Sketch_2") Dim oProfile As Profile = oSketch1.Profiles.AddForSolid ' Create a path. Dim oSketch2 As Sketch = oCompDef.Sketches.Item("Sketch_1") Dim oPath As Path = oCompDef.Features.CreatePath(oSketch2.SketchLines(1)) ' Create the sweep feature. Dim oSweep As SweepFeature = oCompDef.Features.SweepFeatures.AddUsingPath(oProfile, oPath, kJoinOperation) oSweep.Name = "Sweep"

 Regards,

Yatish.

0 Likes
Message 6 of 7

FINET_Laurent
Advisor
Advisor
Accepted solution

I think there is a mistake aroud this :

oFeatures = ThisApplication.ActiveDocument.ComponentDefinition.Features

I think The active document is the assembly document you are  lauching the rules from.

Maybe you need to activate the part document first (from the assembly) :

 

Dim oDoc As Document
For Each oDoc In ThisApplication.Documents.VisibleDocuments
	If oDoc.DisplayName = "part2.ipt" Then
		
		oDoc.Activate
		
		iLogicVb.Automation.RunRule(oDoc, "Test")
		'iLogicVb.Automation.RunRule(oDoc, "Rule_2")
		
	End If
Next

 The oDoc.Activate set the document to the active document.

 

Regards,

 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 7 of 7

Anonymous
Not applicable

@FINET_Laurent  Hey, Thank you so much. Yes. The oDoc.Activate is the fix.