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: 

Driving iLogic Rule into a Part (Please Help)

10 REPLIES 10
Reply
Message 1 of 11
jddickson
1156 Views, 10 Replies

Driving iLogic Rule into a Part (Please Help)

Hello everyone,

 

It’s kind of hard to explain what I want to do. I would like to make an External Rule that would make an iLogic Internal Rule (with the same code every time).  I guess what I really need is a way to drive an Ilogic rule into every part that does not have the rule in the part already.

 

I know what you’re thinking and just using the External Rule doesn’t work for what I want to do.  I need it to be an iLogic Internal Rule.

 

I would appreciate any help or advice that you might be able to give.

 

Thanks

JD

10 REPLIES 10
Message 2 of 11
tuliobarata
in reply to: jddickson

Which kind of code are you using that can't be from an external rule ?

 

Sometime ago I was trying to do the same... I didn't find how to make it, but I found some tips that made it to work a lot better with an external rule.

 

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/create-rule-by-one-e-rule-OR-fix-exter...

 

 

Túlio Barata

IV 2013
Message 3 of 11
jddickson
in reply to: tuliobarata

I have a form that that drives parameters and custom properties (external rule) into a part and it works great. The parameters and custom properties make it so the form can find everything it needs. The rule I need to add is the rule that fills in all the data depending on what is selected. I have it so all the data is filled in and displayed when you hit the “Update Item Information” Button. This way you can see what information you are driving into the part. It updates and works perfectly if it’s an internal rule (no triggers attached to the rule). For some reason it will not update when I try to run it as an external rule.

 

Hope that made some kind of sense.

 

Info.jpg

Message 4 of 11
mrattray
in reply to: jddickson

Search around for an application created by one of our forum members, megajerk, called "iLogic Rule Injector"(I think?).
This will add rules to a large batch of files in one go.

 

Edit: It may be "Code Injector". Not sure now...

Mike (not Matt) Rattray

Message 5 of 11
tuliobarata
in reply to: mrattray

I read somewhere about this code injector, seems to be a very good tool!

 

And jddickson, I just dont understand why fill the parameter with the external rule doesn't work with tou code. Could you paste the iLogic Code here ? I ask that, because what I did in my code are exactly the same, I have some notes in my drawing that are filled directly by the external rule.

 

Túlio Barata

IV 2013
Message 6 of 11
mrattray
in reply to: tuliobarata

I'm curious about that, too. I'm not aware of anything you can do in an internal rule that you can't do in an external.
Mike (not Matt) Rattray

Message 7 of 11
jddickson
in reply to: tuliobarata

First I want to let you know that I’m new to writing any kind of code so don’t make too much fun of it. I taught myself so there might be better ways of doing this.

 

I’m going to try to explain how I set everything up so the code might make some kind of sense. I have two external rules that drive parameters and custom properties into the part. This part of the code works great. I just click the button and it runs the external rule and drives in all the information to the part.

 

Now that all the parameters and custom properties are in the part I can run the rule below (it’s just a snippet of the code but I hope you get what its doing).

 

When I have the code as an internal rule and click the “Update Item Information” button to run the rule it drives the correct information into the custom properties instantly. As you can see by the code the Description and Extended Item Description have to put in the same way every time. All the information gets exported into a different program.


I don’t know why but when I try to run it as an external rule from the form it doesn’t do anything at all. I’ve tried to put automatic updates in the code with no change. If I go to the external rule tab and run the rule from there it still doesn’t work.

 

I would appreciate any help or advice that you might be able to give.

 

'Making Item ID File Name Or Override Info     If PK_Item_ID = "Same" Then
        iProperties.Value("Custom", "Item ID") = iProperties.Value("Project", "Part Number")
    End If

    If PK_Item_ID = "Override" Then
        iProperties.Value("Custom", "Item ID") = iProperties.Value("Custom", "Item ID Override")
    End If
    

'Making Item Material Description Or Override Info     If PK_Material_Spec = "Same" Then
        iProperties.Value("Custom", "Material Spec") = iProperties.Value("Custom", "Specification")
    End If
    
        If PK_Material_Spec = "Override" Then
        iProperties.Value("Custom", "Material Spec") = iProperties.Value("Custom", "Material Spec Override")
    End If
    
    
    
'Making Item Type Description    iProperties.Value("Custom", "Item Type") = PK_Item_Type



'Making Extended Item Description Location Description    iProperties.Value("Custom", "Extended Item Description Location") = PK_Extended_Item_Description
    
    

'Making Ship Loose Description        iProperties.Value("Custom", "Ship Loose") = PK_Ship_Loose
    
    
    


'Making Item Description    Description = PK_Description
    Additional = iProperties.Value("Custom", "Extended Item Description Override (Additional)")
    Material = iProperties.Value("Custom", "Material Spec")
    
    
    'Plate Infomation        If Description = "Plate" Then
              'Rounding Increment                inc = .0625 ' rounding increment ( .125, .25, .5, etc)
              'Rounding Thickness, Width, And Length                FINISHED_THICK = Format(Round(Round(Round(Thickness,4) / inc) * inc,3),".000")
                FINISHED_WIDTH = Format(Round(Round(Round(Width,4) / inc) * inc,3),".000")
                FINISHED_LENGTH = Format(Round(Round(Round(Length,4) / inc) * inc,3),".000")
                
            'Assigning Item Description And Extended Item Description                iProperties.Value("Custom", "Item Description") = "=PLATE "& FINISHED_THICK &" X "& FINISHED_WIDTH &" X "& FINISHED_LENGTH &""
                iProperties.Value("Custom", "Extended Item Description") = "=PLATE "& FINISHED_THICK &" THICK X "& FINISHED_WIDTH &" WIDE X "& FINISHED_LENGTH &" LG. Material: "& Material &". "& Additional &"" 
        End If
    
    
    'Pipe Infomation        If Description = "Pipe" Then
              'Rounding Increment                inc = .0625 ' rounding increment ( .125, .25, .5, etc)
              'Rounding Thickness, Width, And Length                FINISHED_LENGTH = Format(Round(Round(Round(PipeLength,4) / inc) * inc,3),".000")
                
            'Assigning Item Description And Extended Item Description                iProperties.Value("Custom", "Item Description") = "=PIPE <PipeSize> X <PipeTHK> X "& FINISHED_LENGTH &""
                iProperties.Value("Custom", "Extended Item Description") = "=PIPE <PipeSize> NPS X <PipeTHK> WALL X "& FINISHED_LENGTH &" LG. Material: "& Material &". "& Additional &"" 
        End If


Message 8 of 11
jddickson
in reply to: mrattray

Sorry it got jumbled when I pasted the code. This might be easier to read if you paste it in iLogic.

'Making Item ID File Name Or Override Info     

If PK_Item_ID = "Same" Then iProperties.Value("Custom", "Item ID") = iProperties.Value("Project", "Part Number") End If If PK_Item_ID = "Override" Then iProperties.Value("Custom", "Item ID") = iProperties.Value("Custom", "Item ID Override") End If 'Making Item Material Description Or Override Info

If PK_Material_Spec = "Same" Then iProperties.Value("Custom", "Material Spec") = iProperties.Value("Custom", "Specification") End If

If PK_Material_Spec = "Override" Then iProperties.Value("Custom", "Material Spec") = iProperties.Value("Custom", "Material Spec Override") End If 'Making Item Type Description

iProperties.Value("Custom", "Item Type") = PK_Item_Type 'Making Extended Item Description Location Description

iProperties.Value("Custom", "Extended Item Description Location") = PK_Extended_Item_Description 'Making Ship Loose Description

iProperties.Value("Custom", "Ship Loose") = PK_Ship_Loose 'Making Item Description

Description = PK_Description Additional = iProperties.Value("Custom", "Extended Item Description Override (Additional)") Material = iProperties.Value("Custom", "Material Spec") 'Plate Infomation

If Description = "Plate" Then 'Rounding Increment

inc = .0625 ' rounding increment ( .125, .25, .5, etc) 'Rounding Thickness, Width, And Length

FINISHED_THICK = Format(Round(Round(Round(Thickness,4) / inc) * inc,3),".000") FINISHED_WIDTH = Format(Round(Round(Round(Width,4) / inc) * inc,3),".000") FINISHED_LENGTH = Format(Round(Round(Round(Length,4) / inc) * inc,3),".000") 'Assigning Item Description And Extended Item Description

iProperties.Value("Custom", "Item Description") = "=PLATE "& FINISHED_THICK &" X "& FINISHED_WIDTH &" X "& FINISHED_LENGTH &"" iProperties.Value("Custom", "Extended Item Description") = "=PLATE "& FINISHED_THICK &" THICK X "& FINISHED_WIDTH &" WIDE X "& FINISHED_LENGTH &" LG. Material: "& Material &". "& Additional &"" End If 'Pipe Infomation

If Description = "Pipe" Then 'Rounding Increment

inc = .0625 ' rounding increment ( .125, .25, .5, etc) 'Rounding Thickness, Width, And Length

FINISHED_LENGTH = Format(Round(Round(Round(PipeLength,4) / inc) * inc,3),".000") 'Assigning Item Description And Extended Item Description

iProperties.Value("Custom", "Item Description") = "=PIPE <PipeSize> X <PipeTHK> X "& FINISHED_LENGTH &"" iProperties.Value("Custom", "Extended Item Description") = "=PIPE <PipeSize> NPS X <PipeTHK> WALL X "& FINISHED_LENGTH &" LG. Material: "& Material &". "& Additional &"" End If

Message 9 of 11
tuliobarata
in reply to: jddickson

Here i had to change how I call all my parameters when I use external rules, try to change onlye its name for Parameter("parameter_name")= True

I dont know if just that can solve your problem, but try it and see if it works.

 

Just like:

 

If Parameter("PK_Item_ID") = "Same" Then
        iProperties.Value("Custom", "Item ID") = iProperties.Value("Project", "Part Number")
    End If

but for all parameters (not for temp variables neither for iProperties, just for parameters)

 

Túlio Barata

IV 2013
Message 10 of 11

+1 for Megajerk's Code Injector. It saved me a TON of time without having to use an external rule.

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
Message 11 of 11
jddickson
in reply to: tuliobarata

Túlio Barata,

 

That didn’t do exactly what I wanted but it did change something so that gives me hope. That means I can use the external rule to drive this form. I just need to get a little bit smarter on writing code.  I will play around with it tomorrow and see what kind of damage a can cause.

 

I just figured that the internal rule work that way so should the external rule.  

 

Thank you everyone for you pointing in the right direction.

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

Post to forums  

Autodesk Design & Make Report