How to create wall assembly with selected parts on inventor with VB.net code.

How to create wall assembly with selected parts on inventor with VB.net code.

ganesh.rajapurkar-ext
Contributor Contributor
1,629 Views
28 Replies
Message 1 of 29

How to create wall assembly with selected parts on inventor with VB.net code.

ganesh.rajapurkar-ext
Contributor
Contributor

Hi Team,

 

I want to create assembly through VB .net code with 5 parts files .

And its actual output should look like Picture(Final outputPart-1Part-1Part-3Part-3Part-2Part-2Part-4Part-4Part-5Part-5Final Output.PNG

0 Likes
Accepted solutions (1)
1,630 Views
28 Replies
Replies (28)
Message 21 of 29

ganesh.rajapurkar-ext
Contributor
Contributor

Thank you for the reply on capturing ILogic code .

With the help of this we are developing small Plugin where we need to perform mate constraint on respective edges of the two parts.

 

Can anyone help us how to perform mate using edges .

Here is the iLogic code which we wants to convert into VB.Net

 

Constraints.AddMate("Mate:1", "091Z004429-0042:1", "Edge0",
"091Z004429-0031:1", "Edge4",
e1InferredType := InferredTypeEnum.kNoInference,
e2InferredType := InferredTypeEnum.kInferredPoint)

0 Likes
Message 22 of 29

ganesh.rajapurkar-ext
Contributor
Contributor

We have to programatically perform mate on two parts using respective edges .

1] Part-1 Edge 0

2]Part-2 Edge 4

 

We got a code in iLogic as follows .But we are not getting how to find out this Edge-0 and Edge-4 from parts using VB.Net

Constraints.AddMate("Mate:1", "091Z004429-0042:1", "Edge0",
"091Z004429-0031:1", "Edge4",
e1InferredType := InferredTypeEnum.kNoInference,
e2InferredType := InferredTypeEnum.kInferredPoint)

0 Likes
Message 23 of 29

ganesh.rajapurkar-ext
Contributor
Contributor

Any help on this would be highly appreciated.

0 Likes
Message 24 of 29

ganesh.rajapurkar-ext
Contributor
Contributor

Can anybody please let me know how to perform mate constraint on parts edges using vba /vb.net code.

 

Following is the code from iLogic which I am trying to convert into VB but not getting proper output.

 

Dim _091Z004429_0031_1Pos = ThisAssembly.Geometry.Matrix(1, 0, 0, 0.05628,
0, 0, 1, 22.xxx-xxxxxxxx,
0, -1, 0, 22.55628,
0, 0, 0, 1)
Dim _091Z004429_0031_1 = Components.Add("091Z004429-0031:1",
"091Z004429-0031.ipt",
_091Z004429_0031_1Pos)

Constraints.AddMate("Mate:1", "091Z004429-0042:1", "Edge0",
"091Z004429-0031:1", "Edge4",
e1InferredType := InferredTypeEnum.kNoInference,
e2InferredType := InferredTypeEnum.kInferredPoint)

 

0 Likes
Message 25 of 29

A.Acheson
Mentor
Mentor

Here is the API sample for a generic entity. If you know the object is an edge you can declare it as such. Try the sample on it's own before integration it into a bigger rule. 

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

ganesh.rajapurkar-ext
Contributor
Contributor

Please find below my code and suggest how to perform Mate on edge 0 of first part and edge 4 of second part.

Dim oAsm As AssemblyDocument = inventorApp.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsm.ComponentDefinition

Dim oTG As TransientGeometry
oTG = inventorApp.TransientGeometry

Dim oOccurrence As ComponentOccurrence

Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix()

'Adding First part on assembly
Dim oOcc1 As ComponentOccurrence
oOcc1 = oAsmCompDef.Occurrences.Add("091Z004429-0042.ipt", oMatrix)
oOcc1.Grounded = True

'Adding Second part on assembly
Dim oOcc3 As ComponentOccurrence
oOcc3 = oAsmCompDef.Occurrences.Add("091Z004429-0031.ipt", oMatrix)

0 Likes
Message 27 of 29

A.Acheson
Mentor
Mentor

The API samples have a sample of working with edges look under assembly joint and constraint samples

Dim oEdge1 As Edge = oOcc1.SurfaceBodies(1).Edges(0)
Dim oEdge1 As Edge = oOcc3.SurfaceBodies(1).Edges(4)
' Create the insert constraint between the parts.
Dim oMate As MateConstraint = oAsmCompDef.Constraints.AddMateConstraint(oEdge1, oEdge2, 0)

 

Loop through all edges of an occurrence extracted from 

  Dim oEdge As Edge
    For Each oEdge In oOcc1.SurfaceBodies(1).Edges
        If oEdge.GeometryType = kLineSegmentCurve Then
        End If
    Next

 

 

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

ganesh.rajapurkar-ext
Contributor
Contributor

This is the desired output I wantThis is the desired output I wantThis is what I am getting with VB.net codeThis is what I am getting with VB.net code

0 Likes
Message 29 of 29

A.Acheson
Mentor
Mentor

Any chance of attaching the assemblies your working with and also the code as you have so far? I would have thought faces would be easier to use as there is less in the model but without seeing your full model it is hard to offer to  much insight. 

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