Hi
I have created a ilogic rule that should set the size and the cut length of my parts. Most of the time the rule behave as I want it to. But sometime it gives me a error. See attached picture. It would be great if anyone could tell me what is wrong with the rule.. By the way, I have included this rule in my custom content center parts (beam's etc). The rule is:
'Turn off workfeatures
ThisDoc.Document.ObjectVisibility.AllWorkFeatures = False
'check if the part has any geometry
If Measure.ExtentsLength="0" Then
'sets values to 0 if no geometry exists
iProperties.Value("Custom", "G_L")="0"
iProperties.Value("Custom", "Size")="0,0,0"
'Turn on workfeatures
ThisDoc.Document.ObjectVisibility.AllWorkFeatures = True
Return
End If
'Sets size of part
iProperties.Value("Custom", "Size")=Round(Measure.ExtentsLength, 1) & "mmX" & Round(Measure.ExtentsWidth, 1) & "mmX" & Round(Measure.ExtentsHeight, 1) &"mm"
'Sets a value in the properties field G_L (cutlenght) based on what value that is written in the filed "kpl" (x,y or z)
If iProperties.Value("Custom", "kpl")="Z" Then
iProperties.Value("Custom", "G_L")=Round(Measure.ExtentsHeight, 0) & "mm"
Else If iProperties.Value("Custom", "kpl")="z" Then
iProperties.Value("Custom", "G_L")=Round(Measure.ExtentsHeight, 0) & "mm"
Else If iProperties.Value("Custom", "kpl")="X" Then
iProperties.Value("Custom", "G_L")=Round(Measure.ExtentsLength, 0) & "mm"
Else If iProperties.Value("Custom", "kpl")="x" Then
iProperties.Value("Custom", "G_L")=Round(Measure.ExtentsLength, 0) & "mm"
Else If iProperties.Value("Custom", "kpl")="Y" Then
iProperties.Value("Custom", "G_L")=Round(Measure.ExtentsWidth, 0) & "mm"
Else If iProperties.Value("Custom", "kpl")="y" Then
iProperties.Value("Custom", "G_L")=Round(Measure.ExtentsWidth, 0) & "mm"
Else iProperties.Value("Custom", "G_L")=iProperties.Value("Custom", "kpl")
End If
'Turn on workfeatures
ThisDoc.Document.ObjectVisibility.AllWorkFeatures = True
Solved! Go to Solution.
Solved by MjDeck. Go to Solution.
How do you know there will be a Custom Variable "kpl". You don't give it an initial value.
Have you declared this variable in your Template file?
Take a look at the following Blog entry, it may be related to your problem.
Length parameter of Frame generator beams.
Jon
Asle,
What is the error message? If the error has a More Info tab, please click on that. Then copy and paste the text and post it here as text. That is better than posting a screenshot.
Hi
The error message is:
Error in rule: Sette_yttermål, in document: Sette_yttermål.iLogicVb
Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
And under More Info is:
System.Runtime.InteropServices.COMException (0x80020003): Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Thanks for checking in to this 🙂
I'm not sure what's causing the problem. Here's a few more questions:
How are you running the external rule? Do you run it manually, or automatically on an event?
Do you ever run it in a drawing document? That will produce this error.
Can you try to comment out all the lines that have this text:
ThisDoc.Document.ObjectVisibility.AllWorkFeatures
and see if that makes the error message go away?
Does the error message seem to happen at random? How often does it happen?
Does it happen only in certain parts?
Do you have only one solid body in the part? If so, I can send you code that gets the extents of the solid body only. Then you won't need the ThisDoc.Document.ObjectVisibility.AllWorkFeatures statement.
(I can also provide code to work on more than one solid body, but it would be more complex.)
Please try the attached rule. It is a modified version of your original rule, with code added to replace the Measure.Extents functions.
A update on this issue. The problem seems to occur when I (from a assembly) edit a part, return (without saving) and hit save. If the part is in a subassembly and I returns to the top level assembly before saving the odds for the error to occur are rising..
Can you post yoir model (all assemblies and parts)? That would probably help me to figure out what is causing the problem.
Hi
Attached is a zip folder that contains one part and two assemblies. It also contain the rules that is trigged by the part. This is external rules. The "main" rule is "IPT_KJORE_FOR_LAGRE.iLogicVb". This rule is set to run "before save" in all new ipt files. This rule is starting the other rules. (I'm from Norway so you must excuse me for the Norwegian language in the rules 🙂 )
The top level assembly is "Assembly4.iam".
A video where I get the error is to be found on youtube: http://www.youtube.com/watch?v=7raaXpXfcPQ
Asle Svastuen
Asle,
I wasn't able to reproduce the problem, but I have an idea that might fix it. Please try this modified version of your Sette_kapplengde_G_L.iLogicVb external rule. The change I made was to explicitly use a PartDocument instead of a Document.
If this doesn't fix the problem, can you post a few more files? You didn't include IAM_KJORE_FOR_LAGRE.iLogicVb. Also, are you creating new parts from templates that contain rules? If so, please post your templates.
Although your signature says Inventor 2011, I see that you are using 2012. Do you have SP1 installed?
I thought I was strange that you was not able to reproduce the error, then I open the assembly an found out that neither was I. Then after some testing it seem that I had to create the part place it in the assembly and then place the assembly in a new assembly without exit Inventor. Then (out of nowhere) I got a new error. This error is similar to the old but refer to a new rule. This rule is similar to the rule that sets the size on a part, but it is used to set the size of a assembly. I'm starting to give up.. Attached is my template ipt, iam and all rules.
And my signature is updated 🙂
Can't find what you're looking for? Ask the community or share your knowledge.