Extracting Face/Edge information
Many of the methods in the global context of the script expect Part Id as one of the parameter.
The challenge is how to write code that works during development and, lets call it, production environment.
The technique is to rely on a global function called isDevMode().
This can best be illustrated using following pseduo code as an example. This is a pseduo code. Refer to API’s for creating actual cylinder object
//Objective : Measure Face information
let cylFace, endFaces;
if( isDevMode() ) {
//construct a solid used for testing code. Say a cylinder
let cylinder = createCylinder();
//Access the circular face
cylFace = cylinder.faces()[0];
//Access end faces
endFaces = cylinder.faces()[2];
} else {
//Here, assumption is, you have defined a parameter of type 'Face' with name as 'faces'.
//When this shape is edited as a feature in the Part Designer,
//you will notice 'faces' as one of the parameters.
//That lets you choose a face, wait...., by clicking on any face!
//Now, assuming you have supplied this information
let cylFaceParam = params.faces[0];
let endFaceParam = params.faces[1];
//Each face object consists of partId, regionId, faceId and faceName
//faceName is more reliable than faceId.
//Extract Face object using following function.
cylFace = getPartFaceByName(cylFaceParam.partId, cylFaceParam.regionId, cylFaceParam.faceName);
//ditto
endFace = getPartFaceByName(endFaceParam.partId, endFaceParam.regionId, endFaceParam.faceName);
}
//Begin actual code by using the extraced face object
let measurement = cadlib.measureFace(cylFace);