understanding the API and implement it in ilogic

understanding the API and implement it in ilogic

GeertvanderHeide
Advocate Advocate
524 Views
4 Replies
Message 1 of 5

understanding the API and implement it in ilogic

GeertvanderHeide
Advocate
Advocate

Hi all,  

 

in the past years i have become very familiar with the ilogic method of coding. 

now i want to try a few new things in my code that i have never done before. 

for example. to make a constraint a want to click 2 parts of an assembly. these parts have predefined objects i use for constraining (origin plane and a workplane)

 

now for the constraint feature i need an ComponentArgument object. i have found some functions but they don't seem to be filling correctly. 

i think this is because my understanding of vb.net is far too limited. 

 

in the help page i have found the ComponentArgument class and i can se there are : constructors, properties, methods and type converions. 

 

this looks like a lot of information, but for now i can't do anything with this. i don't know what methods are and how to implement this in my ilogic code. 

 

Is there someone that has a guide/ tutorial or just an explanation how to navigate these different branches within the class i seem to be needing? 

 

kind regards, 

 

Geert

0 Likes
Accepted solutions (1)
525 Views
4 Replies
Replies (4)
Message 2 of 5

A.Acheson
Mentor
Mentor

The best way I have found to learn the inventor API is to try out a sample of code I know someone had functioning and work backwards, learn what your objects and methods do what and when and adjust to my custom needs. The samples in the help file work great for this. It is a shame they are in VBA and not also in VB.NET. The difference are slight but are enough to stop a new user progressing. The main thing to know is remove the word “Set” and ensure you start any sub routine with sub main as the driving sub routine.

 

Here is a sample to constrain two parts together in an assembly. The other way to learn is to try and find the main method of an object you would like to use and work backwards to fill in what the and methods are required to have it function.

Here is the method for assemblyconstraints

 

Here is the method for making a user selection of an object. The object filter will need to be changed to the object type .  

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 5

GeertvanderHeide
Advocate
Advocate

i think i understand why i am so confused. 

when adding a constraint inside ilogic it shows a lot more inputs:

GeertvanderHeide_0-1663826263906.png

so here it shows the code needs a componentargument and an entityname as string. 

That looks to me like something completely different then 2 input planes and an offset. 

 

i did got it to work with the following paramters:

componentargument = occurence.name as string

when component argument is current assembly fill in an empty string --> ""

then entity name is just the name of the plane in my case.

 

but the constraining between a plane in a subassembly and a plane in the current assembly is not something i could find anywhere..

 

 

0 Likes
Message 4 of 5

cidhelp
Advocate
Advocate
Accepted solution

Hallo @GeertvanderHeide ,

 

to constrain a subcomponent you have to use an array of strings for the ComponentArgument.

I have created a top level assembly Sub_00.iam including a first level subassembly component Sub_01:1.

cidhelp_0-1663856226077.png

 

 

The subassembly includes a part component Part_01:1 with an assigned entity name FrontFace

cidhelp_1-1663856386774.png

Now I can add a constraint in the top level assembly using iLogic:

 

Dim oComp1 As ComponentArgument = "" 'empty string for root component

Dim oComp2 As ComponentArgument = "Sub_01:1" 'string for first level component

Dim oComp3 As ComponentArgument = {"Sub_01:1" , "Part_01:1"} 'array of strings for subcomponent

 

Constraints.AddFlush("Flush1", oComp1, "XY Plane", oComp3, "FrontFace")

 

In this case the XY Plane of the top level assembly will be constraint to the face named FrontFace of the Part in the subassembly. See the comments how to create a ComponentArgument-Object using an empty string, a string or an array of strings.

0 Likes
Message 5 of 5

GeertvanderHeide
Advocate
Advocate

Thanks for the explanation!

I don't think there is a way i would have figured that out myself. 

this also helps a bit in understanding how to fill in objects like this 🙂

GeertvanderHeide_0-1663913258985.png

 

0 Likes