iLogic - exporting parameter for multiple parts

iLogic - exporting parameter for multiple parts

Rafal_Napierala
Participant Participant
1,372 Views
3 Replies
Message 1 of 4

iLogic - exporting parameter for multiple parts

Rafal_Napierala
Participant
Participant

Hi,

 

What I'm tring to do is to write simple program for exporting given parameter for multiple files.

 

Fist thing is that I use iLogic Part Batch Tool 2015.v.1.4.ipt that I found on the forum. 

 

Next I'm adding new rule that should find the parameter "PL" (pipe length) and make it exported. It looks like this:

 

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveEditDocument

Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

' Get a reference to the parameter controlling the thickness.
Dim oParam As Parameter
oParam = oCompDef.PL
oParam.ExposedAsProperty = True 
'
oParam.CustomPropertyFormat.Precision = CustomPropertyPrecisionEnum.kThreeDecimalPlacesPrecision 
oParam.CustomPropertyFormat.ShowTrailingZeros = True 
oParam.CustomPropertyFormat.ShowUnitsString = True 
oParam.CustomPropertyFormat.Units = "mm" 

Unfortunately this is not working, it gives me error that it could not found public member PL

 

Error in rule: Exporting Parameter_new ***, in document: iLogic Part Batch Tool 2015.v.1.4.ipt

Could not found public member PL for type PartComponentDefinition.

 

Detailed info looks like this:

 

System.MissingMemberException: could not found member PL for type PartComponentDefinition.
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 ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

I need to add that I'm completely new to VBA and iLogic. I did some digging and experimenting but errors getting even worse so I need to ask You for help.

 

Thank you

Rafal 

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

lmc.engineering
Advocate
Advocate
Accepted solution

Hi @Rafal_Napierala 

 

You were almost there, good effort.

 

change this

oParam = oCompDef.PL

to this

oParam = oCompDef.Parameters.Item("PL")

If you want to learn more I might suggest you have a look in to object orientated programming to help improve your understanding of what is going on here. 

Message 3 of 4

Rafal_Napierala
Participant
Participant

Thank you very much lmc.engineering!

 

I knew that it must be something simple that I'm just not aware of. I'm just starting with VBA. Do you have any advice for me about starting with object programming? Good lecture or course? 

 

Thank you!

Rafal

0 Likes
Message 4 of 4

lmc.engineering
Advocate
Advocate
Accepted solution

No problem, happy to help.

 

You can learn a lot from these forums, but you need the basics to know whats going on. Try here for vb.net, which I would recommend over VBA, even though they are similar. iLogic is essentially vb.net.

 

Whilst there is a lot more to it that the following, it's a good place to start: In object programming its good to know this: Namespace>Class>methods/properties/fields. A namespace is a group of classes. A class is a group of methods, properties, and fields. A method is a subroutine or function. A field is a data member (variables, arrays, strings etc..). A property is half way between a method and a field, with the ability to get and set values.

 

If you look at the Inventor API  object model here, you can see the structure of object programming. It's a bit like tree roots, and you follow down the classes until you hit the properties/fields/methods you require. 'Inventor' is the namespace here, from there you have 'Application'. You can then follow down any of the routes to get what you need.

i'e, getting the parameters as in your example: Application.Documents.PartDocument.PartComponentDefinition.Parameters.... 

 

Someone else may be able to explain it better than myself as I am self taught and probably have a few holes in my knowledge, but hopefully you get the rough idea.

 

 

0 Likes