Need help with a strange iLogic problem.

Need help with a strange iLogic problem.

rschader
Advocate Advocate
1,023 Views
2 Replies
Message 1 of 3

Need help with a strange iLogic problem.

rschader
Advocate
Advocate

Trying to add more functionality to one of my iLogic parts. The main portion of the iLogic code and associated form have been working quite well so far. This is what I am trying to accomplish at this time:

 

The part in question (see attached ipt file with embedded rule and form) is a go/no-go pin used in check fixtures. It has an unconsumed planar sketch in which I have parameter based text that shows the hole designation and nominal hole size, which I turn on in the top view of the check fixture. I found this easier to use than adding or updating leader text, as it tends to stay where it is supposed to, and is fairly automatic.

 

Now I am trying to make this a full blown ilogic driven part so I can just place it as an ilogic component instance. One of the items I have to accomplish in the rule is to adjust the textbox vertical justification to either the top or bottom. I have written the ilogic code to do this, and it is mostly working, but I am having the following problem:

 

1. The rule first runs my ilogic form. I've added a True/False parameter for setting the text justification.

2. The actual jsutification does not update the first time I run the rule. But if I run the rule again and just dismiss the form, the justification does change. (so I basically have to run the rule twice for it to work)

3. The really weird thing is, if I just invoke the form and switch the justification, it updates right away, without running the rule that changes it. But if I comment out the relevant code in the rule, just running the form has no effect? It's like the form is invoking the rule?

 

Here is the text from the rule:

iLogicForm.Show("GNG RND PIN", FormMode.Modal)
'start of newest text justification code: 'get the reference to the text box Dim oPartDef As PartComponentDefinition Dim oPartDoc As PartDocument oPartDoc = ThisDoc.Document oPartDef = oPartDoc.ComponentDefinition Dim oSketches As PlanarSketches oSketches = oPartDef.Sketches Dim oSketch As PlanarSketch oSketch = oSketches.Item("DRAWING_LABEL") Dim oTextBox As TextBox oTextBox = oSketch.TextBoxes.Item(1)
If TEXT_ABOVE = True Then oTextBox.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextUpper Else oTextBox.VerticalJustification = VerticalTextAlignmentEnum.kAlignTextLower End If
'end of newest code for text justification.
InventorVb.DocumentUpdate() Dim value1 As Double = Parameter("GO") Dim value2 As Double = Parameter("NOGO") InventorVb.DocumentUpdate() iProperties.Value("Project", "Part Number") = "GNG RND PIN, HOLE " & CStr(Parameter("HOLE_DESIGNATION")) & ", " & value1.ToString("#0.000") & "-" & value2.ToString("#0.000")

 

I am using Inventor Pro 2015 SP2 Update 1 (thought I had Update 2, but looks like I only downloaded it, might have to try that)

 

Can someone check this out and tell me how to fix it so the justification updates the first time the rule is run? I appreicate it! Thanks!

0 Likes
Accepted solutions (1)
1,024 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi rschader,

 

If I understand the issue, I think what you want to do is change the way you call the parameter as shown:

 

 

Autodesk Inventor iLogic True False Parameter Form Update 00.PNG

 

Autodesk Inventor iLogic True False Parameter Form Update 01.PNG

 

 

Of course you're going to want to now "WHY" this makes a difference, and I'm going to muddle the explination, but basically when you have an internal rule and you see the Parameter in blue it will update automatically (assuming the rule is set to run automatically which is the default behavior). In your case setting the parameter not to run automatically gives you better control of when it's updating.

 

I think what might have been happening is the parameter was setting as the form displayed, so the form and parameter where intially out of sync, although I didn't really test that theory.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 3 of 3

rschader
Advocate
Advocate

Man do I feel dumb! I have ran into that exact problem before. Got to remember that I can't just double click on a parameter name in the upper browser to insert the parameter name! Thanks for refreshing my memory, Iguess I haven't been doing alot of ilogic code writing lately!

0 Likes