The assembly module

Also see :

Quick Notes

Example :

# Adds the assembly you select to the member you select.
from assembly import Assembly, AssemblyList
from dialog import Dialog
from dialog.combobox import Combobox
from member import MemberLocate
from point import PointLocate
from param import ClearSelection
assm_list = AssemblyList()
# Dialog opens
Dlg0 = Dialog("Select an Assembly")
Menu1 = Combobox( Dlg0, "assm_name", assm_list, label="Select
            an assembly:", default=assm_list[0])
# Dialog closes after user presses "OK" or "Cancel"
if Dlg0.Run():                            # if user pressed "OK"
    mem1 = MemberLocate("Select a member") # rotation is based off the member -- mem1
    rot_pt = (90.0, 0.0, 0.0)
    point = PointLocate("Locate a point")
    #Assembly begin
    assm1 = Assembly()
    assm1.Member = mem1
    assm1.AssemblyName = Dlg0.assm_name
    assm1.LocationPoint = point
    assm1.Rotation = rot_pt
    assm1.Add()
    # Assembly end
    ClearSelection()
else:                            # if user pressed "Cancel"
    print("You have canceled this operation!")

assm1 =

assm1 = Assembly() begins the code for adding an assembly to a member. A block of code for adding an assembly to a member ends with the line assm1.Add() .

assm1.Member = MemberLocate("status line") or a member object previously identified in the parametric code. This assigns the member the assembly is added to. An assembly must be added to a member. The materials that makes up the assembly becomes submaterials of the member.


Assembly attributes :

assm1 .AssemblyName = a " string " that identifies the name of an assembly in your current Job. If a parametric's assembly name does not exist in the Job in which the parametric is Run , the parametric generates an assembly.error . In the following code, "clips" is the name of the assembly. If you have an assembly named clips in your current Job, this script will add that assembly.

# Adds an assembly named "clips" to the member you select.
from assembly import Assembly
import assembly                                # to catch the exception
from member import MemberLocate
from point import PointLocate
from param import ClearSelection
try:
    assm1 = Assembly()
    assm1.Member = MemberLocate("Select a member")
    assm1.AssemblyName = "clips"
    assm1.LocationPoint = PointLocate("Locate a point")
    assm1.Rotation = (0.0, 0.0, 0.0)
    assm1.Add()
except assembly.error:
    print("There is no assembly named clips in your Job")
    ClearSelection()

assm1 .LocationPoint = PointLocate("Locate a point") or a point object.

In the following example , mem1.RightEndLocation is used as the assembly's reference point. If PointLocate("Locate a point") were used, the user would be prompted to locate a point. If (0, 0, 0) was used, the assembly would be placed at the model's 0, 0, 0 point. If you have an assembly named clips in your current Job, this script will run.

# Adds an assembly at the right-end member work point.
from assembly import Assembly
from member import MemberLocate
from param import ClearSelection
mem1 = MemberLocate("Select a member")
assm1 = Assembly()
assm1.Member = mem1
assm1.AssemblyName = "clips"
assm1.LocationPoint = mem1.RightEnd.Location
assm1.Rotation = (0.0, 0.0, 0.0)
assm1.Add()
ClearSelection()

assm1 .Rotation = degrees of rotation around X, Y, Z member coordinates .

In the following example , (90.0, 0.0, 0.0) rotates the assembly 90 degrees around the X member axis. (0.0, 90.0, 0.0) would rotate the assembly 90 degrees around the Y member axis. (0.0, 0.0, -90.0) would rotate the assembly -90 degrees around the Z member axis. The origin of these axes is at the point located by the user according to the assm1.LocationPoint = PointLocate("Locate a point") line in the code. If you have an assembly named clips in your current Job, this script will run.

# Rotates assembly 90 degrees around X member axis.
from assembly import Assembly
from member import MemberLocate
from point import PointLocate
from param import ClearSelection
assm1 = Assembly()
assm1.Member = MemberLocate("Select a member")
assm1.AssemblyName = "clips"
assm1.LocationPoint = PointLocate("Locate a point")
assm1.Rotation = (90.0, 0.0, 0.0)
assm1.Add()
ClearSelection()

Methods and functions :

assm1 .Add() adds the assembly. This line ends the block of code that begins with assm1 = Assembly() .

AssemblyList() returns a list of the assemblies in your current Job .

The following example is code that generates a dialog that shows the AssemblyList() as menu options ( ) . The assm_list[0] is the assembly that is selected by default and is the first item in AssemblyList() . The variable dlg1.assm_name is the assembly that the user selects -- click here for an important tip. Also, click here for an example of a script that actually lets you add the assembly that you select on the dialog.

# Prints the name of the assembly that you select in the dialog.
from assembly import AssemblyList
from dialog import Dialog
from dialog.combobox import Combobox
assm_list = AssemblyList()
# Dialog opens
Dlg0 = Dialog("Select an Assembly")
Menu1 = Combobox( Dlg0, "assm_name", assm_list, label="Select
    an assembly:", default=assm_list[0])
# Dialog closes after user presses "OK" or "Cancel"
if Dlg0.Run():                            # if user pressed "OK"
        print(Dlg0.assm_name)
    else:                                 # if user pressed "Cancel"
        print("You have canceled this operation.")