Luleå CAD assignments
Create a parametric wall using Expressions
The wall block
Start NX 5.0 and create a new model file. Now we are going to sketch a rectangle and extrude the rectangle to a block. This block will be parametric and one type of parameters in NX are called expressions. Create a sketch by pressing the sketch button.
Click on the Z-Y plane and click OK in the Create sketch dialog. You now enter the sketcher. Press the rectangle button and draw a rectangle with an arbitrary size.
Create two dimension parameters by clicking the Inferred Dimensions button. Name the parameters h as in height and w as in width. Make w dependent of h in some way (e.g. w=h*2). Change the value for h to examine that the dependency works.
Finish the sketch by pressing the flag button to the left and you return to the Modeling environment. Now we are going to give the rectangle a depth by using the extrude function. Press the extrude button and choose your sketch (the rectangle).
Define the depth either by typing in a value or grabbing the end of the green arrow. Now your wall should look something like this, of course depending on the depth and parametric relations you defined.
Now it's time to take a look at the expressions, i.e. the parameters of the wall. Click the Tools menu and select Expressions (or type Ctr-E). In the Expressions dialog, select All in Listed Expressions. Now you should see the parameters of your wall. Note that the extrude operation has two parameters that define the length of the extrude. Now create a new parameter (user defined) manufacturing_cost and make it dependent of some of the other parameters. You do it by, in the Expressions dialog, simply typing the name, giving it a formula and pressing Apply. Now it's time to save, if you haven't done it earlier.
The door and window
Now we are going to create two holes; one for a door and one for a window, and parametrize! First we will sketch to rectangles and the we will extrude them into holes.
Click the sketch button and and select the front surface of the wall and click OK. Draw two rectangles using the same rectangle button as before. Now the sketch should look something like this:
Now we will constraint the door rectangle to be Collinear with the wall block. Click the constraints button, select the bottom line of the rectangle and the bottom line of the wall block.
Possible constraint will show in the constraints dialog. Choose collinear. Then constrain the window to be collinear with the door and add dimensional parameters (Inferred dimensions button) to the door and the window. Also add dimensions between the sides of the wall block and the door and window respectively to control the positioning. Rename the dimensions you just created so you later can find them easier in the expressions dialog. When done return to the modeling environment.
Now extrude the two rectangles into two holes by using the extrude button. Reverse direction of the extrude vector if needed and select a suitable Boolean for the operation. Now your wall should look sometime like this:
Open the expressions dialog again and list Named expressions to see the parameters that you have named. Play around with the parameters by changing them, creating more user defined, making them dependent or constant and press Apply to see the changes. Create expressions where you assess the geometry for downstream aspects e.g. manufacturing, cost. Try to find a practical parametrization. When your satisfied, show the results for one of the tutors.
Extra assignment
Create a new wall or arbitrary geometry using freer geometry and explore how it can be parametrized using expressions. Try the other drawing tools of the this toolbar:
This is an example for inspiration (extrude if you like or explore other functions of NX):
Create a parametric room using User defined features
Now we are going to use a function in NX that let us create an own feature (piece of geometry, often a part of a component) called an User Defined Feature (UDF). We are going to create a UDF of the wall just created and use this UDF to couple several walls into a parametric room. This is one example:
Creating an User Defined Feature
When creating the UDF you have to have something to guide the positioning of the UDF in the space. We are going to use the coordinate system for that issue. So first we'll make sure that the wall sketch is constrained to the coordinate system.
Constrain the wall sketch
Open the wall sketch by double-clicking on the actual sketch (seen in blue in the 3D-view) or in the Part Navigator. Then use the Contraints button again and click on the left side of the wall and on the Z-axis (the vertical axis). Choose Collinear. Repeat this for the bottom side of the rectangle and the Y-axis. Now your sketch should look like this with the bottom left corner of the rectangle “attached” to the origin of the coordinate system:
Add UDF
Now we will add the UDF.
- Exit the sketcher and start the UDF Wizard: Tools → User Defined Feature → Wizard
- Name: Wall, Part Name: The name of your part-file (????.prt). Click Next.
- Now we choose what portion of the part file that will be included in the UDF. Choose the two sketches and the two extrudes and click the arrow pointing to the right. Click Next.
- Now we will choose what expressions to include in the UDF. Choose at least the width of the wall. Name each expression you export. Click Finish.
Inserting the UDF to create a room
Now we will insert numerous walls to create a parametric room. Start a new part-file (Type: Modeling) and choose: Tools → User Defined Feature → Insert. Click the wall and the positioning and definition of expression values starts. Firstly choose the values of your expressions. Then start to resolve the references. By checking the UDF Definition window you get a hint of what you need to resolve. When there is a plus-sign in front of the references indicate that it is resolved. Click Apply and your first wall appears. Repeat the process of giving the expressions values and resolving the references and create at least three walls. If your wall gets positioned in a way you did not intend to. Double click the wall and you can edit the references. Use the reverse direction button. Change the room layout by changing the expressions.
Create a parametric volume using Knowledge-based engineering
In this exercise you will create a parametric volume where the floor guides the sizes of the walls and positioning of foor and window. The window can also be switched to a rectangular window by changing a parameter.
Start NX 5.0 and create a new model file. Make sure that roles is set to “Advanced with full menus”. You find the roles tab to the left.
Click Start and toggle Knowledge Fusion and the Knowledge Fusion Navigator (KFN) tab will appear to the left.
The floor
First we are going to create the floor by using a class that creates a block and two attributes (parameters) that we will create.
Attributes
The attributes are parameters that can be used to govern the geometry objects, e.g. the child rules. We will create two attributes that control the dimensions of the floor in x and y direction.
- In the KFN, right click root and choose Add Attribute
- Name the attribute to floor_x_dim
- Keep the default Type (Number, Lenght and mm)
- In the formula space write: 6000 and press Apply
- Create an attribute floor_y_dim in the same manner and set it to 4000
- Close the Add Attributes dialog
- In the KFN expand the Attributes list and you find your two attributes in blue color
Child rule
A child rule is an instance of a class. We will now add a child rule that creates a block and let the attributes we just created control the block dimensions.
- Right click root and choose Add Child Rule
- In the Add Child Rule dialog name the child to Floor
- In the Name filter space write block and choose ug_block
- Select Length under Input parameters and in Rule for parameter delete 1 and add floor_x_dim. Do this by right clicking the attribute in KFN and select Reference. It should look like: floor_x_dim:;
- Couple Width and Floor_y_dim in the same way
- Height decides the thickness of the floor. Choose a number, e.g. 200.
- Press OK and your floor is created
- Use the Fit button to see the whole floor.
The door wall
Now we will create the wall with a doorway. We will once again use the ug_block class for the wall and the door. We will parametrize the wall and the doorway to adapt to floor changes.
The wall
- Add a ug_block instance and name it to wall_w_doorway
- Couple the width of the wall to one of the floor attributes so the width of the wall follows the floor. Hint: Length, Width and Height, in Input Parameters, represent the X, Y and Z directions respectively. Compare with the coordinate system.
- Position the wall on the floor by changing the position parameter in Input Parameters
- Give the wall a thickness and height as well.
- Click OK to exit the dialog and change the floor attribute to examine that the width of the wall follows.
The doorway
When satisfied with the wall it is time to create the doorway. We will create a block and subtracting it from the wall block. NOTE: It is important that you do all of the following before pressing apply in order for the subtract operation to work properly.
- Create a block and name it to doorway
- Give the door dimensions
- Make sure that the door always is positioned in the middle of the wall
- As we are going to subtract the block from the wall to create a doorway change Operation to Subtract
- We also need to specify what object to subtract from. Click Target and right click the wall child (wall_w_doorway) the KFN and select reference.
- Click OK and the doorway will be created
- Change the governing floor attribute to see that the doorway always stays in the middle.
Your module should now look something like this:
The window wall
Now lets create one more wall for the module and put a nice window opening into it. Besides that both the wall and the window opening should follow when the floor changes in size we should also enable the window to change shape from round to rectangular. Ok, lets do it!
The wall
- Create a wall in the same way as for the door wall and position it beside the door wall
- When the wall is created try to change the floor attributes to see that the width follows
The window opening
Lets go for the window now! This time we will start by using a class that creates a cylinder; ug_cylinder and then we will use an if-then-else rule to enable a change to rectangular window. But first of all we need to create one more attribute that decides the shape of the window opening.
- Add an attribute with the type String and call it window_opening_shape and set its value to “round”. NOTE: The quotation marks need to be included which is common for the String type.
- Now create a cylinder by using ug_cylinder and subtract it to the wall in the same way as for the window wall
- When positioning the cylinder also use the Direction Input parameter
Your module should now look something like this (depending on the chosen dimensions of course):
If-then-else rules
Ok, now its time to create the rules that changes the shape of the window opening by changing the instance of ug_cylinder to a instance of ug_block.
- Double click the window_opening child in the KFN
- In the Edit Child Rule dialog click the Method drop list and choose Specify Rule for Class
- Click the Extended Entry button to enlarge the input field
- Write: if window_opening_shape:=“round” then ug_cylinder else Nulldesign;
- Close the dialog and change the window_opening_shape attribute to something else and the window should disappear
- Leave the window opening gone
- Now, create a rectangular window opening and create a rule that makes it appear when window_opening_shape:=“square”
- Change the window_opening_shape attribute and see if the window changes the shape
Reflect over the need for more attributes to make the module more parametric.


















