Get part name of subassembly component picked

Get part name of subassembly component picked

rbertoletti
Enthusiast Enthusiast
339 Views
2 Replies
Message 1 of 3

Get part name of subassembly component picked

rbertoletti
Enthusiast
Enthusiast

Hi everyone!

I'm trying to adjust a rule i built in order to pick components and get the name.

This actually works inside and assembly with only parts, but i'm trying to use it in an assembly in order to pick components placed inside other 2 assemblies.

 

Here below there's the code. Let me know how to adjust it.

Thanks in advance!

Dim cam As Camera = ThisApplication.ActiveView.Camera
cam.ViewOrientationType = ViewOrientationTypeEnum.kLeftViewOrientation
cam.ApplyWithoutTransition
cam.Perspective = True
cam.ApplyWithoutTransition
cam.Fit
cam.ApplyWithoutTransition

'[Pick First stud, Last stud and Liner panel
Dim objFirstStud As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select the FIRST Stud") 
Dim objLastStud As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select the LAST Stud")
Dim objLiner As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select the LINER PANEL")
']

'[Get Studs and Liner name
Dim oFirstStud As String = objFirstStud.Name
Dim oLastStud As String = objLastStud.Name
Dim oLiner As String = objLiner.Name
']

'[Get the distance between first and last stud and calculate Slot number
Dim oStudTotDist As Double = Measure.MinimumDistance(oFirstStud, "StudCL", oLastStud, "StudCL") + (Parameter(objFirstStud.Name, "d1") * 2)

Dim oStudSlotNer As Integer = (oStudTotDist / Hole_Span) + 1
']

'[Place Batten channel in assembly with defined slot number
Dim ItemSeq As String = "BC_" & iProperties.Value("Custom", "BattenChannel")
Try
Dim oBCMat As String = Liner_Material
Select Case oBCMat
	
Case "C.S."
Dim oNewBCAdd = Components.Add(ItemSeq, "BC_L_CS_CA-24V.ipt")

Case "SS304"
Dim oNewBCAdd = Components.Add(ItemSeq, "BC_L_304_CA-24V.ipt")

Case "SS309"
Dim oNewBCAdd = Components.Add(ItemSeq, "BC_L_309_CA-24V.ipt")

Case "SS310"
Dim oNewBCAdd = Components.Add(ItemSeq, "BC_L_310_CA-24V.ipt")

Case "SS409"
Dim oNewBCAdd = Components.Add(ItemSeq, "BC_L_409_CA-24V.ipt")

Case "CORTEN"
Dim oNewBCAdd = Components.Add(ItemSeq, "BC_L_COR_CA-24V.ipt")

End Select

Parameter(ItemSeq, "HolesSpan") = Hole_Span
Component.ActiveModelState(ItemSeq) = oStudSlotNer & "Slots"
']

'[Constraint Batten channel to studs and liner panel
Dim oMateSeq = "BC_" & iProperties.Value("Custom", "BattenChannel")
Constraints.AddMate("Mate1:" & oMateSeq, ItemSeq, "BCFaceToLiner", oLiner, "LinerInt")
					
Constraints.AddMate("Mate2:" & oMateSeq, ItemSeq, "FirstSlotCL", oFirstStud, "StudCL", e1InferredType := InferredTypeEnum.kInferredLine,
                    e2InferredType := InferredTypeEnum.kInferredLine,
                    solutionType := MateConstraintSolutionTypeEnum.kOpposedSolutionType)
					
Constraints.AddMate("Mate3:" & oMateSeq, ItemSeq, "LastSlotCL", oLastStud, "StudCL", e1InferredType := InferredTypeEnum.kInferredLine,
                    e2InferredType := InferredTypeEnum.kInferredLine,
                    solutionType := MateConstraintSolutionTypeEnum.kOpposedSolutionType)

iProperties.Value("Custom", "BattenChannel") = iProperties.Value("Custom", "BattenChannel") + 1

Catch
End Try

cam.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
cam.ApplyWithoutTransition
cam.Perspective = False
cam.ApplyWithoutTransition
cam.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation
cam.Fit
cam.ApplyWithoutTransition
']
0 Likes
Accepted solutions (1)
340 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @rbertoletti.  There is another selection filter variation that is better suited for letting you select components that represents parts that are down with sub assembly components (kAssemblyLeafOccurrenceFilter).  Maybe give that one a try instead of the 'kAssemblyOccurrenceFilter' variation.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

rbertoletti
Enthusiast
Enthusiast
That's great!
Thanks!
0 Likes