Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Writing External Rule 1

Status
Not open for further replies.

cjjatpuresilica

Civil/Environmental
Oct 20, 2010
65
0
0
GB
Dear EngAddict,

I managed to get the model to loft OK in the end and it updates OK when I change the MultiValue selection under the parameters in each of the files. So thank you so much.

My next task is to apply an external rule which will be activated upon opening say the top level file and the subsequent subordinate files, that will:

a: automatically load each of the lower assembly files.

b. Set the MultiValue selection in the respective user-parameters in each of the respective files.

I have loaded Microsoft Visual Basic 2010 to create the external file but wondered if you could possibly help me with the code for the Inventor Rule and if possible the *.vb file.

This is the existing header code within my Inventor Rule and I want the external rule to determine which of the model types is to be used.

MultiValue.SetList("ModelType", "OuterNormal", "OuterIntense", "InnerIntense", "InnerNormal",)

I think the extra code should look something like this but I am only guessing:

localTrigger = iTrigger0
AddReference "ModelType.DLL"


localTrigger = iTrigger0

Using dlg As New ModelType.Dialog1

dlg.Parameter = Parameter
dlg.MultiValue = MultiValue
dlg.type_list = MultiValue.List("ModelType")
dlg.type = Parameter("ModelType")

dlg.ShowDialog()

End Using
End If

At the moment I get the following error message:

Error on Line 0 : could not find library 'ModelType.DLL'
Error on Line 0 : compiler initialization failed unexpectedly: 0x80070002

Your continued help would be greatly appreciated.

Finally I must thank you for your meaningful help. I may be a mere novice but nevertheless in the past week with your help I have made more progress than I have in the previous three/four months

So thank you once again.

cjj
 
Replies continue below

Recommended for you

I am not too sure what you mean by "automatically load each of the lower assembly files", this is done when opening the assembly.

Do you have an external rule called ModelType?

I am not 100% clear on what you want to do but I think you can do it easier with an iLogic rule in your top assembly file.

I will use an example, you have a multivalue list called:
Code:
MultiValue.SetList("ModelType", "OuterNormal", "OuterIntense", "InnerIntense", "InnerNormal",)
In my example I have an equivalent list, corresponding to plate size in my assembly:
Code:
MultiValue.SetList("ModelType", "Large", "Largest", "Medium", "Small", "Smallest")

Now all I need to do is add an input list for my multivalue and a select case that can change the parameters in all the part files. Now add some code to update the assembly.
Code:
ModelType = InputListBox("Enter Size", MultiValue.List("ModelType"), "Smallest", Title := "Input", ListName := "Size")

Select Case ModelType
 Case "Smallest"
 Parameter("Plate:1", "Height") = 60
  Case "Small"
 Parameter("Plate:1", "Height") = 70
  Case "Medium"
 Parameter("Plate:1", "Height") = 80
  Case "Large"
 Parameter("Plate:1", "Height") = 90
  Case "Largest"
 Parameter("Plate:1", "Height") = 100
 End Select
 
 InventorVb.DocumentUpdate()

Now all that is left is to select Event Triggers and add your new rule to the After Open Document trigger. See attached sample files.
 
 http://files.engineering.com/getfile.aspx?folder=4d675124-33dc-48aa-a88a-51e0edfc011c&file=Plate_Assay.zip
Dear EngAddict,

Thank you once again for your kind explicit explanation and sample model.

I have played around with your model for about a couple of hours, adding additional components and seem to have got the hang of it.

No doubt I will get confused as I build my assembly but once again without your clear and precise explanation and example I would be floundering in the dark.

So a big thank you.

cjj
 
Dear EngAddict,

Just a quick update to say that I am staggered that I am able to control all the various files/models from the one top level rule.

So to reiterate - thank you so much.

cjj

I have only really just started to build the assembly but this is what my code looks like thus far:


ModelType = InputListBox("Enter Size", MultiValue.List("ModelType"), " OuterNormal ", Title := "Input", ListName := "Size")

Select Case ModelType

Case "OuterNormal"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 581.2864022444 mm
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0 mm
Parameter("Full Pyramid:1", "AdjustedHeight") = 581.2864022444 mm
Parameter("Full Pyramid:1", "RipThickness") = 3.0 mm
Parameter("Solid Cap:1", "AdjustedHeight") = 581.2864022444 mm
Parameter("Solid Cap:1", "RipThickness") = 3.0 mm

Case "OuterIntense "
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 581.2864022444
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 581.2864022444
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 581.2864022444
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerNormal0"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 160.968
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 160.968
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 160.968
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerNormal2"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 160.968
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 160.968
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 160.968
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerNormal4"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 160.968
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 160.968
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 160.968
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerIntense0"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 91.43118302
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 91.43118302
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 91.43118302
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerIntense1"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 91.43118302
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 91.43118302
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 91.43118302
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerIntense2"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 91.43118302
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 91.43118302
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 91.43118302
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerIntense3"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 91.43118302
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 91.43118302
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 91.43118302
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerIntense4"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 91.43118302
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 91.43118302
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 91.43118302
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerIntense4"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 91.43118302
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 91.43118302
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 91.43118302
Parameter("Solid Cap:1", "RipThickness") = 3.0

Case "InnerIntense5"
Parameter("Pyramid without Summit:1", "AdjustedHeight") = 91.43118302
Parameter("Pyramid without Summit:1", "RipThickness") = 3.0
Parameter("Full Pyramid:1", "AdjustedHeight") = 91.43118302
Parameter("Full Pyramid:1", "RipThickness") = 3.0
Parameter("Solid Cap:1", "AdjustedHeight") = 91.43118302
Parameter("Solid Cap:1", "RipThickness") = 3.0

End Select

InventorVb.DocumentUpdate()
 
Looks like you got it working ok. It is always easier to demonstrate with part files.

Just one other thing you can do, is instead of using the input list you can make the multivalue a key parameter. If you then place it in a new assembly with the 'Place iLogic Component' option it will prompt you to select any keyed parameters on placement. This will create a copy of the master iLogic assembly and all its parts. If you cancel the command and place it again you will get a new copy of your assembly.

This is similar to the functionality of an iAssembly if you made all your part files into iParts. I would use an iAssembly though if this is what you are after, provided it will do everything you need. If you have to start mixing a lot of code with iAssemblies then usually it is cleaner to just do everything with iLogic.
 
Dear EngAddict,

Thank you once again for your informative reply.

I am slightly bewildered by your suggestion and wonder if once again you have an example you could kindly let me have sight of; or failing that, the url of a tutorial on the process.

Thank you once again I am truly grateful.

cjj
 
Status
Not open for further replies.
Back
Top