How to change the origin of a importet .stl model to its center #40
-
Hi, i want to import the same .stl cylinder model twice O_Ring_Template.zip. The second cylinder model i scale a little bit smaler. Then i want to difference the smaller cylinder from the bigger one to get an symmetric O-Ring. The problem is, that madcad puts the origin of the model in the left lower corner and not in the center of the cylinder (indepented where i put the origin of the cylinder in e.g. solid works) How can i match the centers of both cylinder (smaller and bigger on), |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello For imported meshes, madcad is not changing the origin, it simply import points coordinates as they are stored in the file, which means the software that produced your cylinders actually placed the origin on the corner (the solidworks' mesher ?). I agree such an origin placement is not convenient for a cylinder ;) Also you can fix that origin by translating one or both mesh of what is necessary (the radius) # translating both
difference(
ring_big .transform(-ring_big_radius*vec3(1,1,0)),
ring_small .transform(-ring_small_radius*vec3(1,1,0)),
)
# translating only one
difference(
ring_big .transform(),
ring_small .transform((ring_big_radius-ring_small_radius)*vec3(1,1,0)),
) If you don't know the radius by advance and want an automated solution, you can get it from the boundingbox difference(
ring_big .transform(-ring_big.box().width/2),
ring_small .transform(-ring_small.box().width/2),
) Note: using the boundingbox is precise only if the cylinder meshing is symetrical (typically has a number of divisions multiple of 4). If you need the precise axis of a cylinder with random meshing, you can use the reverse engineering function creating cylinders using madcad functions will center it on what you want: cylinder(
vec3(0), # center of the bottom circle, placed on the origin
vec3(0,0,1), # center of the top circle, placed above the origin
0.5, # radius
) I hope this helps |
Beta Was this translation helpful? Give feedback.
Hello
For imported meshes, madcad is not changing the origin, it simply import points coordinates as they are stored in the file, which means the software that produced your cylinders actually placed the origin on the corner (the solidworks' mesher ?). I agree such an origin placement is not convenient for a cylinder ;)
Also you can fix that origin by translating one or both mesh of what is necessary (the radius)