I logic program for adding and constraining components but i don't know how to add multiple assembly with the same program

I logic program for adding and constraining components but i don't know how to add multiple assembly with the same program

richie_rQYQ8U
Contributor Contributor
170 Views
2 Replies
Message 1 of 3

I logic program for adding and constraining components but i don't know how to add multiple assembly with the same program

richie_rQYQ8U
Contributor
Contributor

Hi All,

 

I write a program to add the components in an assembly and give constrains but I don't know how to add multiple assemblies with the same program i tried creating a panel number as integer and adding it to the name of my component but i ended up getting multiple panel like this. can anyone help me with this 

 

Attached the code below 

 

'Directing to the part folder
Dim PartsFolder As String = "Z:\Jobs-Quotes\Others\Ghost\Generative design\Seamless Balustrade\FFTM"

'Place Faceplate
Dim FaceplateComp = Components.Add("_Faceplate", PartsFolder & "/faceplate.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing)

'Place Baluster
Dim BalusterComp = Components.Add("_Baluster",  PartsFolder & "/seamless baluster.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing)

'get Height from FFL
Dim Handrail_height_from_FFL, Faceplate_to_FFL, Baluster_height_below_FFL As Double

Handrail_height_from_FFL = InputBox("Enter the Handrail height from FFL", "Height from FFL", 1100)
Baluster_height_below_FFL =  InputBox("Enter the Baluster height below FFL", "Height below FFL", 585)
Faceplate_to_FFL=  InputBox("Enter thedistance from Faceplate to FFL", "Faceplate to FFL", 120)
'Parameter Baluster

Parameter("_Baluster", "BalusterHeight_Above_FFL") = (Handrail_height_from_FFL-15)+Faceplate_to_FFL
Parameter("_Baluster", "BalusterHeight_Below_FFL") = Baluster_height_below_FFL - 3

'constrain Faceplate to baluster
Constraints.AddFlush("SideFlush_Faceplate_Baluster", "_Faceplate", "SideFlush_Faceplate", "_Baluster", "SideFlush_Baluster",
                     offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing)
					 
Constraints.AddMate("BackMate_Faceplate_Baluster", "_Faceplate", "FrontMate_Faceplate", "_Baluster", "BackMate_Baluster",
                    offset := 0.0, e1InferredType := InferredTypeEnum.kNoInference, e2InferredType := InferredTypeEnum.kNoInference,
                    solutionType := MateConstraintSolutionTypeEnum.kNoSolutionType,
                    biasPoint1 := Nothing, biasPoint2 := Nothing)

Constraints.AddFlush("TopFlush_Faceplate_Baluster", "_Faceplate", "TopFlush_Faceplate", "_Baluster", "XZ plane",
                     offset := 0.0, biasPoint1 := Nothing, biasPoint2 := Nothing)

'Place Undercap
Dim Comp = Components.Add("_Undercap", PartsFolder & "/undercap.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing)

'Constrain Undercap
Constraints.AddMate("SideMate_Baluster_Undercap", "_Baluster", "SideFlush_Baluster", "_Undercap", "XY plane",
                    offset := 0.0, e1InferredType := InferredTypeEnum.kNoInference, e2InferredType := InferredTypeEnum.kNoInference,
                    solutionType := MateConstraintSolutionTypeEnum.kNoSolutionType,
                    biasPoint1 := Nothing, biasPoint2 := Nothing)

Constraints.AddMate("CentreMate_Baluster_Undercap", "_Baluster", "XY plane", "_Undercap", "YZ plane",
                    offset := 0.0, e1InferredType := InferredTypeEnum.kNoInference, e2InferredType := InferredTypeEnum.kNoInference,
                    solutionType := MateConstraintSolutionTypeEnum.kNoSolutionType,
                    biasPoint1 := Nothing, biasPoint2 := Nothing)
					
Constraints.AddFlush("TopFlush_Baluster_Undrecap", "_Baluster", "XZ plane", "_Undercap", "XZ plane",
                     offset := (Handrail_height_from_FFL-7.5)+Faceplate_to_FFL, biasPoint1 := Nothing, biasPoint2 := Nothing)

'Place Baluster Endcap
Dim BalusterBotEndcapComp = Components.Add("_BalusterBotEndcap", PartsFolder & "/seamless baluster bot ec.ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing)

Constraints.AddUcsToUcs("Endcap_to_Baluster", "_Baluster", "origin", "_BalusterBotEndcap", "origin", 
                            xOffset := 0, yOffset := -Baluster_height_below_FFL, zOffset := 0)

'Get number of balusters
Dim NumberOfBalusters As Double

NumberOfBalusters = InputBox("Enter the Number of Balusters", "Number of Balusters 1 - 15 max", 10)

'Pattern Baluster
Dim rectPattern = Patterns.AddRectangular("Baluster_pattern", {"_Baluster","_BalusterBotEndcap"}, NumberOfBalusters, -110, Nothing, "X Axis", columnNaturalDirection := True, rowCount := 1, rowOffset := 1.0 in, rowEntityName := "Y Axis", rowNaturalDirection := True)

Parameter("_Faceplate", "FacePlate_length") = NumberOfBalusters * 110
Parameter("_Undercap", "uc_ln") = NumberOfBalusters * 110

richie_rQYQ8U_0-1699748555884.png

 

 

 

0 Likes
171 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

Hi @richie_rQYQ8U 

Can you show the browser with the manually added occurrences?  You can then use capture tool to add or if you can highlight what is wrong with the existing code vs what you actually want to achieve on screen then that will help alot. 

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 3

richie_rQYQ8U
Contributor
Contributor

Hi Acheson,

Thank you for your reply

I don't know where it goes wrong with the code

I don't know how to change the parameter name for multiple inputs

And every time i add another assembly with this code the flush constrain changes 

 

richie_rQYQ8U_0-1699776611391.png

 

0 Likes