Fabrication elbow - discern top/bottom extensions

steven.williams.as
Enthusiast

Fabrication elbow - discern top/bottom extensions

steven.williams.as
Enthusiast
Enthusiast

I am trying to change the top or bottom extension of a standard radius elbow. However, I cannot figure out how to tell whether one end is "top" or "bottom." The only consistent approach I have found so far is to guess, and undo if the guess was incorrect. The Edit Part dialog shows a preview of the part, but not in context of the drawing. Here is essentially what I have so far:

 

// part in question is part1
// part's connectors are c1 and c2a
// goal is to figure out which (top/bottom) extension corresponds to c2a
FabricationDimensionDefinition topExt = part1.GetDimensions().SingleOrDefault(i => i.Name == "Top Extension");
double part1topExtension = part1.GetDimensionValue(topExt);
double extLength = 5; // pick your length
part1.SetDimensionValue(topExt, extLength);
// oops, wrong extension, try again 50% of the time

 

Any suggestions for other improvements in technique also welcome, of course.

 

2022-01-12 11.03.22 obzcbG5PJi.png

0 Likes
Reply
Accepted solutions (1)
418 Views
4 Replies
Replies (4)

jeremy_tammik
Autodesk
Autodesk
Accepted solution

The part is defined in its own local coordinate system. In that definition framework, top and bottom are well defined. When the part is placed in the project coordinate space, a transformation is applied. You need to determine what that transformation is. That will tell you how the local coordinate system is transformed to the project space, and thus how the original top and bottom directions end up oriented in your model.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

MarryTookMyCoffe
Collaborator
Collaborator

use CordinateSystem.BasisX/Y/Z in connectors to know where is top

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes

steven.williams.as
Enthusiast
Enthusiast

So it appears that I can use the part's inverse transformation on each connector to find which one is further in the y-direction. As much as that doesn't seem well defined to me -- shouldn't z be top/bottom, not y? -- I think I can work with it. Here's what I have:

// part in question is part1
// connectors are c1 and c2
Transform part1transform = part1.GetTransform();
XYZ c1original = part1transform.Inverse.OfPoint(c1.Origin);
XYZ c2original = part1transform.Inverse.OfPoint(c2.Origin);
if (c1original.Y > c2original.Y)
{
    // c2 is near the bottom extension, do something
}
else
{
    // c2 is near the top extension, do something else
}

 

Does this look reliable for discerning the top and bottom connectors?

0 Likes

jeremy_tammik
Autodesk
Autodesk

Looks good to me. 

 

You should be able to see and understand why to top side is the Y direction by looking into the family definition in the family editor. The family definition defines the origin and orientation of the part.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes