For loop for changing the size of content center components

For loop for changing the size of content center components

T3H
Enthusiast Enthusiast
675 Views
2 Replies
Message 1 of 3

For loop for changing the size of content center components

T3H
Enthusiast
Enthusiast

I need some help creating a for loop (or something similar) for changing the size of content center components.

I created the following code:

SyntaxEditor Code Snippet

If HardwareSize = .25 Then
Dim Circular_Washer_Inch = Components.AddContentCenterPart("Circular Washer (Inch) 1",
                                                           "Fasteners:Washers:Plain",
                                                           "Circular Washer (Inch)",
                                                           "1/4",
                                                           Circular_Washer_InchPos)

ElseIf HardwareSize = .3125 Then
	Dim Circular_Washer_Inch = Components.AddContentCenterPart("Circular Washer (Inch) 1",
                                                           "Fasteners:Washers:Plain",
                                                             "Circular Washer (Inch)",
                                                             "5/16",
                                                           Circular_Washer_InchPos)
														   
End If

 This successfully changes the size of a washer at position "Circular Washer (Inch) 1" based on a selected parameter "HardwareSize".

Now I want to change the size of washer 2, 3, 4 and so on.

Does anybody have a suggestion for how to do this?

Thanks.

0 Likes
Accepted solutions (1)
676 Views
2 Replies
Replies (2)
Message 2 of 3

T3H
Enthusiast
Enthusiast
Accepted solution

I figured out a way (see below). I feel like there must be a much better way to do this though, if anybody has suggestions I'm all ears.

SyntaxEditor Code Snippet

Dim I As Integer = 1

For I = 1 To 4
	
	Dim WasherName = "Circular Washer (Inch) " & I
	Dim NutName = "Hex Nut - Inch " & I

	If HardwareSize = .25 Then
	Dim Circular_Washer_Inch = Components.AddContentCenterPart(WasherName,
                                                           "Fasteners:Washers:Plain",
                                                           "Circular Washer (Inch)",
                                                           "1/4",
                                                           Circular_Washer_InchPos)

    Dim Hex_Nut_Inch_1 = Components.AddContentCenterPart(NutName,
                                                         "Fasteners:Nuts:Hex",
                                                         "Hex Nut - Inch",
                                                         "1/4 - 20",
                                                         Hex_Nut_Inch_1Pos)
    
    ElseIf HardwareSize = .3125 Then
	Dim Circular_Washer_Inch = Components.AddContentCenterPart(WasherName,
                                                           "Fasteners:Washers:Plain",
                                                             "Circular Washer (Inch)",
                                                             "5/16",
                                                           Circular_Washer_InchPos)
	
    Dim Hex_Nut_Inch_5_16_18 = Components.AddContentCenterPart(NutName,
                                                               "Fasteners:Nuts:Hex",
                                                               "Hex Nut - Inch",
                                                               "5/16 - 18",
                                                               Hex_Nut_Inch_5_16_18Pos)
    
    
	End If									   
	
Next
0 Likes
Message 3 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support

@T3H,

 

If code is working, click on "Accept Solution".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes