yapcad package
Subpackages
- yapcad.assembly package
- Submodules
- yapcad.assembly.assembly module
AssemblyAssembly.nameAssembly.partsAssembly.transformsAssembly.matesAssembly.constraintsAssembly.add_constraint()Assembly.add_mate()Assembly.add_part()Assembly.export_to_blender_rig()Assembly.export_to_urdf()Assembly.get_degrees_of_freedom()Assembly.get_transformed_datum()Assembly.import_transforms_from_kinematic_chain()Assembly.report()Assembly.validate()Assembly.validate_and_raise()
AssemblyErrorAssemblyValidationResultAssemblyValidationResult.is_validAssemblyValidationResult.constraint_resultsAssemblyValidationResult.failed_constraintsAssemblyValidationResult.warningsAssemblyValidationResult.constraint_resultsAssemblyValidationResult.failed_constraintsAssemblyValidationResult.is_validAssemblyValidationResult.report()AssemblyValidationResult.warnings
- yapcad.assembly.constraint module
ConstraintConstraint.nameConstraint.constraint_typeConstraint.partConstraint.datumConstraint.centerConstraint.radiusConstraint.directionConstraint.axisConstraint.reference_datumConstraint.plane_normalConstraint.min_valueConstraint.max_valueConstraint.validatorConstraint.tolerance_degConstraint.tolerance_mmConstraint.descriptionConstraint.severityConstraint.axisConstraint.centerConstraint.constraint_typeConstraint.datumConstraint.descriptionConstraint.directionConstraint.evaluate()Constraint.max_valueConstraint.min_valueConstraint.nameConstraint.partConstraint.plane_normalConstraint.radiusConstraint.reference_datumConstraint.severityConstraint.tolerance_degConstraint.tolerance_mmConstraint.validator
ConstraintResultConstraintTypeConstraintType.TANGENT_TO_CIRCLEConstraintType.RADIAL_FROM_CENTERConstraintType.FACINGConstraintType.AT_RADIUSConstraintType.PARALLEL_TOConstraintType.PERPENDICULAR_TOConstraintType.AT_RADIUSConstraintType.CUSTOMConstraintType.FACINGConstraintType.IN_PLANEConstraintType.MIN_DISTANCEConstraintType.NO_INTERFERENCEConstraintType.ON_CIRCLEConstraintType.PARALLEL_TOConstraintType.PERPENDICULAR_TOConstraintType.RADIAL_FROM_CENTERConstraintType.TANGENT_TO_CIRCLE
angle_between_vectors()distance_to_point()dot_product()is_radial_from_center()is_tangent_to_circle()
- yapcad.assembly.datum module
DatumDatumTypePartDefinitionPartDefinition.namePartDefinition.datumsPartDefinition.geometry_sourcePartDefinition.is_printablePartDefinition.materialPartDefinition.descriptionPartDefinition.add_datum()PartDefinition.datumsPartDefinition.descriptionPartDefinition.geometry_sourcePartDefinition.get_datum()PartDefinition.is_printablePartDefinition.materialPartDefinition.namePartDefinition.validate_datums()
- yapcad.assembly.datum_registry module
- yapcad.assembly.face_mate module
FaceToFaceMateFaceToFaceMate.nameFaceToFaceMate.parent_partFaceToFaceMate.parent_datumFaceToFaceMate.parent_sourceFaceToFaceMate.child_partFaceToFaceMate.child_datumFaceToFaceMate.child_sourceFaceToFaceMate.constraintFaceToFaceMate.offset_distanceFaceToFaceMate.rotation_about_normalFaceToFaceMate.child_datumFaceToFaceMate.child_partFaceToFaceMate.child_sourceFaceToFaceMate.compute_transform()FaceToFaceMate.constraintFaceToFaceMate.invalidate_cache()FaceToFaceMate.nameFaceToFaceMate.offset_distanceFaceToFaceMate.parent_datumFaceToFaceMate.parent_partFaceToFaceMate.parent_sourceFaceToFaceMate.rotation_about_normalFaceToFaceMate.validate()
MateValidationResultMateValidationResult.satisfiedMateValidationResult.error_distanceMateValidationResult.error_angleMateValidationResult.error_messageMateValidationResult.detailsMateValidationResult.detailsMateValidationResult.error_angleMateValidationResult.error_distanceMateValidationResult.error_messageMateValidationResult.satisfied
compute_concentric_transform()compute_flush_transform()compute_parallel_transform()create_axis_mate()create_face_mate()
- yapcad.assembly.intent module
AssemblyIntentAssemblyIntent.nameAssemblyIntent.descriptionAssemblyIntent.functional_requirementsAssemblyIntent.connectionsAssemblyIntent.clearancesAssemblyIntent.reference_geometryAssemblyIntent.part_definitionsAssemblyIntent.derived_parametersAssemblyIntent.explicit_constraintsAssemblyIntent.add_clearance()AssemblyIntent.add_connection()AssemblyIntent.add_reference_geometry()AssemblyIntent.add_requirement()AssemblyIntent.clearancesAssemblyIntent.collect_constraints()AssemblyIntent.collect_derived_parameters()AssemblyIntent.connectionsAssemblyIntent.derived_parametersAssemblyIntent.descriptionAssemblyIntent.explicit_constraintsAssemblyIntent.functional_requirementsAssemblyIntent.nameAssemblyIntent.part_definitionsAssemblyIntent.reference_geometryAssemblyIntent.report()AssemblyIntent.solve()AssemblyIntent.to_assembly()AssemblyIntent.validate()
AxisOrientationRequirementAxisOrientationRequirement.axis_datumAxisOrientationRequirement.orientationAxisOrientationRequirement.referenceAxisOrientationRequirement.pointingAxisOrientationRequirement.axis_datumAxisOrientationRequirement.get_implied_constraints()AxisOrientationRequirement.orientationAxisOrientationRequirement.pointingAxisOrientationRequirement.reference
ClearanceClearanceResultConnectionConnection.parentConnection.childConnection.joint_typeConnection.axisConnection.limitsConnection.interface_typeConnection.interface_detailsConnection.axisConnection.childConnection.get_child_datum()Connection.get_child_part()Connection.get_parent_datum()Connection.get_parent_part()Connection.interface_detailsConnection.interface_typeConnection.joint_typeConnection.limitsConnection.parentConnection.to_mate_spec()
ContactRequirementContactRequirement.surfaceContactRequirement.targetContactRequirement.contact_typeContactRequirement.preload_sourceContactRequirement.contact_typeContactRequirement.get_derived_parameters()ContactRequirement.get_implied_constraints()ContactRequirement.preload_sourceContactRequirement.surfaceContactRequirement.target
FunctionalRequirementFunctionalRequirement.nameFunctionalRequirement.partFunctionalRequirement.descriptionFunctionalRequirement.priorityFunctionalRequirement.descriptionFunctionalRequirement.get_derived_parameters()FunctionalRequirement.get_implied_constraints()FunctionalRequirement.nameFunctionalRequirement.partFunctionalRequirement.priority
GeometryTypeParallelAxesRequirementReachRequirementReferenceGeometryReferenceGeometry.nameReferenceGeometry.geometry_typeReferenceGeometry.centerReferenceGeometry.axisReferenceGeometry.radiusReferenceGeometry.normalReferenceGeometry.innerReferenceGeometry.axisReferenceGeometry.centerReferenceGeometry.geometry_typeReferenceGeometry.get_normal_at()ReferenceGeometry.get_surface_point()ReferenceGeometry.innerReferenceGeometry.nameReferenceGeometry.normalReferenceGeometry.radius
RollRequirementSolveResultSolveResult.successSolveResult.derivedSolveResult.transformsSolveResult.constraints_generatedSolveResult.validationSolveResult.errorsSolveResult.warningsSolveResult.constraints_generatedSolveResult.derivedSolveResult.errorsSolveResult.report()SolveResult.successSolveResult.transformsSolveResult.validationSolveResult.warnings
create_scara_arm_intent()create_wheel_assembly_intent()
- yapcad.assembly.kinematic_integration module
AssemblyValidatorConstraintEvaluationResultConstraintEvaluationResult.satisfiedConstraintEvaluationResult.errorConstraintEvaluationResult.error_vectorConstraintEvaluationResult.error_messageConstraintEvaluationResult.detailsConstraintEvaluationResult.detailsConstraintEvaluationResult.errorConstraintEvaluationResult.error_messageConstraintEvaluationResult.error_vectorConstraintEvaluationResult.satisfied
KinematicConstraintKinematicConstraint.nameKinematicConstraint.constraint_typeKinematicConstraint.frame_aKinematicConstraint.frame_bKinematicConstraint.face_aKinematicConstraint.face_bKinematicConstraint.axis_aKinematicConstraint.axis_bKinematicConstraint.reference_centerKinematicConstraint.reference_radiusKinematicConstraint.reference_axisKinematicConstraint.reference_normalKinematicConstraint.pattern_countKinematicConstraint.pattern_radiusKinematicConstraint.pattern_offset_degKinematicConstraint.tolerance_mmKinematicConstraint.tolerance_degKinematicConstraint.descriptionKinematicConstraint.severityKinematicConstraint.validatorKinematicConstraint.axis_aKinematicConstraint.axis_bKinematicConstraint.bounds_aKinematicConstraint.bounds_bKinematicConstraint.constraint_typeKinematicConstraint.descriptionKinematicConstraint.evaluate()KinematicConstraint.face_aKinematicConstraint.face_bKinematicConstraint.frame_aKinematicConstraint.frame_bKinematicConstraint.nameKinematicConstraint.pattern_countKinematicConstraint.pattern_offset_degKinematicConstraint.pattern_radiusKinematicConstraint.reference_axisKinematicConstraint.reference_centerKinematicConstraint.reference_normalKinematicConstraint.reference_radiusKinematicConstraint.severityKinematicConstraint.stl_path_aKinematicConstraint.stl_path_bKinematicConstraint.tolerance_degKinematicConstraint.tolerance_mmKinematicConstraint.validator
KinematicConstraintTypeKinematicConstraintType.AT_DISTANCEKinematicConstraintType.BOLT_PATTERNKinematicConstraintType.COINCIDENTKinematicConstraintType.CONCENTRICKinematicConstraintType.CUSTOMKinematicConstraintType.MIN_DISTANCEKinematicConstraintType.NO_OVERLAPKinematicConstraintType.PARALLELKinematicConstraintType.PERPENDICULARKinematicConstraintType.TANGENTKinematicConstraintType.Z_STACK_CLEARANCE
MeshCollisionResultMeshCollisionResult.collidesMeshCollisionResult.penetration_depthMeshCollisionResult.collision_volumeMeshCollisionResult.contact_pointsMeshCollisionResult.error_messageMeshCollisionResult.collidesMeshCollisionResult.collision_volumeMeshCollisionResult.contact_pointsMeshCollisionResult.error_messageMeshCollisionResult.penetration_depth
ValidationReportValidationReport.is_validValidationReport.total_constraintsValidationReport.passed_countValidationReport.failed_countValidationReport.warning_countValidationReport.constraint_resultsValidationReport.failed_constraintsValidationReport.warningsValidationReport.infoValidationReport.constraint_resultsValidationReport.detailed_report()ValidationReport.failed_constraintsValidationReport.failed_countValidationReport.infoValidationReport.is_validValidationReport.passed_countValidationReport.total_constraintsValidationReport.warning_countValidationReport.warnings
check_mesh_collision()create_coincident_constraint()create_face_coincident_constraint()create_face_distance_constraint()create_mesh_collision_constraint()create_min_distance_constraint()create_no_overlap_constraint()create_parallel_constraint()create_tangent_constraint()create_z_stack_clearance_constraint()validate_assembly()
- yapcad.assembly.mate module
CoincidentResultMateMate.nameMate.mate_typeMate.part_aMate.datum_aMate.part_bMate.datum_bMate.offsetMate.angleMate.axisMate.secondary_axisMate.limitsMate.dynamicsMate.coupling_ratioMate.coupling_offsetMate.coupling_reverseMate.coupling_pitchMate.metadataMate.angleMate.axisMate.compute_coupled_motion()Mate.coupling_offsetMate.coupling_pitchMate.coupling_ratioMate.coupling_reverseMate.datum1Mate.datum2Mate.datum_aMate.datum_bMate.degrees_of_freedom()Mate.dynamicsMate.evaluate()Mate.from_dict()Mate.is_coupled()Mate.limitsMate.mate_typeMate.metadataMate.nameMate.offsetMate.part1Mate.part2Mate.part_aMate.part_bMate.secondary_axisMate.to_dict()Mate.validate()
MateDynamicsMateDynamics.friction_staticMateDynamics.friction_kineticMateDynamics.friction_viscousMateDynamics.dampingMateDynamics.stiffnessMateDynamics.rest_positionMateDynamics.dampingMateDynamics.friction_kineticMateDynamics.friction_staticMateDynamics.friction_viscousMateDynamics.rest_positionMateDynamics.stiffness
MateLimitsMateLimits.min_valueMateLimits.max_valueMateLimits.min_velocityMateLimits.max_velocityMateLimits.min_effortMateLimits.max_effortMateLimits.min_secondaryMateLimits.max_secondaryMateLimits.limit_stiffnessMateLimits.limit_dampingMateLimits.restitutionMateLimits.limit_dampingMateLimits.limit_stiffnessMateLimits.max_effortMateLimits.max_secondaryMateLimits.max_valueMateLimits.max_velocityMateLimits.min_effortMateLimits.min_secondaryMateLimits.min_valueMateLimits.min_velocityMateLimits.restitution
MateTypeMateType.ANGLEMateType.CAMMateType.COINCIDENTMateType.CONCENTRICMateType.CYLINDRICALMateType.DISTANCEMateType.GEARMateType.PARALLELMateType.PERPENDICULARMateType.PIN_SLOTMateType.PLANARMateType.PRISMATICMateType.RACK_PINIONMateType.REVOLUTEMateType.RIGIDMateType.SCREWMateType.SLOTMateType.SPHERICALMateType.TANGENTMateType.UNIVERSAL
check_bolt_circle_alignment()create_coincident_mate()create_gear_mate()create_prismatic_mate()create_revolute_mate()evaluate_coincident()
- yapcad.assembly.mate_examples module
- yapcad.assembly.mate_surrogates module
- PROBLEM STATEMENT
- SOLUTION: MATE SURROGATES
- EXISTING GEOMETRY ANALYSIS
- CONCLUSION
FeatureFeature.nameFeature.feature_typeFeature.pointFeature.directionFeature.radiusFeature.countFeature.angle_offset_degFeature.verticesFeature.heightFeature.descriptionFeature.angle_offset_degFeature.countFeature.descriptionFeature.directionFeature.feature_typeFeature.get_hole_positions()Feature.heightFeature.nameFeature.pointFeature.radiusFeature.vertices
FeatureTypeMateSurrogateMateSurrogate.part_nameMateSurrogate.descriptionMateSurrogate.originMateSurrogate.x_axisMateSurrogate.y_axisMateSurrogate.z_axisMateSurrogate.featuresMateSurrogate.stl_fileMateSurrogate.step_fileMateSurrogate.notesMateSurrogate.add_feature()MateSurrogate.descriptionMateSurrogate.featuresMateSurrogate.get_feature()MateSurrogate.get_transform_to_standard_frame()MateSurrogate.notesMateSurrogate.originMateSurrogate.part_nameMateSurrogate.step_fileMateSurrogate.stl_fileMateSurrogate.x_axisMateSurrogate.y_axisMateSurrogate.z_axis
create_ddsm115_surrogate()create_sun_gear_surrogate()create_xh430_surrogate()create_xh540_surrogate()create_xl330_surrogate()get_all_surrogates()print_surrogate_summary()validate_surrogates()
- yapcad.assembly.solver module
- OVERVIEW
MateConstraintSolverMateMateSolveResultValidationResultValidationResult.validValidationResult.is_rigidValidationResult.is_orthonormalValidationResult.position_errorValidationResult.orientation_errorValidationResult.error_messagesValidationResult.error_messagesValidationResult.is_orthonormalValidationResult.is_rigidValidationResult.orientation_errorValidationResult.position_errorValidationResult.valid
apply_mate_axis_rotation()solve_mate_chain()
- Module contents
AssemblyAssembly.nameAssembly.partsAssembly.transformsAssembly.matesAssembly.constraintsAssembly.add_constraint()Assembly.add_mate()Assembly.add_part()Assembly.constraintsAssembly.export_to_blender_rig()Assembly.export_to_urdf()Assembly.get_degrees_of_freedom()Assembly.get_transformed_datum()Assembly.import_transforms_from_kinematic_chain()Assembly.matesAssembly.partsAssembly.report()Assembly.transformsAssembly.validate()Assembly.validate_and_raise()
AssemblyErrorAssemblyIntentAssemblyIntent.nameAssemblyIntent.descriptionAssemblyIntent.functional_requirementsAssemblyIntent.connectionsAssemblyIntent.clearancesAssemblyIntent.reference_geometryAssemblyIntent.part_definitionsAssemblyIntent.derived_parametersAssemblyIntent.explicit_constraintsAssemblyIntent.add_clearance()AssemblyIntent.add_connection()AssemblyIntent.add_reference_geometry()AssemblyIntent.add_requirement()AssemblyIntent.clearancesAssemblyIntent.collect_constraints()AssemblyIntent.collect_derived_parameters()AssemblyIntent.connectionsAssemblyIntent.derived_parametersAssemblyIntent.descriptionAssemblyIntent.explicit_constraintsAssemblyIntent.functional_requirementsAssemblyIntent.nameAssemblyIntent.part_definitionsAssemblyIntent.reference_geometryAssemblyIntent.report()AssemblyIntent.solve()AssemblyIntent.to_assembly()AssemblyIntent.validate()
AssemblyValidationResultAssemblyValidationResult.is_validAssemblyValidationResult.constraint_resultsAssemblyValidationResult.failed_constraintsAssemblyValidationResult.warningsAssemblyValidationResult.constraint_resultsAssemblyValidationResult.failed_constraintsAssemblyValidationResult.is_validAssemblyValidationResult.report()AssemblyValidationResult.warnings
AssemblyValidatorAxisOrientationRequirementAxisOrientationRequirement.axis_datumAxisOrientationRequirement.orientationAxisOrientationRequirement.referenceAxisOrientationRequirement.pointingAxisOrientationRequirement.axis_datumAxisOrientationRequirement.get_implied_constraints()AxisOrientationRequirement.orientationAxisOrientationRequirement.pointingAxisOrientationRequirement.reference
ClearanceClearanceResultCoincidentResultConnectionConnection.parentConnection.childConnection.joint_typeConnection.axisConnection.limitsConnection.interface_typeConnection.interface_detailsConnection.axisConnection.childConnection.get_child_datum()Connection.get_child_part()Connection.get_parent_datum()Connection.get_parent_part()Connection.interface_detailsConnection.interface_typeConnection.joint_typeConnection.limitsConnection.parentConnection.to_mate_spec()
ConstraintConstraint.nameConstraint.constraint_typeConstraint.partConstraint.datumConstraint.centerConstraint.radiusConstraint.directionConstraint.axisConstraint.reference_datumConstraint.plane_normalConstraint.min_valueConstraint.max_valueConstraint.validatorConstraint.tolerance_degConstraint.tolerance_mmConstraint.descriptionConstraint.severityConstraint.axisConstraint.centerConstraint.constraint_typeConstraint.datumConstraint.descriptionConstraint.directionConstraint.evaluate()Constraint.max_valueConstraint.min_valueConstraint.nameConstraint.partConstraint.plane_normalConstraint.radiusConstraint.reference_datumConstraint.severityConstraint.tolerance_degConstraint.tolerance_mmConstraint.validator
ConstraintEvaluationResultConstraintEvaluationResult.satisfiedConstraintEvaluationResult.errorConstraintEvaluationResult.error_vectorConstraintEvaluationResult.error_messageConstraintEvaluationResult.detailsConstraintEvaluationResult.detailsConstraintEvaluationResult.errorConstraintEvaluationResult.error_messageConstraintEvaluationResult.error_vectorConstraintEvaluationResult.satisfied
ConstraintResultConstraintTypeConstraintType.TANGENT_TO_CIRCLEConstraintType.RADIAL_FROM_CENTERConstraintType.FACINGConstraintType.AT_RADIUSConstraintType.PARALLEL_TOConstraintType.PERPENDICULAR_TOConstraintType.AT_RADIUSConstraintType.CUSTOMConstraintType.FACINGConstraintType.IN_PLANEConstraintType.MIN_DISTANCEConstraintType.NO_INTERFERENCEConstraintType.ON_CIRCLEConstraintType.PARALLEL_TOConstraintType.PERPENDICULAR_TOConstraintType.RADIAL_FROM_CENTERConstraintType.TANGENT_TO_CIRCLE
ContactRequirementContactRequirement.surfaceContactRequirement.targetContactRequirement.contact_typeContactRequirement.preload_sourceContactRequirement.contact_typeContactRequirement.get_derived_parameters()ContactRequirement.get_implied_constraints()ContactRequirement.preload_sourceContactRequirement.surfaceContactRequirement.target
DatumDatumRegistryDatumSourceDatumTypeFaceToFaceMateFaceToFaceMate.nameFaceToFaceMate.parent_partFaceToFaceMate.parent_datumFaceToFaceMate.parent_sourceFaceToFaceMate.child_partFaceToFaceMate.child_datumFaceToFaceMate.child_sourceFaceToFaceMate.constraintFaceToFaceMate.offset_distanceFaceToFaceMate.rotation_about_normalFaceToFaceMate.child_datumFaceToFaceMate.child_partFaceToFaceMate.child_sourceFaceToFaceMate.compute_transform()FaceToFaceMate.constraintFaceToFaceMate.invalidate_cache()FaceToFaceMate.nameFaceToFaceMate.offset_distanceFaceToFaceMate.parent_datumFaceToFaceMate.parent_partFaceToFaceMate.parent_sourceFaceToFaceMate.rotation_about_normalFaceToFaceMate.validate()
FunctionalRequirementFunctionalRequirement.nameFunctionalRequirement.partFunctionalRequirement.descriptionFunctionalRequirement.priorityFunctionalRequirement.descriptionFunctionalRequirement.get_derived_parameters()FunctionalRequirement.get_implied_constraints()FunctionalRequirement.nameFunctionalRequirement.partFunctionalRequirement.priority
GeometryTypeKinematicConstraintKinematicConstraint.nameKinematicConstraint.constraint_typeKinematicConstraint.frame_aKinematicConstraint.frame_bKinematicConstraint.face_aKinematicConstraint.face_bKinematicConstraint.axis_aKinematicConstraint.axis_bKinematicConstraint.reference_centerKinematicConstraint.reference_radiusKinematicConstraint.reference_axisKinematicConstraint.reference_normalKinematicConstraint.pattern_countKinematicConstraint.pattern_radiusKinematicConstraint.pattern_offset_degKinematicConstraint.tolerance_mmKinematicConstraint.tolerance_degKinematicConstraint.descriptionKinematicConstraint.severityKinematicConstraint.validatorKinematicConstraint.axis_aKinematicConstraint.axis_bKinematicConstraint.bounds_aKinematicConstraint.bounds_bKinematicConstraint.constraint_typeKinematicConstraint.descriptionKinematicConstraint.evaluate()KinematicConstraint.face_aKinematicConstraint.face_bKinematicConstraint.frame_aKinematicConstraint.frame_bKinematicConstraint.nameKinematicConstraint.pattern_countKinematicConstraint.pattern_offset_degKinematicConstraint.pattern_radiusKinematicConstraint.reference_axisKinematicConstraint.reference_centerKinematicConstraint.reference_normalKinematicConstraint.reference_radiusKinematicConstraint.severityKinematicConstraint.stl_path_aKinematicConstraint.stl_path_bKinematicConstraint.tolerance_degKinematicConstraint.tolerance_mmKinematicConstraint.validator
KinematicConstraintTypeKinematicConstraintType.AT_DISTANCEKinematicConstraintType.BOLT_PATTERNKinematicConstraintType.COINCIDENTKinematicConstraintType.CONCENTRICKinematicConstraintType.CUSTOMKinematicConstraintType.MIN_DISTANCEKinematicConstraintType.NO_OVERLAPKinematicConstraintType.PARALLELKinematicConstraintType.PERPENDICULARKinematicConstraintType.TANGENTKinematicConstraintType.Z_STACK_CLEARANCE
MateMate.nameMate.mate_typeMate.part_aMate.datum_aMate.part_bMate.datum_bMate.offsetMate.angleMate.axisMate.secondary_axisMate.limitsMate.dynamicsMate.coupling_ratioMate.coupling_offsetMate.coupling_reverseMate.coupling_pitchMate.metadataMate.angleMate.axisMate.compute_coupled_motion()Mate.coupling_offsetMate.coupling_pitchMate.coupling_ratioMate.coupling_reverseMate.datum1Mate.datum2Mate.datum_aMate.datum_bMate.degrees_of_freedom()Mate.dynamicsMate.evaluate()Mate.from_dict()Mate.is_coupled()Mate.limitsMate.mate_typeMate.metadataMate.nameMate.offsetMate.part1Mate.part2Mate.part_aMate.part_bMate.secondary_axisMate.to_dict()Mate.validate()
MateDynamicsMateDynamics.friction_staticMateDynamics.friction_kineticMateDynamics.friction_viscousMateDynamics.dampingMateDynamics.stiffnessMateDynamics.rest_positionMateDynamics.dampingMateDynamics.friction_kineticMateDynamics.friction_staticMateDynamics.friction_viscousMateDynamics.rest_positionMateDynamics.stiffness
MateLimitsMateLimits.min_valueMateLimits.max_valueMateLimits.min_velocityMateLimits.max_velocityMateLimits.min_effortMateLimits.max_effortMateLimits.min_secondaryMateLimits.max_secondaryMateLimits.limit_stiffnessMateLimits.limit_dampingMateLimits.restitutionMateLimits.limit_dampingMateLimits.limit_stiffnessMateLimits.max_effortMateLimits.max_secondaryMateLimits.max_valueMateLimits.max_velocityMateLimits.min_effortMateLimits.min_secondaryMateLimits.min_valueMateLimits.min_velocityMateLimits.restitution
MateTypeMateType.ANGLEMateType.CAMMateType.COINCIDENTMateType.CONCENTRICMateType.CYLINDRICALMateType.DISTANCEMateType.GEARMateType.PARALLELMateType.PERPENDICULARMateType.PIN_SLOTMateType.PLANARMateType.PRISMATICMateType.RACK_PINIONMateType.REVOLUTEMateType.RIGIDMateType.SCREWMateType.SLOTMateType.SPHERICALMateType.TANGENTMateType.UNIVERSAL
MateValidationResultMateValidationResult.satisfiedMateValidationResult.error_distanceMateValidationResult.error_angleMateValidationResult.error_messageMateValidationResult.detailsMateValidationResult.detailsMateValidationResult.error_angleMateValidationResult.error_distanceMateValidationResult.error_messageMateValidationResult.satisfied
ParallelAxesRequirementPartDefinitionPartDefinition.namePartDefinition.datumsPartDefinition.geometry_sourcePartDefinition.is_printablePartDefinition.materialPartDefinition.descriptionPartDefinition.add_datum()PartDefinition.datumsPartDefinition.descriptionPartDefinition.geometry_sourcePartDefinition.get_datum()PartDefinition.is_printablePartDefinition.materialPartDefinition.namePartDefinition.validate_datums()
ReachRequirementReferenceGeometryReferenceGeometry.nameReferenceGeometry.geometry_typeReferenceGeometry.centerReferenceGeometry.axisReferenceGeometry.radiusReferenceGeometry.normalReferenceGeometry.innerReferenceGeometry.axisReferenceGeometry.centerReferenceGeometry.geometry_typeReferenceGeometry.get_normal_at()ReferenceGeometry.get_surface_point()ReferenceGeometry.innerReferenceGeometry.nameReferenceGeometry.normalReferenceGeometry.radius
RollRequirementSolveResultSolveResult.successSolveResult.derivedSolveResult.transformsSolveResult.constraints_generatedSolveResult.validationSolveResult.errorsSolveResult.warningsSolveResult.constraints_generatedSolveResult.derivedSolveResult.errorsSolveResult.report()SolveResult.successSolveResult.transformsSolveResult.validationSolveResult.warnings
ValidationReportValidationReport.is_validValidationReport.total_constraintsValidationReport.passed_countValidationReport.failed_countValidationReport.warning_countValidationReport.constraint_resultsValidationReport.failed_constraintsValidationReport.warningsValidationReport.infoValidationReport.constraint_resultsValidationReport.detailed_report()ValidationReport.failed_constraintsValidationReport.failed_countValidationReport.infoValidationReport.is_validValidationReport.passed_countValidationReport.total_constraintsValidationReport.warning_countValidationReport.warnings
angle_between_vectors()check_bolt_circle_alignment()compute_concentric_transform()compute_flush_transform()compute_parallel_transform()create_axis_mate()create_coincident_constraint()create_coincident_mate()create_face_mate()create_gear_mate()create_min_distance_constraint()create_no_overlap_constraint()create_parallel_constraint()create_prismatic_mate()create_revolute_mate()create_scara_arm_intent()create_tangent_constraint()create_wheel_assembly_intent()create_z_stack_clearance_constraint()datum_to_transform_matrix()distance_to_point()dot_product()evaluate_coincident()is_radial_from_center()is_tangent_to_circle()validate_assembly()
- yapcad.boolean package
- yapcad.collision package
- Submodules
- yapcad.collision.detector module
CollisionDetectorCollisionDetector.geometry_providerCollisionDetector.interface_registryCollisionDetector.verboseCollisionDetector.min_collision_volumeCollisionDetector.mesh_sample_pointsCollisionDetector.penetration_thresholdCollisionDetector.check_assembly()CollisionDetector.check_collision()CollisionDetector.clear_cache()CollisionDetector.get_collision_summary()CollisionDetector.preferred_methodCollisionDetector.set_interface_registry()
GeometryProvider
- yapcad.collision.gear_interface module
GearMeshInterfaceGearMeshInterface.moduleGearMeshInterface.teethGearMeshInterface.pressure_angleGearMeshInterface.face_widthGearMeshInterface.helix_angleGearMeshInterface.backlashGearMeshInterface.addendumGearMeshInterface.backlashGearMeshInterface.base_diameterGearMeshInterface.check_compatibility()GearMeshInterface.dedendumGearMeshInterface.face_widthGearMeshInterface.get_bounding_cylinder()GearMeshInterface.get_center_distance()GearMeshInterface.get_engagement_depth()GearMeshInterface.get_expected_overlap_volume()GearMeshInterface.get_mesh_overlap_depth()GearMeshInterface.helix_angleGearMeshInterface.interface_typeGearMeshInterface.moduleGearMeshInterface.outside_diameterGearMeshInterface.pitch_diameterGearMeshInterface.pressure_angleGearMeshInterface.root_diameterGearMeshInterface.teethGearMeshInterface.to_dict()
check_gear_mesh_collision()create_planetary_gearbox_interfaces()
- yapcad.collision.interface module
CompatibilityResultCompatibilityResult.is_compatibleCompatibilityResult.reasonCompatibilityResult.warningsCompatibilityResult.overlap_volumeCompatibilityResult.required_clearanceCompatibilityResult.is_compatibleCompatibilityResult.overlap_volumeCompatibilityResult.reasonCompatibilityResult.required_clearanceCompatibilityResult.warnings
InterfaceTypeInterfaceType.GEAR_MESHInterfaceType.THREADInterfaceType.PRESS_FITInterfaceType.BEARINGInterfaceType.SPLINEInterfaceType.KEYInterfaceType.SNAP_FITInterfaceType.CUSTOMInterfaceType.BEARINGInterfaceType.CUSTOMInterfaceType.GEAR_MESHInterfaceType.KEYInterfaceType.PRESS_FITInterfaceType.SNAP_FITInterfaceType.SPLINEInterfaceType.THREAD
InterfaceVolumeInterfaceVolume.nameInterfaceVolume.part_nameInterfaceVolume.interface_typeInterfaceVolume.centerInterfaceVolume.axisInterfaceVolume.descriptionInterfaceVolume.metadataInterfaceVolume.axisInterfaceVolume.centerInterfaceVolume.check_compatibility()InterfaceVolume.descriptionInterfaceVolume.get_bounding_cylinder()InterfaceVolume.get_engagement_depth()InterfaceVolume.interface_typeInterfaceVolume.metadataInterfaceVolume.nameInterfaceVolume.overlaps_with()InterfaceVolume.part_nameInterfaceVolume.to_dict()InterfaceVolume.transform_axis()InterfaceVolume.transform_center()
- yapcad.collision.registry module
InterfaceRegistryInterfaceRegistry.check_overlap_compatibility()InterfaceRegistry.clear()InterfaceRegistry.find_compatible_interfaces()InterfaceRegistry.get()InterfaceRegistry.get_all_interfaces()InterfaceRegistry.get_all_parts()InterfaceRegistry.get_compatible_interface_names()InterfaceRegistry.get_interfaces_by_type()InterfaceRegistry.get_interfaces_for_part()InterfaceRegistry.has_interfaces()InterfaceRegistry.register()InterfaceRegistry.register_many()InterfaceRegistry.to_dict()InterfaceRegistry.unregister()
- yapcad.collision.result module
CollisionMethodCollisionResultCollisionResult.part_aCollisionResult.part_bCollisionResult.collidesCollisionResult.methodCollisionResult.intersection_volumeCollisionResult.penetration_depthCollisionResult.contact_pointsCollisionResult.compatible_interfaceCollisionResult.interface_namesCollisionResult.error_messageCollisionResult.metadataCollisionResult.collidesCollisionResult.compatible_interfaceCollisionResult.contact_pointsCollisionResult.error()CollisionResult.error_messageCollisionResult.from_dict()CollisionResult.interface_namesCollisionResult.intersection_volumeCollisionResult.is_errorCollisionResult.is_interface_overlapCollisionResult.metadataCollisionResult.methodCollisionResult.no_collision()CollisionResult.pair_keyCollisionResult.part_aCollisionResult.part_bCollisionResult.penetration_depthCollisionResult.to_dict()
- yapcad.collision.thread_interface module
ThreadClassThreadInterfaceThreadInterface.pitchThreadInterface.major_diameterThreadInterface.thread_typeThreadInterface.thread_classThreadInterface.engagement_lengthThreadInterface.is_internalThreadInterface.check_compatibility()ThreadInterface.engagement_lengthThreadInterface.from_metric_size()ThreadInterface.get_bounding_cylinder()ThreadInterface.get_engagement_depth()ThreadInterface.interface_typeThreadInterface.is_internalThreadInterface.major_diameterThreadInterface.minor_diameterThreadInterface.pitchThreadInterface.pitch_diameterThreadInterface.thread_classThreadInterface.thread_depthThreadInterface.thread_typeThreadInterface.to_dict()
ThreadTypecreate_bolt_pattern_interfaces()
- Module contents
CollisionDetectorCollisionDetector.geometry_providerCollisionDetector.interface_registryCollisionDetector.verboseCollisionDetector.min_collision_volumeCollisionDetector.mesh_sample_pointsCollisionDetector.penetration_thresholdCollisionDetector.check_assembly()CollisionDetector.check_collision()CollisionDetector.clear_cache()CollisionDetector.get_collision_summary()CollisionDetector.preferred_methodCollisionDetector.set_interface_registry()
CollisionMethodCollisionResultCollisionResult.part_aCollisionResult.part_bCollisionResult.collidesCollisionResult.methodCollisionResult.intersection_volumeCollisionResult.penetration_depthCollisionResult.contact_pointsCollisionResult.compatible_interfaceCollisionResult.interface_namesCollisionResult.error_messageCollisionResult.metadataCollisionResult.collidesCollisionResult.compatible_interfaceCollisionResult.contact_pointsCollisionResult.error()CollisionResult.error_messageCollisionResult.from_dict()CollisionResult.interface_namesCollisionResult.intersection_volumeCollisionResult.is_errorCollisionResult.is_interface_overlapCollisionResult.metadataCollisionResult.methodCollisionResult.no_collision()CollisionResult.pair_keyCollisionResult.part_aCollisionResult.part_bCollisionResult.penetration_depthCollisionResult.to_dict()
CompatibilityResultCompatibilityResult.is_compatibleCompatibilityResult.reasonCompatibilityResult.warningsCompatibilityResult.overlap_volumeCompatibilityResult.required_clearanceCompatibilityResult.is_compatibleCompatibilityResult.overlap_volumeCompatibilityResult.reasonCompatibilityResult.required_clearanceCompatibilityResult.warnings
GearMeshInterfaceGearMeshInterface.moduleGearMeshInterface.teethGearMeshInterface.pressure_angleGearMeshInterface.face_widthGearMeshInterface.helix_angleGearMeshInterface.backlashGearMeshInterface.addendumGearMeshInterface.backlashGearMeshInterface.base_diameterGearMeshInterface.check_compatibility()GearMeshInterface.dedendumGearMeshInterface.face_widthGearMeshInterface.get_bounding_cylinder()GearMeshInterface.get_center_distance()GearMeshInterface.get_engagement_depth()GearMeshInterface.get_expected_overlap_volume()GearMeshInterface.get_mesh_overlap_depth()GearMeshInterface.helix_angleGearMeshInterface.interface_typeGearMeshInterface.moduleGearMeshInterface.outside_diameterGearMeshInterface.pitch_diameterGearMeshInterface.pressure_angleGearMeshInterface.root_diameterGearMeshInterface.teethGearMeshInterface.to_dict()
GeometryProviderInterfaceRegistryInterfaceRegistry.check_overlap_compatibility()InterfaceRegistry.clear()InterfaceRegistry.find_compatible_interfaces()InterfaceRegistry.get()InterfaceRegistry.get_all_interfaces()InterfaceRegistry.get_all_parts()InterfaceRegistry.get_compatible_interface_names()InterfaceRegistry.get_interfaces_by_type()InterfaceRegistry.get_interfaces_for_part()InterfaceRegistry.has_interfaces()InterfaceRegistry.register()InterfaceRegistry.register_many()InterfaceRegistry.to_dict()InterfaceRegistry.unregister()
InterfaceTypeInterfaceType.GEAR_MESHInterfaceType.THREADInterfaceType.PRESS_FITInterfaceType.BEARINGInterfaceType.SPLINEInterfaceType.KEYInterfaceType.SNAP_FITInterfaceType.CUSTOMInterfaceType.BEARINGInterfaceType.CUSTOMInterfaceType.GEAR_MESHInterfaceType.KEYInterfaceType.PRESS_FITInterfaceType.SNAP_FITInterfaceType.SPLINEInterfaceType.THREAD
InterfaceVolumeInterfaceVolume.nameInterfaceVolume.part_nameInterfaceVolume.interface_typeInterfaceVolume.centerInterfaceVolume.axisInterfaceVolume.descriptionInterfaceVolume.metadataInterfaceVolume.axisInterfaceVolume.centerInterfaceVolume.check_compatibility()InterfaceVolume.descriptionInterfaceVolume.get_bounding_cylinder()InterfaceVolume.get_engagement_depth()InterfaceVolume.interface_typeInterfaceVolume.metadataInterfaceVolume.nameInterfaceVolume.overlaps_with()InterfaceVolume.part_nameInterfaceVolume.to_dict()InterfaceVolume.transform_axis()InterfaceVolume.transform_center()
ThreadClassThreadInterfaceThreadInterface.pitchThreadInterface.major_diameterThreadInterface.thread_typeThreadInterface.thread_classThreadInterface.engagement_lengthThreadInterface.is_internalThreadInterface.check_compatibility()ThreadInterface.engagement_lengthThreadInterface.from_metric_size()ThreadInterface.get_bounding_cylinder()ThreadInterface.get_engagement_depth()ThreadInterface.interface_typeThreadInterface.is_internalThreadInterface.major_diameterThreadInterface.minor_diameterThreadInterface.pitchThreadInterface.pitch_diameterThreadInterface.thread_classThreadInterface.thread_depthThreadInterface.thread_typeThreadInterface.to_dict()
ThreadTypecheck_gear_mesh_collision()create_planetary_gearbox_interfaces()
- yapcad.contrib package
- yapcad.dsl package
- Subpackages
- Submodules
- yapcad.dsl.ast module
AssertStatementAssignmentStatementAstNodeAstVisitorBinaryOpBlockCommandComprehensionClauseConditionalExprDecoratorDictLiteralElifBranchEmitStatementExportStatementExportUseStatementExpressionExpressionStatementForStatementFunctionCallFunctionDefGenericTypeIdentifierIdentifierPatternIfExprIfStatementIndexAccessLambdaExprLetStatementListComprehensionListLiteralLiteralLiteralPatternMatchArmMatchExprMemberAccessMethodCallModuleNativeBlockNativeFunctionNativeFunctionDeclOptionalTypeParameterPassStatementPatternPrintVisitorPythonBlockPythonExprRangeExprRequireStatementReturnStatementSimpleTypeStatementTypeNodeUnaryOpUseStatementVarDeclWhileStatementWildcardPatternprint_ast()
- yapcad.dsl.checker module
- yapcad.dsl.errors module
DiagnosticDiagnosticCollectorDiagnosticCollector.add()DiagnosticCollector.add_error()DiagnosticCollector.diagnosticsDiagnosticCollector.error_countDiagnosticCollector.format_all()DiagnosticCollector.has_errorsDiagnosticCollector.has_warningsDiagnosticCollector.should_stopDiagnosticCollector.to_json()DiagnosticCollector.warning_count
DslErrorErrorSeverityLexerErrorParserErrorSemanticErrorTypeErrorerror_invalid_binary_literal()error_invalid_escape_sequence()error_invalid_expression()error_invalid_hex_literal()error_invalid_number_literal()error_require_failed()error_type_mismatch()error_undefined_identifier()error_unexpected_character()error_unexpected_eof()error_unexpected_token()error_unterminated_comment()error_unterminated_multiline_string()error_unterminated_string()warning_python_block()
- yapcad.dsl.introspection module
- yapcad.dsl.lexer module
- yapcad.dsl.packaging module
- yapcad.dsl.parser module
- yapcad.dsl.symbols module
- yapcad.dsl.tokens module
SourceLocationSourceSpanTokenTokenTypeTokenType.ANDTokenType.ARROWTokenType.ASTokenType.ASSERTTokenType.ASSIGNTokenType.ATTokenType.BOOL_LITERALTokenType.CLOSETokenType.CLOSE_C0TokenType.CLOSE_C1TokenType.COLONTokenType.COMMATokenType.COMMANDTokenType.DEDENTTokenType.DEFTokenType.DOTTokenType.DOUBLE_ARROWTokenType.DOUBLE_SLASHTokenType.DOUBLE_STARTokenType.ELIFTokenType.ELSETokenType.EMITTokenType.EOFTokenType.EQTokenType.EXPORTTokenType.EXPORTSTokenType.FLOAT_LITERALTokenType.FNTokenType.FORTokenType.GETokenType.GTTokenType.HASHTokenType.IDENTIFIERTokenType.IFTokenType.INTokenType.INDENTTokenType.INT_LITERALTokenType.LBRACETokenType.LBRACKETTokenType.LETokenType.LETTokenType.LPARENTokenType.LTTokenType.MATCHTokenType.MINUSTokenType.MINUS_ASSIGNTokenType.MODULETokenType.NATIVETokenType.NATIVE_BLOCKTokenType.NETokenType.NEWLINETokenType.NOTTokenType.ORTokenType.PASSTokenType.PERCENTTokenType.PLUSTokenType.PLUS_ASSIGNTokenType.PYTHONTokenType.QUESTIONTokenType.RANGETokenType.RBRACETokenType.RBRACKETTokenType.REQUIRETokenType.RETURNTokenType.RPARENTokenType.SEMICOLONTokenType.SLASHTokenType.STARTokenType.STRING_LITERALTokenType.TYPE_ARCTokenType.TYPE_BEZIERTokenType.TYPE_BOOLTokenType.TYPE_CATMULLROMTokenType.TYPE_CIRCLETokenType.TYPE_DICTTokenType.TYPE_ELLIPSETokenType.TYPE_FLOATTokenType.TYPE_HYPERBOLATokenType.TYPE_INTTokenType.TYPE_LINE_SEGMENTTokenType.TYPE_LISTTokenType.TYPE_LOOP3DTokenType.TYPE_NURBSTokenType.TYPE_PARABOLATokenType.TYPE_PATH2DTokenType.TYPE_PATH3DTokenType.TYPE_POINTTokenType.TYPE_POINT2DTokenType.TYPE_POINT3DTokenType.TYPE_PROFILE2DTokenType.TYPE_REGION2DTokenType.TYPE_SHELLTokenType.TYPE_SOLIDTokenType.TYPE_STRINGTokenType.TYPE_SURFACETokenType.TYPE_TRANSFORMTokenType.TYPE_VECTORTokenType.TYPE_VECTOR2DTokenType.TYPE_VECTOR3DTokenType.UNDERSCORETokenType.USETokenType.WHILETokenType.WITH
get_deprecation_message()is_deprecated_keyword()is_type_token()
- yapcad.dsl.types module
CompoundCurveTypeCurveTypeDictTypeErrorTypeFunctionTypeGeometricPrimitiveTypeListTypeNoneTypeOptionalTypeWrapperPrimitiveTypeSolidTypeSurfaceTypeTypeTypeTierUnknownTypecommon_type()is_compound_curve()is_curve()is_geometric_primitive()is_geometry()is_numeric()is_solid()is_surface()make_list_type()make_optional_type()resolve_type_name()
- Module contents
AssignmentStatementAstNodeAstTransformAstVisitorBinaryOpBlockCheckResultCommandCompoundCurveTypeCurveTypeDiagnosticDiagnosticCollectorDiagnosticCollector.add()DiagnosticCollector.add_error()DiagnosticCollector.diagnosticsDiagnosticCollector.error_countDiagnosticCollector.format_all()DiagnosticCollector.has_errorsDiagnosticCollector.has_warningsDiagnosticCollector.should_stopDiagnosticCollector.to_json()DiagnosticCollector.warning_count
DictLiteralDictTypeDslErrorEmitResultEmitStatementErrorSeverityExecutionContextExecutionContext.add_error()ExecutionContext.add_require_failure()ExecutionContext.add_warning()ExecutionContext.clear_return()ExecutionContext.command_nameExecutionContext.current_scopeExecutionContext.diagnosticsExecutionContext.emit_resultExecutionContext.get_variable()ExecutionContext.has_errorsExecutionContext.has_warningsExecutionContext.module_nameExecutionContext.new_scope()ExecutionContext.parametersExecutionContext.require_failuresExecutionContext.return_valueExecutionContext.set_emit()ExecutionContext.set_variable()ExecutionContext.should_returnExecutionContext.signal_return()ExecutionContext.source_linesExecutionContext.update_variable()
ExecutionResultExportUseStatementExpressionExpressionStatementForStatementFunctionCallFunctionSignatureFunctionTypeGenericTypeGeometricPrimitiveTypeIdentifierIdentifierPatternIfExprIndexAccessInterpreterLambdaExprLetStatementLexerLexerErrorListComprehensionListLiteralListTypeLiteralLiteralPatternMatchArmMatchExprMemberAccessMethodCallModuleOptionalTypeOptionalTypeWrapperPackageResultParameterParserParserErrorPatternPrimitiveTypeProvenancePythonBlockPythonExprRangeExprRequireStatementReturnStatementScopeSemanticErrorSimpleTypeSolidTypeSourceLocationSourceSpanStatementSurfaceTypeSymbolSymbolKindSymbolTableTokenTokenTypeTokenType.ANDTokenType.ARROWTokenType.ASTokenType.ASSERTTokenType.ASSIGNTokenType.ATTokenType.BOOL_LITERALTokenType.CLOSETokenType.CLOSE_C0TokenType.CLOSE_C1TokenType.COLONTokenType.COMMATokenType.COMMANDTokenType.DEDENTTokenType.DEFTokenType.DOTTokenType.DOUBLE_ARROWTokenType.DOUBLE_SLASHTokenType.DOUBLE_STARTokenType.ELIFTokenType.ELSETokenType.EMITTokenType.EOFTokenType.EQTokenType.EXPORTTokenType.EXPORTSTokenType.FLOAT_LITERALTokenType.FNTokenType.FORTokenType.GETokenType.GTTokenType.HASHTokenType.IDENTIFIERTokenType.IFTokenType.INTokenType.INDENTTokenType.INT_LITERALTokenType.LBRACETokenType.LBRACKETTokenType.LETokenType.LETTokenType.LPARENTokenType.LTTokenType.MATCHTokenType.MINUSTokenType.MINUS_ASSIGNTokenType.MODULETokenType.NATIVETokenType.NATIVE_BLOCKTokenType.NETokenType.NEWLINETokenType.NOTTokenType.ORTokenType.PASSTokenType.PERCENTTokenType.PLUSTokenType.PLUS_ASSIGNTokenType.PYTHONTokenType.QUESTIONTokenType.RANGETokenType.RBRACETokenType.RBRACKETTokenType.REQUIRETokenType.RETURNTokenType.RPARENTokenType.SEMICOLONTokenType.SLASHTokenType.STARTokenType.STRING_LITERALTokenType.TYPE_ARCTokenType.TYPE_BEZIERTokenType.TYPE_BOOLTokenType.TYPE_CATMULLROMTokenType.TYPE_CIRCLETokenType.TYPE_DICTTokenType.TYPE_ELLIPSETokenType.TYPE_FLOATTokenType.TYPE_HYPERBOLATokenType.TYPE_INTTokenType.TYPE_LINE_SEGMENTTokenType.TYPE_LISTTokenType.TYPE_LOOP3DTokenType.TYPE_NURBSTokenType.TYPE_PARABOLATokenType.TYPE_PATH2DTokenType.TYPE_PATH3DTokenType.TYPE_POINTTokenType.TYPE_POINT2DTokenType.TYPE_POINT3DTokenType.TYPE_PROFILE2DTokenType.TYPE_REGION2DTokenType.TYPE_SHELLTokenType.TYPE_SOLIDTokenType.TYPE_STRINGTokenType.TYPE_SURFACETokenType.TYPE_TRANSFORMTokenType.TYPE_VECTORTokenType.TYPE_VECTOR2DTokenType.TYPE_VECTOR3DTokenType.UNDERSCORETokenType.USETokenType.WHILETokenType.WITH
TransformPipelineTreeTransformTreeTransform.transform()TreeTransform.visit_assignment()TreeTransform.visit_binary_op()TreeTransform.visit_block()TreeTransform.visit_command()TreeTransform.visit_dict_literal()TreeTransform.visit_emit()TreeTransform.visit_expr_statement()TreeTransform.visit_expression()TreeTransform.visit_for()TreeTransform.visit_function_call()TreeTransform.visit_identifier()TreeTransform.visit_if_expr()TreeTransform.visit_index_access()TreeTransform.visit_lambda()TreeTransform.visit_let()TreeTransform.visit_list_comprehension()TreeTransform.visit_list_literal()TreeTransform.visit_literal()TreeTransform.visit_match_expr()TreeTransform.visit_member_access()TreeTransform.visit_method_call()TreeTransform.visit_module()TreeTransform.visit_python_block()TreeTransform.visit_python_expr()TreeTransform.visit_range()TreeTransform.visit_require()TreeTransform.visit_return()TreeTransform.visit_statement()TreeTransform.visit_unary_op()
TypeTypeCheckerTypeErrorTypeNodeTypeTierUnaryOpUseStatementValueWildcardPatterncheck()compile_and_run()create_provenance()describe_function()execute()get_api_as_json()get_api_reference()get_common_pattern()get_function_info()get_method_signature()get_methods_for_type()get_type_info()is_type_token()list_common_patterns()list_functions()list_types()make_list_type()make_optional_type()package_from_dsl()parse()print_ast()resolve_type_name()tokenize()
- yapcad.fasteners package
- Submodules
- yapcad.fasteners.builders module
- yapcad.fasteners.catalog module
- Module contents
HexCapScrewSpecHexCapScrewSpec.diameterHexCapScrewSpec.head_flat_diameterHexCapScrewSpec.head_heightHexCapScrewSpec.shank_diameterHexCapScrewSpec.shank_lengthHexCapScrewSpec.startsHexCapScrewSpec.thread_arc_samplesHexCapScrewSpec.thread_lengthHexCapScrewSpec.thread_samples_per_pitchHexCapScrewSpec.washer_diameterHexCapScrewSpec.washer_thickness
HexNutSpecbuild_hex_cap_screw()build_hex_nut()clear_cache()get_bolt_data()get_nut_data()get_thread_data()list_available_sizes()list_tolerance_classes()load_catalog()metric_hex_bolt()metric_hex_cap_catalog()metric_hex_cap_screw()metric_hex_nut()metric_hex_nut_catalog()unified_hex_bolt()unified_hex_cap_catalog()unified_hex_cap_screw()unified_hex_nut()unified_hex_nut_catalog()
- yapcad.io package
- yapcad.kinematics package
- Submodules
- yapcad.kinematics.chain module
KinematicChainKinematicChain.nameKinematicChain.partsKinematicChain.DATUM_NAMEKinematicChain.DATUM_NAMEKinematicChain.add_part()KinematicChain.export_json()KinematicChain.from_dict()KinematicChain.from_json()KinematicChain.get_all_descendants()KinematicChain.get_all_world_transforms()KinematicChain.get_chain_to_root()KinematicChain.get_children()KinematicChain.get_joint_value()KinematicChain.get_relative_transform()KinematicChain.get_world_transform()KinematicChain.print_tree()KinematicChain.set_joint_value()KinematicChain.to_dict()KinematicChain.validate()
- yapcad.kinematics.frame module
CoordinateFrameCoordinateFrame.nameCoordinateFrame.transformCoordinateFrame.datum_sourceCoordinateFrame.datum_nameCoordinateFrame.descriptionCoordinateFrame.datum_nameCoordinateFrame.datum_sourceCoordinateFrame.descriptionCoordinateFrame.from_dict()CoordinateFrame.get_transform()CoordinateFrame.invalidate_cache()CoordinateFrame.nameCoordinateFrame.to_dict()CoordinateFrame.transform
- yapcad.kinematics.joint module
JointJoint.nameJoint.joint_typeJoint.base_transformJoint.axisJoint.valueJoint.min_limitJoint.max_limitJoint.axisJoint.base_transformJoint.clamp_value()Joint.from_dict()Joint.get_transform()Joint.joint_typeJoint.max_limitJoint.min_limitJoint.nameJoint.set_value()Joint.to_dict()Joint.value
JointType
- yapcad.kinematics.part module
KinematicPartKinematicPart.nameKinematicPart.parentKinematicPart.parent_frameKinematicPart.jointKinematicPart.framesKinematicPart.stl_pathKinematicPart.is_printableKinematicPart.materialKinematicPart.colorKinematicPart.descriptionKinematicPart.add_frame()KinematicPart.colorKinematicPart.descriptionKinematicPart.framesKinematicPart.from_dict()KinematicPart.get_cached_world_transform()KinematicPart.get_frame()KinematicPart.invalidate_cache()KinematicPart.is_cache_valid()KinematicPart.is_printableKinematicPart.jointKinematicPart.materialKinematicPart.nameKinematicPart.parentKinematicPart.parent_frameKinematicPart.set_cached_world_transform()KinematicPart.stl_pathKinematicPart.to_dict()
- yapcad.kinematics.transform module
TransformTransform.matrixTransform.from_axis_angle()Transform.from_dict()Transform.from_euler_xyz()Transform.from_matrix()Transform.from_position_rpy()Transform.from_rotation_x()Transform.from_rotation_y()Transform.from_rotation_z()Transform.from_translation()Transform.identity()Transform.inverse()Transform.matrixTransform.rotation_matrixTransform.to_dict()Transform.to_euler_xyz()Transform.transform_point()Transform.transform_vector()Transform.translation
- Module contents
- OVERVIEW
CoordinateFrameCoordinateFrame.nameCoordinateFrame.transformCoordinateFrame.datum_sourceCoordinateFrame.datum_nameCoordinateFrame.descriptionCoordinateFrame.datum_nameCoordinateFrame.datum_sourceCoordinateFrame.descriptionCoordinateFrame.from_dict()CoordinateFrame.get_transform()CoordinateFrame.invalidate_cache()CoordinateFrame.nameCoordinateFrame.to_dict()CoordinateFrame.transform
JointJoint.nameJoint.joint_typeJoint.base_transformJoint.axisJoint.valueJoint.min_limitJoint.max_limitJoint.axisJoint.base_transformJoint.clamp_value()Joint.from_dict()Joint.get_transform()Joint.joint_typeJoint.max_limitJoint.min_limitJoint.nameJoint.set_value()Joint.to_dict()Joint.value
JointTypeKinematicChainKinematicChain.nameKinematicChain.partsKinematicChain.DATUM_NAMEKinematicChain.DATUM_NAMEKinematicChain.add_part()KinematicChain.export_json()KinematicChain.from_dict()KinematicChain.from_json()KinematicChain.get_all_descendants()KinematicChain.get_all_world_transforms()KinematicChain.get_chain_to_root()KinematicChain.get_children()KinematicChain.get_joint_value()KinematicChain.get_relative_transform()KinematicChain.get_world_transform()KinematicChain.partsKinematicChain.print_tree()KinematicChain.set_joint_value()KinematicChain.to_dict()KinematicChain.validate()
KinematicPartKinematicPart.nameKinematicPart.parentKinematicPart.parent_frameKinematicPart.jointKinematicPart.framesKinematicPart.stl_pathKinematicPart.is_printableKinematicPart.materialKinematicPart.colorKinematicPart.descriptionKinematicPart.add_frame()KinematicPart.colorKinematicPart.descriptionKinematicPart.framesKinematicPart.from_dict()KinematicPart.get_cached_world_transform()KinematicPart.get_frame()KinematicPart.invalidate_cache()KinematicPart.is_cache_valid()KinematicPart.is_printableKinematicPart.jointKinematicPart.materialKinematicPart.nameKinematicPart.parentKinematicPart.parent_frameKinematicPart.set_cached_world_transform()KinematicPart.stl_pathKinematicPart.to_dict()
TransformTransform.matrixTransform.from_axis_angle()Transform.from_dict()Transform.from_euler_xyz()Transform.from_matrix()Transform.from_position_rpy()Transform.from_rotation_x()Transform.from_rotation_y()Transform.from_rotation_z()Transform.from_translation()Transform.identity()Transform.inverse()Transform.matrixTransform.rotation_matrixTransform.to_dict()Transform.to_euler_xyz()Transform.transform_point()Transform.transform_vector()Transform.translation
- yapcad.manufacturing package
- Submodules
- yapcad.manufacturing.connectors module
- yapcad.manufacturing.data module
ConnectorSpecConnectorSpec.idConnectorSpec.parent_element_idConnectorSpec.center_parameterConnectorSpec.lengthConnectorSpec.fit_clearanceConnectorSpec.profile_typeConnectorSpec.center_parameterConnectorSpec.fit_clearanceConnectorSpec.idConnectorSpec.lengthConnectorSpec.parent_element_idConnectorSpec.profile_type
CutPointSegmentSegment.idSegment.solidSegment.parent_element_idSegment.parameter_rangeSegment.has_connector_tabSegment.connector_typeSegment.mates_withSegment.bounding_boxSegment.bounding_boxSegment.connector_typeSegment.has_connector_tabSegment.idSegment.mates_withSegment.parameter_rangeSegment.parent_element_idSegment.solid
SegmentationResultSegmentationResult.segmentsSegmentationResult.connectorsSegmentationResult.assembly_graphSegmentationResult.build_volume_okSegmentationResult.warningsSegmentationResult.assembly_instructionsSegmentationResult.assembly_graphSegmentationResult.assembly_instructionsSegmentationResult.build_volume_okSegmentationResult.connectorsSegmentationResult.get_segment()SegmentationResult.get_segments_for_element()SegmentationResult.segment_countSegmentationResult.segmentsSegmentationResult.warnings
SweptElementProvenanceSweptElementProvenance.idSweptElementProvenance.operationSweptElementProvenance.outer_profileSweptElementProvenance.inner_profileSweptElementProvenance.spineSweptElementProvenance.wall_thicknessSweptElementProvenance.semantic_typeSweptElementProvenance.idSweptElementProvenance.inner_profileSweptElementProvenance.metadataSweptElementProvenance.operationSweptElementProvenance.outer_profileSweptElementProvenance.semantic_typeSweptElementProvenance.spineSweptElementProvenance.wall_thickness
- yapcad.manufacturing.path_utils module
- yapcad.manufacturing.rings module
- yapcad.manufacturing.segmentation module
- Module contents
- Phase 1 Implementation
- Example Usage
ConnectorSpecConnectorSpec.idConnectorSpec.parent_element_idConnectorSpec.center_parameterConnectorSpec.lengthConnectorSpec.fit_clearanceConnectorSpec.profile_typeConnectorSpec.center_parameterConnectorSpec.fit_clearanceConnectorSpec.idConnectorSpec.lengthConnectorSpec.parent_element_idConnectorSpec.profile_type
CutPointSegmentSegment.idSegment.solidSegment.parent_element_idSegment.parameter_rangeSegment.has_connector_tabSegment.connector_typeSegment.mates_withSegment.bounding_boxSegment.bounding_boxSegment.connector_typeSegment.has_connector_tabSegment.idSegment.mates_withSegment.parameter_rangeSegment.parent_element_idSegment.solid
SegmentationResultSegmentationResult.segmentsSegmentationResult.connectorsSegmentationResult.assembly_graphSegmentationResult.build_volume_okSegmentationResult.warningsSegmentationResult.assembly_instructionsSegmentationResult.assembly_graphSegmentationResult.assembly_instructionsSegmentationResult.build_volume_okSegmentationResult.connectorsSegmentationResult.get_segment()SegmentationResult.get_segments_for_element()SegmentationResult.segment_countSegmentationResult.segmentsSegmentationResult.warnings
SweptElementProvenanceSweptElementProvenance.idSweptElementProvenance.operationSweptElementProvenance.outer_profileSweptElementProvenance.inner_profileSweptElementProvenance.spineSweptElementProvenance.wall_thicknessSweptElementProvenance.semantic_typeSweptElementProvenance.idSweptElementProvenance.inner_profileSweptElementProvenance.metadataSweptElementProvenance.operationSweptElementProvenance.outer_profileSweptElementProvenance.semantic_typeSweptElementProvenance.spineSweptElementProvenance.wall_thickness
add_female_holes_to_ring()add_terminal_connectors_to_segment()build_connector_solids()compute_arc_attachment_point()compute_connector_length()compute_connector_profile_dimensions()compute_connector_spec()compute_cut_plane()compute_inner_profile_dimensions()compute_optimal_cuts()compute_ring_cuts_avoiding_holes()create_connector_region2d()create_female_hole_solid()create_interior_connector()create_ring_profile()create_ring_solid()create_ring_spine()create_terminal_connector()evaluate_path3d_at_t()extract_segment_between_planes()extract_sub_path()length_to_parameter()offset_rectangular_profile()parameter_to_length()path_length()segment_closed_ring()segment_swept_element()split_solid_at_plane()trim_segment_against_ring()
- yapcad.package package
- Subpackages
- yapcad.package.analysis package
- Submodules
- yapcad.package.analysis.base module
- yapcad.package.analysis.calculix module
- yapcad.package.analysis.cli module
- yapcad.package.analysis.face_naming module
- yapcad.package.analysis.fenics module
- yapcad.package.analysis.gmsh_mesher module
- yapcad.package.analysis.schema module
- yapcad.package.analysis.yapcad_native module
- Module contents
- yapcad.package.analysis package
- Submodules
- yapcad.package.core module
- yapcad.package.signing module
- yapcad.package.validator module
- yapcad.package.viewer module
- Module contents
AnalysisAdapterAnalysisPlanAnalysisPlan.acceptanceAnalysisPlan.attachmentsAnalysisPlan.backendAnalysisPlan.backend_optionsAnalysisPlan.boundary_conditionsAnalysisPlan.descriptionAnalysisPlan.executionAnalysisPlan.geometryAnalysisPlan.kindAnalysisPlan.loadsAnalysisPlan.materialsAnalysisPlan.metadataAnalysisPlan.nameAnalysisPlan.normalized_backendAnalysisPlan.plan_idAnalysisPlan.raw
AnalysisResultExecutionConfigPackageManifestSignatureInfoSignatureMethodSigningErrorVerificationResultVerificationStatusadd_geometry_file()analyze_package()available_backends()create_package_from_entities()list_signatures()load_analysis_plan()load_geometry()register_backend()sign_package()validate_package()verify_package()view_package()
- Subpackages
- yapcad.viewer package
- Submodules
- yapcad.viewer.api_server module
- yapcad.viewer.config module
- Viewer Configuration
ViewerConfigViewerConfig.stl_dirViewerConfig.positions_fileViewerConfig.command_fileViewerConfig.screenshot_dirViewerConfig.background_colorViewerConfig.color_paletteViewerConfig.command_fileViewerConfig.command_pathViewerConfig.command_poll_interval_msViewerConfig.default_colorViewerConfig.default_opacityViewerConfig.enable_multi_viewportViewerConfig.from_dict()ViewerConfig.get_color()ViewerConfig.positions_fileViewerConfig.positions_pathViewerConfig.screenshot_dirViewerConfig.screenshot_pathViewerConfig.stl_dirViewerConfig.stl_pathViewerConfig.to_dict()ViewerConfig.window_sizeViewerConfig.window_titleViewerConfig.xray_opacity
- yapcad.viewer.events module
- yapcad.viewer.vtk_viewer module
- Module contents
Submodules
yapcad.analytic_surfaces module
Analytic surface definitions for yapCAD.
This module provides native analytic surface representations that store parametric definitions rather than (or in addition to) tessellated meshes. These surfaces can be evaluated at arbitrary (u, v) parameters and tessellated on demand.
Surface types: - PlaneSurface: infinite plane defined by point and normal - SphereSurface: sphere defined by center and radius - CylinderSurface: cylinder defined by axis, radius, and height bounds - ConeSurface: cone defined by apex, axis, half-angle, and height bounds - TorusSurface: torus defined by center, axis, major/minor radii
Each surface stores: - Parameter domain (u, v bounds) - Local coordinate system (origin, axis) - Geometric parameters (radii, angles, etc.) - Optional tessellation cache
Copyright (c) 2025 Richard DeVaul MIT License
- yapcad.analytic_surfaces.bspline_surface(control_points, u_knots, v_knots, u_degree, v_degree, *, weights=None, u_range=None, v_range=None)[source]
Create a NURBS/B-spline surface.
The surface is defined by a grid of control points, knot vectors in both parameter directions, and optional weights (for rational B-splines).
- Parameters:
control_points (list of list of points) – 2D grid of control points [v_rows][u_cols]. Each point is [x, y, z] or [x, y, z, w].
u_degree (int) – Degree of the B-spline in u direction.
v_degree (int) – Degree of the B-spline in v direction.
weights (list of list of float, optional) – Weights for rational B-splines. If None, all weights are 1.0 (non-rational).
u_range (tuple, optional) – Parameter range in u direction. Defaults to (min(u_knots), max(u_knots)).
v_range (tuple, optional) – Parameter range in v direction. Defaults to (min(v_knots), max(v_knots)).
- Returns:
B-spline surface definition: [‘bspline_surface’, control_points, metadata_dict]
- Return type:
- yapcad.analytic_surfaces.bspline_surface_normal(surf, u, v, delta=1e-06)[source]
Return the normal vector at (u, v) on a B-spline surface.
Computed via finite differences of partial derivatives.
- yapcad.analytic_surfaces.cone_surface(apex, axis_direction, half_angle, *, u_range=(0.0, 6.283185307179586), v_range=(0.0, 1.0))[source]
Create an analytic cone surface.
The cone is parameterized as: - u: angular position around the axis (0 to 2*pi) - v: distance from apex along the surface
- Parameters:
apex (point) – Apex (tip) of the cone.
axis_direction (vector) – Direction of the cone axis (from apex, will be normalized).
half_angle (float) – Half-angle of the cone in radians.
u_range (tuple, optional) – Angular parameter range (default (0, 2*pi)).
v_range (tuple, optional) – Distance parameter range from apex (default (0, 1)).
- Returns:
Cone surface definition.
- Return type:
- yapcad.analytic_surfaces.cone_surface_normal(surf, u, v)[source]
Return the outward normal vector at (u, v) on a cone surface.
- yapcad.analytic_surfaces.cylinder_surface(axis_point, axis_direction, radius, *, u_range=(0.0, 6.283185307179586), v_range=(0.0, 1.0))[source]
Create an analytic cylinder surface.
The cylinder is parameterized as: - u: angular position around the axis (0 to 2*pi) - v: position along the axis (0 to 1 maps to v_range)
- Parameters:
axis_point (point) – A point on the cylinder axis.
axis_direction (vector) – Direction of the cylinder axis (will be normalized).
radius (float) – Radius of the cylinder.
u_range (tuple, optional) – Angular parameter range (default (0, 2*pi)).
v_range (tuple, optional) – Height parameter range (default (0, 1)).
- Returns:
Cylinder surface definition.
- Return type:
- yapcad.analytic_surfaces.cylinder_surface_normal(surf, u, v)[source]
Return the outward normal vector at (u, v) on a cylinder surface.
- yapcad.analytic_surfaces.evaluate_bspline_surface(surf, u, v)[source]
Evaluate a point on a B-spline surface at parameters (u, v).
- yapcad.analytic_surfaces.evaluate_cone_surface(surf, u, v)[source]
Evaluate a point on a cone surface at parameters (u, v).
- yapcad.analytic_surfaces.evaluate_cylinder_surface(surf, u, v)[source]
Evaluate a point on a cylinder surface at parameters (u, v).
- yapcad.analytic_surfaces.evaluate_plane_surface(surf, u, v)[source]
Evaluate a point on a plane surface at parameters (u, v).
- yapcad.analytic_surfaces.evaluate_sphere_surface(surf, u, v)[source]
Evaluate a point on a sphere surface at parameters (u, v).
- yapcad.analytic_surfaces.evaluate_surface(surf, u, v)[source]
Evaluate a point on an analytic surface at parameters (u, v).
This is a generic dispatcher for all analytic surface types.
- yapcad.analytic_surfaces.evaluate_tessellated_surface(surf, u, v)[source]
Evaluate a point on a tessellated surface at parameters (u, v).
Since the surface is pre-tessellated, this uses bilinear interpolation over the bounding box as an approximation.
- yapcad.analytic_surfaces.evaluate_torus_surface(surf, u, v)[source]
Evaluate a point on a torus surface at parameters (u, v).
- yapcad.analytic_surfaces.is_analytic_surface(obj)[source]
Return True if obj is any type of analytic surface.
- yapcad.analytic_surfaces.is_cylinder_surface(obj)[source]
Return True if obj is a cylinder surface.
- yapcad.analytic_surfaces.is_tessellated_surface(obj)[source]
Return True if obj is a pre-tessellated surface.
- yapcad.analytic_surfaces.plane_surface(origin, normal, *, u_range=(-1.0, 1.0), v_range=(-1.0, 1.0))[source]
Create an analytic plane surface.
- Parameters:
- Returns:
Plane surface definition: [‘plane_surface’, origin, metadata_dict]
- Return type:
- yapcad.analytic_surfaces.plane_surface_normal(surf, u, v)[source]
Return the normal vector at (u, v) on a plane surface.
For a plane, the normal is constant everywhere.
- yapcad.analytic_surfaces.sphere_surface(center, radius, *, u_range=(0.0, 6.283185307179586), v_range=(-1.5707963267948966, 1.5707963267948966))[source]
Create an analytic sphere surface.
The sphere is parameterized as: - u: longitude angle (0 to 2*pi) - v: latitude angle (-pi/2 to pi/2)
- Parameters:
- Returns:
Sphere surface definition: [‘sphere_surface’, center, metadata_dict]
- Return type:
- yapcad.analytic_surfaces.sphere_surface_normal(surf, u, v)[source]
Return the outward normal vector at (u, v) on a sphere surface.
- yapcad.analytic_surfaces.surface_normal(surf, u, v)[source]
Return the normal vector at (u, v) on an analytic surface.
This is a generic dispatcher for all analytic surface types.
- yapcad.analytic_surfaces.tessellate_surface(surf, *, u_divisions=16, v_divisions=16)[source]
Convert an analytic surface to a tessellated mesh surface.
- yapcad.analytic_surfaces.tessellated_surface(vertices, normals, faces, *, u_range=(0.0, 1.0), v_range=(0.0, 1.0))[source]
Create a pre-tessellated surface (fallback for non-analytic geometry).
This surface type stores an already-tessellated mesh. It cannot be re-tessellated at different resolutions but provides a consistent interface with other analytic surfaces.
- Parameters:
vertices (list of points) – List of vertex positions.
normals (list of vectors) – List of normal vectors (one per vertex or one per face).
faces (list of [i, j, k]) – Triangle indices into vertices.
u_range (tuple, optional) – Nominal parameter range in u direction.
v_range (tuple, optional) – Nominal parameter range in v direction.
- Returns:
Tessellated surface definition.
- Return type:
- yapcad.analytic_surfaces.tessellated_surface_normal(surf, u, v)[source]
Return a nominal normal for a tessellated surface.
Returns average of all normals as an approximation.
- yapcad.analytic_surfaces.torus_surface(center, axis_direction, major_radius, minor_radius, *, u_range=(0.0, 6.283185307179586), v_range=(0.0, 6.283185307179586))[source]
Create an analytic torus surface.
The torus is parameterized as: - u: angle around the major circle (0 to 2*pi) - v: angle around the minor circle (0 to 2*pi)
- Parameters:
center (point) – Center of the torus.
axis_direction (vector) – Direction of the torus axis (will be normalized).
major_radius (float) – Major radius (distance from center to tube center).
minor_radius (float) – Minor radius (tube radius).
u_range (tuple, optional) – Major angle parameter range (default (0, 2*pi)).
v_range (tuple, optional) – Minor angle parameter range (default (0, 2*pi)).
- Returns:
Torus surface definition.
- Return type:
yapcad.brep module
Core Boundary Representation (BREP) helpers for yapCAD.
These classes wrap pythonocc-core objects when that dependency is available. Importing this module on systems without pythonocc-core should not explode; instead, we raise a clear runtime error the first time a BREP feature is requested so users know to activate the conda environment.
- class yapcad.brep.BrepEdge(shape: Any)[source]
Bases:
objectA wrapper for a TopoDS_Edge.
- property shape
- class yapcad.brep.BrepFace(shape: Any)[source]
Bases:
objectA wrapper for a TopoDS_Face.
- property shape
- class yapcad.brep.BrepSolid(shape)[source]
Bases:
objectA wrapper for a TopoDS_Shape (Solid or Compound of Solids).
- property shape
- tessellate(deflection=0.5, _debug=False)[source]
Generate a faceted representation of the BREP model.
This method will use pythonocc-core’s meshing capabilities to generate a triangular mesh of the BREP model. The resulting faceted representation will be returned in the same format as yapcad.geom3d.poly2surface.
- class yapcad.brep.BrepVertex(shape: Any)[source]
Bases:
objectA wrapper for a TopoDS_Vertex.
- property shape
- yapcad.brep.apply_matrix_to_brep_solid(solid: list, matrix) None[source]
Apply a yapCAD transformation matrix to the stored BREP shape.
This function converts a yapCAD Matrix (4x4 homogeneous transformation) to an OCC gp_Trsf and applies it to the BREP data attached to the solid.
- Parameters:
solid – A yapCAD solid with BREP metadata attached
matrix – A yapCAD Matrix instance (from yapcad.xform)
Note
The matrix must represent an affine transformation (rotation, translation, uniform scale, or composition thereof). Non-uniform scaling will cause the BREP to be dropped.
- yapcad.brep.attach_brep_to_solid(solid: list, brep: BrepSolid) None[source]
Embed serialized BREP data into the solid metadata and cache the shape.
- yapcad.brep.brep_from_solid(solid: list) BrepSolid | None[source]
Return the cached BrepSolid for
solidif metadata is present.
- yapcad.brep.chamfer_all_edges(brep_solid: BrepSolid, distance: float) BrepSolid[source]
Apply chamfer (beveled edge) to all edges of a BREP solid.
Creates symmetric 45-degree chamfers with equal distances on both faces.
- Parameters:
brep_solid – A BrepSolid object containing the shape to chamfer
distance – Chamfer distance from the edge in model units
- Returns:
A new BrepSolid with chamfered edges
- Raises:
RuntimeError – If OCC is not available or chamfer operation fails
- yapcad.brep.chamfer_edges(brep_solid: BrepSolid, edges: list, distance: float) BrepSolid[source]
Apply chamfer to specific edges of a BREP solid.
- Parameters:
brep_solid – A BrepSolid object containing the shape to chamfer
edges – List of BrepEdge objects to chamfer
distance – Chamfer distance from the edge in model units
- Returns:
A new BrepSolid with chamfered edges
- Raises:
RuntimeError – If OCC is not available or chamfer operation fails
- yapcad.brep.fillet_all_edges(brep_solid: BrepSolid, radius: float) BrepSolid[source]
Apply fillet (rounded edge) to all edges of a BREP solid.
- Parameters:
brep_solid – A BrepSolid object containing the shape to fillet
radius – Fillet radius in model units
- Returns:
A new BrepSolid with filleted edges
- Raises:
RuntimeError – If OCC is not available or fillet operation fails
- yapcad.brep.fillet_edges(brep_solid: BrepSolid, edges: list, radius: float) BrepSolid[source]
Apply fillet to specific edges of a BREP solid.
- Parameters:
brep_solid – A BrepSolid object containing the shape to fillet
edges – List of BrepEdge objects to fillet
radius – Fillet radius in model units
- Returns:
A new BrepSolid with filleted edges
- Raises:
RuntimeError – If OCC is not available or fillet operation fails
yapcad.brep_edge_select module
Edge selection helper functions for yapCAD BREP operations.
This module provides functions to select edges from BREP solids based on various geometric criteria such as direction, length, position, and association with specific faces.
These functions are particularly useful for applying selective fillet or chamfer operations to specific edges rather than all edges of a solid.
- Example usage:
from yapcad.brep import brep_from_solid, fillet_edges from yapcad.brep_edge_select import select_vertical_edges from yapcad.geom3d_util import prism
# Create a pocket (prism with a hole) solid = prism(20, 20, 10) brep = brep_from_solid(solid)
# Select only vertical edges vertical_edges = select_vertical_edges(brep)
# Apply fillet only to vertical edges filleted = fillet_edges(brep, vertical_edges, radius=1.0)
Copyright (c) 2025 Richard W. DeVaul Copyright (c) 2025 yapCAD contributors MIT License
- yapcad.brep_edge_select.edge_info(edge: BrepEdge) dict[source]
Get detailed information about an edge.
- Parameters:
edge – A BrepEdge object
- Returns:
length: Edge length
endpoints: ((x1, y1, z1), (x2, y2, z2))
midpoint: (x, y, z)
direction: (dx, dy, dz) for linear edges, None for curved
is_linear: True if edge is straight
is_vertical: True if parallel to Z axis
is_horizontal: True if perpendicular to Z axis
- Return type:
Dictionary with edge properties
- yapcad.brep_edge_select.filter_curved_edges(edges: List[BrepEdge]) List[BrepEdge][source]
Filter to keep only curved (non-linear) edges.
- Parameters:
edges – List of BrepEdge objects to filter
- Returns:
List of curved BrepEdge objects
- yapcad.brep_edge_select.filter_linear_edges(edges: List[BrepEdge]) List[BrepEdge][source]
Filter to keep only linear (straight) edges.
- Parameters:
edges – List of BrepEdge objects to filter
- Returns:
List of linear BrepEdge objects
- yapcad.brep_edge_select.get_all_edges(brep_solid: BrepSolid) List[BrepEdge][source]
Get all unique edges from a BREP solid as BrepEdge objects.
- Parameters:
brep_solid – A BrepSolid object
- Returns:
List of BrepEdge objects (unique, no duplicates)
- yapcad.brep_edge_select.intersect_edges(*edge_lists: List[BrepEdge]) List[BrepEdge][source]
Find edges common to all input lists.
- Parameters:
*edge_lists – Variable number of BrepEdge lists
- Returns:
List of BrepEdge objects present in all input lists
- yapcad.brep_edge_select.select_bottom_edges(brep_solid: BrepSolid, tolerance: float = 0.001) List[BrepEdge][source]
Select edges at the minimum Z height of the solid.
- Parameters:
brep_solid – A BrepSolid object
tolerance – Position tolerance (default 0.001)
- Returns:
List of BrepEdge objects at the bottom of the solid
- yapcad.brep_edge_select.select_edges_at_z(brep_solid: BrepSolid, z_value: float, tolerance: float = 0.001) List[BrepEdge][source]
Select edges that lie entirely at a specific Z height.
This selects horizontal edges where both endpoints are at the given Z value.
- Parameters:
brep_solid – A BrepSolid object
z_value – The Z coordinate to match
tolerance – Position tolerance (default 0.001)
- Returns:
List of BrepEdge objects at the specified Z height
- yapcad.brep_edge_select.select_edges_by_direction(brep_solid: BrepSolid, direction: Tuple[float, float, float] | list, tolerance_deg: float = 1.0) List[BrepEdge][source]
Select linear edges parallel to a given direction.
- Parameters:
brep_solid – A BrepSolid object
direction – Direction vector as (x, y, z) tuple or list
tolerance_deg – Angular tolerance in degrees (default 1.0)
- Returns:
List of BrepEdge objects parallel to the direction
- yapcad.brep_edge_select.select_edges_by_length(brep_solid: BrepSolid, min_length: float | None = None, max_length: float | None = None) List[BrepEdge][source]
Select edges within a length range.
- Parameters:
brep_solid – A BrepSolid object
min_length – Minimum edge length (inclusive), None for no minimum
max_length – Maximum edge length (inclusive), None for no maximum
- Returns:
List of BrepEdge objects within the length range
- yapcad.brep_edge_select.select_edges_crossing_z(brep_solid: BrepSolid, z_value: float, tolerance: float = 0.001) List[BrepEdge][source]
Select edges that cross a specific Z height (vertical edges spanning Z).
This is useful for selecting vertical edges of a pocket or boss.
- Parameters:
brep_solid – A BrepSolid object
z_value – The Z coordinate that edges must span
tolerance – Position tolerance (default 0.001)
- Returns:
List of BrepEdge objects that cross the Z value
- yapcad.brep_edge_select.select_edges_in_cylinder(brep_solid: BrepSolid, center: Tuple[float, float, float] | list, radius: float, axis: Tuple[float, float, float] | list = (0, 0, 1)) List[BrepEdge][source]
Select edges whose midpoint is within a cylindrical region.
Useful for selecting edges around a hole or boss.
- Parameters:
brep_solid – A BrepSolid object
center – Center point of cylinder axis (x, y, z)
radius – Radius of the cylindrical region
axis – Cylinder axis direction (default Z axis)
- Returns:
List of BrepEdge objects within the cylinder
- yapcad.brep_edge_select.select_edges_in_z_range(brep_solid: BrepSolid, z_min: float, z_max: float, tolerance: float = 0.001) List[BrepEdge][source]
Select edges where both endpoints are within a Z range.
- Parameters:
brep_solid – A BrepSolid object
z_min – Minimum Z coordinate
z_max – Maximum Z coordinate
tolerance – Position tolerance (default 0.001)
- Returns:
List of BrepEdge objects within the Z range
- yapcad.brep_edge_select.select_edges_near_point(brep_solid: BrepSolid, target_point: Tuple[float, float, float] | list, max_distance: float) List[BrepEdge][source]
Select edges whose midpoint is within a distance of a target point.
- Parameters:
brep_solid – A BrepSolid object
target_point – The reference point as (x, y, z)
max_distance – Maximum distance from target point
- Returns:
List of BrepEdge objects near the target point
- yapcad.brep_edge_select.select_horizontal_edges(brep_solid: BrepSolid, tolerance_deg: float = 1.0) List[BrepEdge][source]
Select edges that are perpendicular to the Z axis (horizontal).
This includes edges in the XY plane at any Z height.
- Parameters:
brep_solid – A BrepSolid object
tolerance_deg – Angular tolerance in degrees (default 1.0)
- Returns:
List of BrepEdge objects that are horizontal
- yapcad.brep_edge_select.select_top_edges(brep_solid: BrepSolid, tolerance: float = 0.001) List[BrepEdge][source]
Select edges at the maximum Z height of the solid.
- Parameters:
brep_solid – A BrepSolid object
tolerance – Position tolerance (default 0.001)
- Returns:
List of BrepEdge objects at the top of the solid
- yapcad.brep_edge_select.select_vertical_edges(brep_solid: BrepSolid, tolerance_deg: float = 1.0) List[BrepEdge][source]
Select edges that are parallel to the Z axis (vertical).
- Parameters:
brep_solid – A BrepSolid object
tolerance_deg – Angular tolerance in degrees (default 1.0)
- Returns:
List of BrepEdge objects that are vertical
- yapcad.brep_edge_select.subtract_edges(base_edges: List[BrepEdge], edges_to_remove: List[BrepEdge]) List[BrepEdge][source]
Remove edges from a list.
- Parameters:
base_edges – The original list of edges
edges_to_remove – Edges to remove from the base list
- Returns:
List of BrepEdge objects from base_edges not in edges_to_remove
yapcad.combine module
- class yapcad.combine.Boolean(type='union', polys=[], *, minang=5.0, minlen=0.25)[source]
Bases:
GeometryBoolean operations on Polygons
- property geom
return yapcad.geom representation of figure
- mirror(plane)[source]
apply a mirror operation to a figure. Currently, the following values of “plane” are allowed: ‘xz’, ‘yz’, xy’. Generalized arbitrary reflection plane specification will be added in the future.
If
keepSign == True(default) the sign of the area will be maintained, meaning that ifmirroris applied to a right-handed closed figure (a figure with positive area) the resulting mirrored figure will also have positive area. This is probably what you want, unless you are specifically turning a face into a hole, or vice-versa.
- transform(m)[source]
apply an arbitrary transformation to a figure, as specified by a transformation matrix.
- property type
- types = ('union', 'intersection', 'difference')
yapcad.drawable module
- class yapcad.drawable.Drawable[source]
Bases:
objectBase class for yapCAD drawables
- colordict = {'aliceblue': ([240, 248, 255], None), 'antiquewhite': ([250, 235, 215], None), 'aqua': ([0, 255, 255], 4), 'aquamarine': ([127, 255, 212], None), 'azure': ([240, 255, 255], None), 'beige': ([245, 245, 220], None), 'bisque': ([255, 228, 196], None), 'black': ([0, 0, 0], 0), 'blanchedalmond': ([255, 235, 205], None), 'blue': ([0, 0, 255], 5), 'blueviolet': ([138, 43, 226], None), 'brown': ([165, 42, 42], None), 'burlywood': ([222, 184, 135], None), 'cadetblue': ([95, 158, 160], None), 'chartreuse': ([127, 255, 0], None), 'chocolate': ([210, 105, 30], None), 'coral': ([255, 127, 80], None), 'cornflowerblue': ([100, 149, 237], None), 'cornsilk': ([255, 248, 220], None), 'crimson': ([220, 20, 60], None), 'cyan': ([0, 255, 255], None), 'darkblue': ([0, 0, 139], None), 'darkcyan': ([0, 139, 139], None), 'darkgoldenrod': ([184, 134, 11], None), 'darkgray': ([169, 169, 169], None), 'darkgreen': ([0, 100, 0], None), 'darkgrey': ([169, 169, 169], None), 'darkkhaki': ([189, 183, 107], None), 'darkmagenta': ([139, 0, 139], None), 'darkolivegreen': ([85, 107, 47], None), 'darkorange': ([255, 140, 0], None), 'darkorchid': ([153, 50, 204], None), 'darkred': ([139, 0, 0], None), 'darksalmon': ([233, 150, 122], None), 'darkseagreen': ([143, 188, 143], None), 'darkslateblue': ([72, 61, 139], None), 'darkslategray': ([47, 79, 79], None), 'darkslategrey': ([47, 79, 79], None), 'darkturquoise': ([0, 206, 209], None), 'darkviolet': ([148, 0, 211], None), 'deeppink': ([255, 20, 147], None), 'deepskyblue': ([0, 191, 255], None), 'dimgray': ([105, 105, 105], None), 'dimgrey': ([105, 105, 105], None), 'dodgerblue': ([30, 144, 255], None), 'firebrick': ([178, 34, 34], None), 'floralwhite': ([255, 250, 240], None), 'forestgreen': ([34, 139, 34], None), 'fuchsia': ([255, 0, 255], 6), 'gainsboro': ([220, 220, 220], None), 'ghostwhite': ([248, 248, 255], None), 'gold': ([255, 215, 0], None), 'goldenrod': ([218, 165, 32], None), 'gray': ([128, 128, 128], 8), 'gray0': ([0, 0, 0], None), 'gray1': ([3, 3, 3], None), 'gray10': ([26, 26, 26], None), 'gray100': ([255, 255, 255], None), 'gray11': ([28, 28, 28], None), 'gray12': ([31, 31, 31], None), 'gray13': ([33, 33, 33], None), 'gray14': ([36, 36, 36], None), 'gray15': ([38, 38, 38], None), 'gray16': ([41, 41, 41], None), 'gray17': ([43, 43, 43], None), 'gray18': ([46, 46, 46], None), 'gray19': ([48, 48, 48], None), 'gray2': ([5, 5, 5], None), 'gray20': ([51, 51, 51], None), 'gray21': ([54, 54, 54], None), 'gray22': ([56, 56, 56], None), 'gray23': ([59, 59, 59], None), 'gray24': ([61, 61, 61], None), 'gray25': ([64, 64, 64], None), 'gray26': ([66, 66, 66], None), 'gray27': ([69, 69, 69], None), 'gray28': ([71, 71, 71], None), 'gray29': ([74, 74, 74], None), 'gray3': ([8, 8, 8], None), 'gray30': ([76, 76, 76], None), 'gray31': ([79, 79, 79], None), 'gray32': ([82, 82, 82], None), 'gray33': ([84, 84, 84], None), 'gray34': ([87, 87, 87], None), 'gray35': ([89, 89, 89], None), 'gray36': ([92, 92, 92], None), 'gray37': ([94, 94, 94], None), 'gray38': ([97, 97, 97], None), 'gray39': ([99, 99, 99], None), 'gray4': ([10, 10, 10], None), 'gray40': ([102, 102, 102], None), 'gray41': ([105, 105, 105], None), 'gray42': ([107, 107, 107], None), 'gray43': ([110, 110, 110], None), 'gray44': ([112, 112, 112], None), 'gray45': ([115, 115, 115], None), 'gray46': ([117, 117, 117], None), 'gray47': ([120, 120, 120], None), 'gray48': ([122, 122, 122], None), 'gray49': ([125, 125, 125], None), 'gray5': ([13, 13, 13], None), 'gray50': ([128, 128, 128], None), 'gray51': ([130, 130, 130], None), 'gray52': ([133, 133, 133], None), 'gray53': ([135, 135, 135], None), 'gray54': ([138, 138, 138], None), 'gray55': ([140, 140, 140], None), 'gray56': ([143, 143, 143], None), 'gray57': ([145, 145, 145], None), 'gray58': ([148, 148, 148], None), 'gray59': ([150, 150, 150], None), 'gray6': ([15, 15, 15], None), 'gray60': ([153, 153, 153], None), 'gray61': ([156, 156, 156], None), 'gray62': ([158, 158, 158], None), 'gray63': ([161, 161, 161], None), 'gray64': ([163, 163, 163], None), 'gray65': ([166, 166, 166], None), 'gray66': ([168, 168, 168], None), 'gray67': ([171, 171, 171], None), 'gray68': ([173, 173, 173], None), 'gray69': ([176, 176, 176], None), 'gray7': ([18, 18, 18], None), 'gray70': ([178, 178, 178], None), 'gray71': ([181, 181, 181], None), 'gray72': ([184, 184, 184], None), 'gray73': ([186, 186, 186], None), 'gray74': ([189, 189, 189], None), 'gray75': ([191, 191, 191], None), 'gray76': ([194, 194, 194], None), 'gray77': ([196, 196, 196], None), 'gray78': ([199, 199, 199], None), 'gray79': ([201, 201, 201], None), 'gray8': ([20, 20, 20], None), 'gray80': ([204, 204, 204], None), 'gray81': ([207, 207, 207], None), 'gray82': ([209, 209, 209], None), 'gray83': ([212, 212, 212], None), 'gray84': ([214, 214, 214], None), 'gray85': ([217, 217, 217], None), 'gray86': ([219, 219, 219], None), 'gray87': ([222, 222, 222], None), 'gray88': ([224, 224, 224], None), 'gray89': ([227, 227, 227], None), 'gray9': ([23, 23, 23], None), 'gray90': ([230, 230, 230], None), 'gray91': ([232, 232, 232], None), 'gray92': ([235, 235, 235], None), 'gray93': ([237, 237, 237], None), 'gray94': ([240, 240, 240], None), 'gray95': ([242, 242, 242], None), 'gray96': ([245, 245, 245], None), 'gray97': ([247, 247, 247], None), 'gray98': ([250, 250, 250], None), 'gray99': ([252, 252, 252], None), 'green': ([0, 127, 0], 94), 'greenyellow': ([173, 255, 47], None), 'grey': ([128, 128, 128], None), 'grey0': ([0, 0, 0], None), 'grey1': ([3, 3, 3], None), 'grey10': ([26, 26, 26], None), 'grey100': ([255, 255, 255], None), 'grey11': ([28, 28, 28], None), 'grey12': ([31, 31, 31], None), 'grey13': ([33, 33, 33], None), 'grey14': ([36, 36, 36], None), 'grey15': ([38, 38, 38], None), 'grey16': ([41, 41, 41], None), 'grey17': ([43, 43, 43], None), 'grey18': ([46, 46, 46], None), 'grey19': ([48, 48, 48], None), 'grey2': ([5, 5, 5], None), 'grey20': ([51, 51, 51], None), 'grey21': ([54, 54, 54], None), 'grey22': ([56, 56, 56], None), 'grey23': ([59, 59, 59], None), 'grey24': ([61, 61, 61], None), 'grey25': ([64, 64, 64], None), 'grey26': ([66, 66, 66], None), 'grey27': ([69, 69, 69], None), 'grey28': ([71, 71, 71], None), 'grey29': ([74, 74, 74], None), 'grey3': ([8, 8, 8], None), 'grey30': ([76, 76, 76], None), 'grey31': ([79, 79, 79], None), 'grey32': ([82, 82, 82], None), 'grey33': ([84, 84, 84], None), 'grey34': ([87, 87, 87], None), 'grey35': ([89, 89, 89], None), 'grey36': ([92, 92, 92], None), 'grey37': ([94, 94, 94], None), 'grey38': ([97, 97, 97], None), 'grey39': ([99, 99, 99], None), 'grey4': ([10, 10, 10], None), 'grey40': ([102, 102, 102], None), 'grey41': ([105, 105, 105], None), 'grey42': ([107, 107, 107], None), 'grey43': ([110, 110, 110], None), 'grey44': ([112, 112, 112], None), 'grey45': ([115, 115, 115], None), 'grey46': ([117, 117, 117], None), 'grey47': ([120, 120, 120], None), 'grey48': ([122, 122, 122], None), 'grey49': ([125, 125, 125], None), 'grey5': ([13, 13, 13], None), 'grey50': ([128, 128, 128], None), 'grey51': ([130, 130, 130], None), 'grey52': ([133, 133, 133], None), 'grey53': ([135, 135, 135], None), 'grey54': ([138, 138, 138], None), 'grey55': ([140, 140, 140], None), 'grey56': ([143, 143, 143], None), 'grey57': ([145, 145, 145], None), 'grey58': ([148, 148, 148], None), 'grey59': ([150, 150, 150], None), 'grey6': ([15, 15, 15], None), 'grey60': ([153, 153, 153], None), 'grey61': ([156, 156, 156], None), 'grey62': ([158, 158, 158], None), 'grey63': ([161, 161, 161], None), 'grey64': ([163, 163, 163], None), 'grey65': ([166, 166, 166], None), 'grey66': ([168, 168, 168], None), 'grey67': ([171, 171, 171], None), 'grey68': ([173, 173, 173], None), 'grey69': ([176, 176, 176], None), 'grey7': ([18, 18, 18], None), 'grey70': ([178, 178, 178], None), 'grey71': ([181, 181, 181], None), 'grey72': ([184, 184, 184], None), 'grey73': ([186, 186, 186], None), 'grey74': ([189, 189, 189], None), 'grey75': ([191, 191, 191], None), 'grey76': ([194, 194, 194], None), 'grey77': ([196, 196, 196], None), 'grey78': ([199, 199, 199], None), 'grey79': ([201, 201, 201], None), 'grey8': ([20, 20, 20], None), 'grey80': ([204, 204, 204], None), 'grey81': ([207, 207, 207], None), 'grey82': ([209, 209, 209], None), 'grey83': ([212, 212, 212], None), 'grey84': ([214, 214, 214], None), 'grey85': ([217, 217, 217], None), 'grey86': ([219, 219, 219], None), 'grey87': ([222, 222, 222], None), 'grey88': ([224, 224, 224], None), 'grey89': ([227, 227, 227], None), 'grey9': ([23, 23, 23], None), 'grey90': ([230, 230, 230], None), 'grey91': ([232, 232, 232], None), 'grey92': ([235, 235, 235], None), 'grey93': ([237, 237, 237], None), 'grey94': ([240, 240, 240], None), 'grey95': ([242, 242, 242], None), 'grey96': ([245, 245, 245], None), 'grey97': ([247, 247, 247], None), 'grey98': ([250, 250, 250], None), 'grey99': ([252, 252, 252], None), 'honeydew': ([240, 255, 240], None), 'hotpink': ([255, 105, 180], None), 'indianred': ([205, 92, 92], None), 'indigo': ([75, 0, 130], None), 'ivory': ([255, 255, 240], None), 'khaki': ([240, 230, 140], None), 'lavender': ([230, 230, 250], None), 'lavenderblush': ([255, 240, 245], None), 'lawngreen': ([124, 252, 0], None), 'lemonchiffon': ([255, 250, 205], None), 'lightblue': ([173, 216, 230], None), 'lightcoral': ([240, 128, 128], None), 'lightcyan': ([224, 255, 255], None), 'lightgoldenrodyellow': ([250, 250, 210], None), 'lightgray': ([211, 211, 211], None), 'lightgreen': ([144, 238, 144], None), 'lightgrey': ([211, 211, 211], None), 'lightpink': ([255, 182, 193], None), 'lightsalmon': ([255, 160, 122], None), 'lightseagreen': ([32, 178, 170], None), 'lightskyblue': ([135, 206, 250], None), 'lightslategray': ([119, 136, 153], None), 'lightslategrey': ([119, 136, 153], None), 'lightsteelblue': ([176, 196, 222], None), 'lightyellow': ([255, 255, 224], None), 'lime': ([0, 255, 0], 3), 'limegreen': ([50, 205, 50], None), 'linen': ([250, 240, 230], None), 'magenta': ([255, 0, 255], None), 'maroon': ([127, 0, 0], 14), 'mediumaquamarine': ([102, 205, 170], None), 'mediumblue': ([0, 0, 205], None), 'mediumorchid': ([186, 85, 211], None), 'mediumpurple': ([147, 112, 219], None), 'mediumseagreen': ([60, 179, 113], None), 'mediumslateblue': ([123, 104, 238], None), 'mediumspringgreen': ([0, 250, 154], None), 'mediumturquoise': ([72, 209, 204], None), 'mediumvioletred': ([199, 21, 133], None), 'midnightblue': ([25, 25, 112], None), 'mintcream': ([245, 255, 250], None), 'mistyrose': ([255, 228, 225], None), 'moccasin': ([255, 228, 181], None), 'navajowhite': ([255, 222, 173], None), 'navy': ([0, 0, 128], 174), 'oldlace': ([253, 245, 230], None), 'olive': ([127, 127, 0], 54), 'olivedrab': ([107, 142, 35], None), 'orange': ([255, 165, 0], None), 'orangered': ([255, 69, 0], None), 'orchid': ([218, 112, 214], None), 'palegoldenrod': ([238, 232, 170], None), 'palegreen': ([152, 251, 152], None), 'paleturquoise': ([175, 238, 238], None), 'palevioletred': ([219, 112, 147], None), 'papayawhip': ([255, 239, 213], None), 'peachpuff': ([255, 218, 185], None), 'peru': ([205, 133, 63], None), 'pink': ([255, 192, 203], None), 'plum': ([221, 160, 221], None), 'powderblue': ([176, 224, 230], None), 'purple': ([128, 0, 128], 214), 'rebeccapurple': ([102, 51, 153], None), 'red': ([255, 0, 0], 1), 'rosybrown': ([188, 143, 143], None), 'royalblue': ([65, 105, 225], None), 'saddlebrown': ([139, 69, 19], None), 'salmon': ([250, 128, 114], None), 'sandybrown': ([244, 164, 96], None), 'seagreen': ([46, 139, 87], None), 'seashell': ([255, 245, 238], None), 'sienna': ([160, 82, 45], None), 'silver': ([192, 192, 192], 9), 'skyblue': ([135, 206, 235], None), 'slateblue': ([106, 90, 205], None), 'slategray': ([112, 128, 144], None), 'slategrey': ([112, 128, 144], None), 'snow': ([255, 250, 250], None), 'springgreen': ([0, 255, 127], None), 'steelblue': ([70, 130, 180], None), 'tan': ([210, 180, 140], None), 'teal': ([0, 127, 127], 134), 'thistle': ([216, 191, 216], None), 'tomato': ([255, 99, 71], None), 'turquoise': ([64, 224, 208], None), 'violet': ([238, 130, 238], None), 'wheat': ([245, 222, 179], None), 'white': ([255, 255, 255], 7), 'whitesmoke': ([245, 245, 245], None), 'yellow': ([255, 255, 0], 2), 'yellowgreen': ([154, 205, 50], None)}
- colormapAUTOCAD = [[0, 0, 0], [255, 0, 0], [255, 255, 0], [0, 255, 0], [0, 255, 255], [0, 0, 255], [255, 0, 255], [255, 255, 255], [128, 128, 128], [192, 192, 192], [255, 0, 0], [255, 127, 127], [165, 0, 0], [165, 82, 82], [127, 0, 0], [127, 63, 63], [76, 0, 0], [76, 38, 38], [38, 0, 0], [38, 19, 19], [255, 63, 0], [255, 159, 127], [165, 41, 0], [165, 103, 82], [127, 31, 0], [127, 79, 63], [76, 19, 0], [76, 47, 38], [38, 9, 0], [38, 23, 19], [255, 127, 0], [255, 191, 127], [168, 82, 0], [165, 124, 82], [127, 63, 0], [127, 95, 63], [76, 38, 0], [76, 57, 38], [38, 19, 0], [38, 28, 19], [255, 191, 0], [255, 223, 127], [165, 124, 0], [165, 145, 82], [127, 95, 0], [127, 111, 63], [76, 57, 0], [76, 66, 38], [38, 28, 0], [38, 33, 19], [255, 255, 0], [255, 255, 127], [165, 165, 0], [165, 165, 82], [127, 127, 0], [127, 127, 63], [76, 76, 0], [76, 76, 38], [38, 38, 0], [38, 38, 19], [191, 255, 0], [223, 255, 127], [124, 165, 0], [145, 165, 82], [95, 127, 0], [111, 127, 63], [57, 76, 0], [66, 76, 38], [28, 38, 0], [33, 38, 19], [127, 255, 0], [191, 255, 127], [82, 165, 0], [124, 165, 82], [63, 127, 0], [95, 127, 63], [38, 76, 0], [57, 76, 38], [19, 38, 0], [28, 38, 19], [63, 255, 0], [159, 255, 127], [41, 165, 0], [103, 165, 82], [31, 127, 0], [79, 127, 63], [19, 76, 0], [47, 76, 38], [9, 38, 0], [23, 38, 19], [0, 255, 0], [127, 255, 127], [0, 165, 0], [82, 165, 82], [0, 127, 0], [63, 127, 63], [0, 76, 0], [38, 76, 38], [0, 38, 0], [19, 38, 19], [0, 255, 63], [127, 255, 159], [0, 165, 41], [82, 165, 103], [0, 127, 31], [63, 127, 79], [0, 76, 19], [38, 76, 47], [0, 38, 9], [19, 38, 23], [0, 255, 127], [127, 255, 191], [0, 165, 82], [82, 165, 124], [0, 127, 63], [63, 127, 95], [0, 76, 38], [38, 76, 57], [0, 38, 19], [19, 38, 28], [0, 255, 191], [127, 255, 223], [0, 165, 124], [82, 165, 145], [0, 127, 95], [63, 127, 111], [0, 76, 57], [38, 76, 66], [0, 38, 28], [19, 38, 33], [0, 255, 255], [127, 255, 255], [0, 165, 165], [82, 165, 165], [0, 127, 127], [63, 127, 127], [0, 76, 76], [38, 76, 76], [0, 38, 38], [19, 38, 38], [0, 191, 255], [127, 223, 255], [0, 124, 165], [82, 145, 165], [0, 95, 127], [63, 111, 127], [0, 57, 76], [38, 66, 76], [0, 28, 38], [19, 33, 38], [0, 127, 255], [127, 191, 255], [0, 82, 165], [82, 124, 165], [0, 63, 127], [63, 95, 127], [0, 38, 76], [38, 57, 76], [0, 19, 38], [19, 28, 38], [0, 63, 255], [127, 159, 255], [0, 41, 165], [82, 103, 165], [0, 31, 127], [63, 79, 127], [0, 19, 76], [38, 47, 76], [0, 9, 38], [19, 23, 38], [0, 0, 255], [127, 127, 255], [0, 0, 165], [82, 82, 165], [0, 0, 127], [63, 63, 127], [0, 0, 76], [38, 38, 76], [0, 0, 38], [19, 19, 38], [63, 0, 255], [159, 127, 255], [41, 0, 165], [103, 82, 165], [31, 0, 127], [79, 63, 127], [19, 0, 76], [47, 38, 76], [9, 0, 38], [23, 19, 38], [127, 0, 255], [191, 127, 255], [82, 0, 165], [124, 82, 165], [63, 0, 127], [95, 63, 127], [38, 0, 76], [57, 38, 76], [19, 0, 38], [28, 19, 38], [191, 0, 255], [223, 127, 255], [124, 0, 165], [145, 82, 165], [95, 0, 127], [111, 63, 127], [57, 0, 76], [66, 38, 76], [28, 0, 38], [33, 19, 38], [255, 0, 255], [255, 127, 255], [165, 0, 165], [165, 82, 165], [127, 0, 127], [127, 63, 127], [76, 0, 76], [76, 38, 76], [38, 0, 38], [38, 19, 38], [255, 0, 191], [255, 127, 223], [165, 0, 124], [165, 82, 145], [127, 0, 95], [127, 63, 111], [76, 0, 57], [76, 38, 66], [38, 0, 28], [38, 19, 33], [255, 0, 127], [255, 127, 191], [165, 0, 82], [165, 82, 124], [127, 0, 63], [127, 63, 95], [76, 0, 38], [76, 38, 57], [38, 0, 19], [38, 19, 28], [255, 0, 63], [255, 127, 159], [165, 0, 41], [165, 82, 103], [127, 0, 31], [127, 63, 79], [76, 0, 19], [76, 38, 47], [38, 0, 9], [38, 19, 23], [0, 0, 0], [45, 45, 45], [91, 91, 91], [137, 137, 137], [183, 183, 183], [179, 179, 179], False]
- draw_ellipse(center, semi_major, semi_minor, rotation, start, end)[source]
Draw an ellipse or elliptical arc.
- property fillcolor
- property layer
- property layerlist
- property linecolor
- property linetype
- property linewidth
- property pointsize
- property pointstyle
- property polystyle
yapcad.ezdxf_drawable module
- class yapcad.ezdxf_drawable.ezdxfDraw[source]
Bases:
Drawable- draw_ellipse(center, semi_major, semi_minor, rotation, start, end)[source]
Draw an ellipse or elliptical arc to DXF.
DXF ellipse is defined by: - center point - major axis endpoint relative to center - ratio of minor to major axis - start/end parameters (0 to 2*pi)
- draw_text(text, location, align=TextEntityAlignment.LEFT, attr={'height': 0.75, 'style': 'LiberationMono'})[source]
- property filename
- property linetype
yapcad.ezdxf_exporter module
DXF export utilities for yapCAD geometry.
Provides functions to export 2D geometry (region2d, curves, polylines) to DXF format using the ezdxf library via yapCAD’s ezdxfDraw drawable class.
Copyright (c) 2024 yapCAD contributors All rights reserved (MIT License)
- yapcad.ezdxf_exporter.is_2d_geometry(geom) bool[source]
Check if geometry is 2D (exportable to DXF as native entities).
Returns True for: - Points, lines, arcs, circles, ellipses - Polylines/polygons - Geometry lists (lists of the above) - Catmull-Rom and NURBS splines
Returns False for: - 3D solids - Surfaces - Unknown types
- yapcad.ezdxf_exporter.write_dxf(geometry, output_path: str, layer: str = 'PATHS') bool[source]
Export 2D geometry to a DXF file.
- Parameters:
geometry – yapCAD 2D geometry (region2d, curves, polylines, etc.)
output_path – Path to output DXF file (with or without .dxf extension)
layer – DXF layer name (default ‘PATHS’)
- Returns:
True if export succeeded, False otherwise.
Supported geometry types: - point: Exported as point entity - line: Exported as LINE entity - arc: Exported as ARC or CIRCLE entity - ellipse: Exported as ELLIPSE entity - polyline/polygon: Exported as series of LINE entities - catmullrom: Sampled and exported as polyline - nurbs: Sampled and exported as polyline - geomlist (region2d): All elements exported
- yapcad.ezdxf_exporter.write_dxf_multi(geometries: List[Any], output_path: str, layers: str | List[str] = 'PATHS') bool[source]
Export multiple geometry objects to a single DXF file.
- Parameters:
geometries – List of yapCAD 2D geometry objects
output_path – Path to output DXF file
layers – Layer name or list of layer names (one per geometry)
- Returns:
True if export succeeded, False otherwise.
yapcad.fasteners_legacy module
Parametric fastener helpers (threads + hex-cap screws).
- class yapcad.fasteners_legacy.HexCapScrewSpec(diameter: float, thread_length: float, shank_length: float, head_height: float, head_flat_diameter: float, washer_thickness: float = 0.5, washer_diameter: float | None = None, shank_diameter: float | None = None, starts: int = 1, thread_arc_samples: int = 180, thread_samples_per_pitch: int = 6)[source]
Bases:
objectDimensions (all millimeters) for
build_hex_cap_screw().
- class yapcad.fasteners_legacy.HexNutSpec(diameter: 'float', pitch: 'float', width_flat: 'float', thickness: 'float', handedness: 'str' = 'right', starts: 'int' = 1, thread_arc_samples: 'int' = 180, thread_samples_per_pitch: 'int' = 6)[source]
Bases:
object
- yapcad.fasteners_legacy.build_hex_cap_screw(profile: ThreadProfile, spec: HexCapScrewSpec)[source]
Create a watertight solid representing a hex cap screw.
- Parameters:
profile – External thread profile describing nominal diameter/pitch.
spec – Geometry parameters (all millimeters).
- yapcad.fasteners_legacy.build_hex_nut(profile: ThreadProfile, spec: HexNutSpec)[source]
- yapcad.fasteners_legacy.metric_hex_cap_screw(size: str, length: float, *, thread_length: float | None = None, starts: int = 1, thread_arc_samples: int = 180, thread_samples_per_pitch: int = 6)[source]
Return a hex screw for a metric size (e.g.
'M8').
- yapcad.fasteners_legacy.metric_hex_nut(size: str, *, starts: int = 1, handedness: str = 'right', thread_arc_samples: int = 180, thread_samples_per_pitch: int = 6)[source]
- yapcad.fasteners_legacy.unified_hex_cap_screw(size: str, length_in: float, *, thread_length_in: float | None = None, starts: int = 1, thread_arc_samples: int = 180, thread_samples_per_pitch: int = 6)[source]
Return a hex screw for a UNC/UNF imperial size (e.g.
'1/4-20').
yapcad.geom module
foundational computational geometry library for yapCAD
OVERVIEW
The yapcad.geom module provides foundational computational geometry functions for yapCAD. This includes operations for computing intersections, bounding boxes, inside-outside testing, etc., on both simple and compound geometry.
yapcad.geom geometric representations
The yapcad.geom module includes constants, scalar operations, vector operations, operations on non-compound geometry elements such as points, lines and arcs, as well as operations on compound geometry elements such as multi-vertex polylines and polygons, and arbitrary geometry lists.
constants
yapcad.geom provides the “constants” epsilon and pi2 (2*pi).
Redefine these at your peril.
scalars
Scalar numbers in yapCAD are ordinary Python3 int or float
numbers. This means that in general you will have ordinary
double-precision floating point dynamic range and precision for your
computational geometry operations. These precision limitations are
reflected in the empirically-chosen value of epsilon of 5E-6.
vectors
vectors are defined as a list of four numbers, i.e. [x,y,z,w]
When vectors in yapCAD are interpreted as three-dimensional coordinates (as opposed to lists of parameters) the “extra” w coordinate is a normalization factor. This approach is sometimes referred to as generalized homogeneous coordinates or projective coordinates, and was popular with computer graphicists in the 1990s. See https://en.wikipedia.org/wiki/Homogeneous_coordinates
In this interpretation, the w coordinate is a normalization coordinate, and is either 1.0 or all coordinates are assumed to be scaled by 1/w. The inclusion of the w coordinate allows the general use of transformation matrices for affine transforms.
The exception to the above statement is direction vectors, such as the
vector [1,0,0,0] that represents the direction of the x axis.
Direction vectors live in the w=0.0 plane and are subject to
rotation and scaling, but not translation.
There is a yapcad.geom convenience function, vect(), that will make
a vector out of just about any plausible set of arguments. Unspecified
w values are set to 1, and unspecified z values are set to 0.
yapcad.geom simple (non-compound) figures
points
Points are the simplest of the yapcad.geom figures. Ordinary
yapCAD geometry is assumed to lie in the w=1 hyperplane, and when
a vector lies in that plane it is usually interpreted as transformable
coordinate, or point. Because we expect w=1 unless certain types of
affine transforms have been applied, most yapCAD geometry
operations do not look at the w coordinate, and operate as though w=1.
Any vector that lies in the w>0 half-space is a valid coordinate, or
point. And in yapCAD, [x,y,z,w] corresponds to the same 3D
coordinate as [x/w,y/w,z/w,1]
yapcad.geom provides the point() convenience function that operates
much like vect(), except that point() enforces that w is always
greater than zero.
All of the following are examples of a yapcad.geom point:
pnt1 = point(0,0)
pnt2 = point(2.0,-2.0,5.0)
pnt3 = vect(0,0,0,1)
pnt4 = [1.0, 2.0, 3.0, 1.0]
lines
Lines are Python3 lists of two points, e.g. the following are all lines:
line1 = line(point(0,0),point(1,1))
line2 = line(point(-5,-5,-5),point(5,5,5))
line3 = [point(x1,y1,z1),point(x2,y2,z2)]
Lines are paramaterized over the interval 0 <= u <= 1 where u=0 corresponds to the first point, and u=1 corresponds to the second. Points on the interval between 0 and 1 are considered to be “inside” the line segment, and points outside the interval are still on the line, but not inside the line segment. This distinction is important for intersection calculations, among other operations.
Lines support all standard yapcad.geom computational geometry
operations. (see below)
bounding boxes
One special type of yapcad.geom line is a 3D bounding box. A
bounding box is a line that spans the “left lower bottom” to “right
upper top” of a figure, e.g. bbx =
[[xmin,ymin,zmin,1],[xmax,ymax,zmax,1]]. Bounding boxes are used
internally to speed up inside/outside testing and for a variety of
other purposes.
arcs
In yapcad.geom, an arc or circle is defined by a center, a radius, a
start angle, an end angle, and a normal that specifies the plane of
the arc/circle. Here are some examples of yapcad.geom arcs:
circle1 = arc(point(5.0,5.0),5.0) # full circle implied
circle2 = arc(point(5.0,5.0),5.0,0,360) # special values for start and end
notCirc = arc(point(5.0,5.0),5.0,90.0,450.0) # zero-length arc due to mod 360.0
semicirc1 = arc(point(0,0),10.0,90.0,270.0)
arc2 = arc(point(-1,1,10),1.0,-45.0,45.0,point(0,0,1),samplereverse=True)
Angles are specified in degrees and are right-handed, which is to say a positive angle specifies a counter-clockwise sweep.
A full circle is specified through special values of start and
end; If and only if start == 0 and end == 360 (both integer values)
then the arc is a full circle. NOTE: Other values for start and
end that span a 360 degree difference will actually produce a
zero-length arc, which is probably not what you want.
Arcs are paramaterized over an interval 0 <= u <=1, where u=0
corresponds to the point on the arc at the start angle, and u=1
corresponds to the point on the arc at the end angle (unless
samplereverse==True, see below). Parameters less than zero or
greater than one correspond to point on the circle outside the angular
interval between start and end. NOTE: In the special case of a
circle, the point at u=0 and u=1 is the same. Parameters which
correspond to angles greater than 360 degrees or less than zero
degrees “wrap around” to the corresponding angle modulus 360.
An arc is is represented as a list of one or two vectors and a
quasivector, e.g. [ center, [radius, start, end, -1 ], <normal>].
Most of the time, we assume that arcs lie in the x-y plane, which is
to say yapCAD assumes normal = [0,0,1] if it’s not
specified. NOTE: At present, yapCAD doesn’t support non-unit-z
normal vectors for arcs, though it will not stop you from specifying
one.
To mark that the second list element is a quasivector, we set the w component to a negative value. Since negative w values should never exist for points in our projective geometry system this should be a robust convention. For ordinary arcs, w=-1. For sample-reversed arcs (left-handed arcs, where u=0 begins at the end angle, and u=1 is the start angle) w=-2
NOTE: Sample-reverse arcs are left-handed with respect to the sampling parameter, not with respect to the specification of angles. This means that two arcs that are geometrically the same except for sampling order will have the beneficial property of having the same start and end values.
Arcs support all standard yapcad.geom computational geometry
operations. (see below)
yapcad.geom compound figures
polylines/polygons
A polyline is specified as a list of three or more points which define
a series of continuous line segments. A polygon is a list of four or
more coplanar points, where the first and last points are coincident,
i.e. dist(points[0],points[-1]) < epsilon. Here are some
examples:
plyline1 =[point(-5,-5),point(5,-5),point(0,5),point(0,10)]
plygon1 =[point(-5,-5),point(5,-5),point(0,5),point(-5,-5)]
Polylines are parameterized in much the same way as lines. Values 0 <= u <=1 correspond to points along the polyline or polygon between the start and end points. In the case of the non-closed polyline, values of u<0 correspond to points on the line in the negative u parameter space of the first line segment, and values of u>1 correspond to points on the line in the u>1 space of the last line segment.
Polygons are parameterized in the same way, with the exception that,
like circles, the value at u=0 and u=1 are the same, and u
values outside the [1,0] interval “wrap around” (are subject to u
% 1.0) and thus always return a point on the line segments that make
up the polygon.
Polygons with positive area are defined in right-hand (counterclockwise) order. A polygon with left-hand point order has negative area, and implies a hole in a larger surface.
Polylines and polygons support all standard yapcad.geom
computational geometry operations. (see below)
geometry lists
Geometry lists are pretty much exactly what they sound like, which is
to say a Python3 list of other yapcad.geom elements. There is
nothing enforcing continuity of elements in a geometry list, so if
continuity, coplanar elements, a closed representation, etc. are
required, these constraints must be checked or enforced by the
functions that operate on them.
Even though there is no inherent continuity constraint, geometry lists do support element-ordered sampling, unsampling, and intersection, as well as bounding box calculation and even inside-outside testing, though the results of such testing will only make sense for geometry lists composed of closed elements.
Geometry lists are paramaterized a bit like polylines, except that there is no guarantee of continuity.
COMPUTATIONAL GEOMETRY OPERATIONS
The primary purpose of the yapcad.geom module is to support
computational geometry operations on two-dimensional figures in
three-dimensional space.
All of the yapcad.geom geometry representations, or figures,
described here support the following operations:
length(x)– return the scalar length of figurexcenter(x)– return the center point of figurexbbox(x)– return the three-dimensional bounding box ofxsample(x,u)– parameterizing figurexover the closed interval [0,1], return the point onxcorresponding to the parameteru.unsample(x,p)– given a pointpand figurex, parameterizingxover the closed interval [0,1], return the parameter u resulting in the point closest top, orFalseif no point onxlies within epsilon ofp. FIXME: Unsampling of geometry lists is currently unimplemented.segment(x,u1,u2)– given a figurexand two scalar parametersu1 != u2 and u1 >= 0 and u2 >= 0 and u1 <= 1 and u2 <= 1, return a new figure sliced from the original figure spanning the specified sampling interval.isinsideXY(x,p)– for figurexand pointpthat lie in the same XY plane, determine whetherplies within epsilon of the interior of figurex. In the case wherexis a point, line, or polyline where there is no two-dimensional interior defined, determine ifplies on or within epsilon of the 0 <= u <=1 parameter domain of figurex.intersectXY(g1,g2,inside=True,params=False)– Compute the intersections of the two figuresg1andg2that lie in the same XY plane. If parameterinside == True, then the intersection is only considered valid if it lies within the parameter domain 0 <= u <= 1 for each figure. Return a list of intersection points, or the boolean valueFalseif there are none. Ifparams==True, then return a list of intersection parameter values for each figure, orFalseif there are no intersections.
In addition to the above, yapcad.geom supports following affine
transformation operations for all figures:
scale(x,sx=1.0,sy=False,sz=False,cent=point(0,0))– scale the figurex, either uniformly or by specified factors in x, y, and z. Returns a new scaled figure.translate(x,delta)– translate the figurexby the specifieddeltavector. Returns a new translated figure.rotate(x,ang,cent=point(0,0),axis=point(0,0,1.0))– rotate the figurexby angleangdegrees about pointcentand axisaxis. Returns a new rotated figure.mirror(x,plane)– mirror the figurexby the axis-aligned, origin-intersecting plane specified by the stringplane in ['xy','yz','xz']. FIXME: Allow for the specification of an arbitrary plane described by an intersection point and a normal, or by three points in space. Return a new mirrored figure.transform(x,m)– apply the arbitrary transformation specified by matrixm(see the documentation for yapcad.xform) to figurex. Return a new transformed figure.
specialized computational geometry operations
operations on points
Points are defined as vectors that lie in a positive, non-zero hyperplane, i.e. [x, y, z, w] such that w > 0. points are distinguished from quasivectors, such as the parameters to an arc, which don’t transform as vectors.
Quasivectors, by contrast, lie in a w < 0 hyperplane. For example, by convention right-handed arc parameters lie in the quasivector w=-1 hyperplane.
The yapcad.geom module provides a relatively full set of vector
operations for adding, subtracting, computing inner and outer
products, scaling, etc., including versions that treat
yapcad.geom points/vectors as 3 vectors and versions that treat
them as 4 vectors.
Other notable computational geometry operations on points:
barycentricXY(a,p1,p2,p3):– Given a pointaand three verticesp1,p2, andp3, all of which fall into the same XY plane, compute the barycentric coordinates lam1, lam2, and lam3 and return them as a list.
operations on lines
There are several line-specific computational geometry operations, notably:
linePointXY(l,p,inside=True,distance=False,params=False)– For a pointpand a linelthat lie in the same XY plane, compute the point onlthat is closest top, and return that point. Ifinsideis true, then return the closest distance point between the point and the line segment. Ifdistanceis true, return the closest distance, not the point. Ifparamsis true, return the sampling parameter value of the closest point.linePointXYDist(l,p,inside=True)– Convenience function wrapping fast point-line distance calculation usinglinePointXY()
operations on arcs
In addition to the standard operations, there are several arc-specific computational geometry operations, notably:
lineArcIntersectXY(l,c,inside=True,params=False)– Value safe function to compute the intersection of a lineland an arccthat lie in the same XY plane. Ifinside == Trueonly return intersections that lie within the line and arc segment, otherwise treat the line as infinite and the arc as a circle. Return a list of intersection points, or ifparams == Truereturn a list of intersection parameters instead.circleCircleTangentsXY(c0,c1)– Value-safe function to compute tangent lines to two coplanar circlesc0andc1lying in the same XY plane. Function will either return two lines orFalse, if the center of the circles are too close together.
operations on polylines and polygons
In addition to the standard operations, there are several polyline- and polygon-specific computational geometry operations, notably:
samplepoly(a,u)– Sample the polyaat parameteru, where u is mapped proportionally across the length of all line segments, and return the resulting point. Ifais a closed polygon, then sample atu % 1.0, such that samples outside the [0,1] interval “wrap around”. Ifais not closed andu<0, then samples are drawn from the first line in theu<0paramter space of that line. Ifais not closed andu>1, then samples are drawn from the last line in theu>1paramter space of that line.
- yapcad.geom.arc(c, rp=False, sn=False, e=False, n=False, samplereverse=False)[source]
Construct an arc by copying an eisting arc or specifying a center
cand various optional parameters.
- yapcad.geom.arcArcIntersectXY(c1, c2, inside=True, params=False)[source]
Value-safe function to compute the intersection of two arcs that lie in the same XY plane. If
inside == True, only count intersections within the arc segments. Ifinside == False, then treat the arcs as circles for intersection calculation. Return a list of the intersection points, or ifparams==Truereturn a list of the intersection parameters for each arc.
- yapcad.geom.arccenter(c)[source]
return the midpoint of an arc. In the special case of a complete circle, return the center of the circle.
- yapcad.geom.barycentricXY(a, p1, p2, p3)[source]
Given a point
aand three verticesp1,p2, andp3, all of which fall into the same XY plane, compute the barycentric coordinates lam1, lam2, and lam3
- yapcad.geom.bbox(x)[source]
Given a figure x, return the three-dimensional bounding box of the figure.
- yapcad.geom.bezier(control_points)[source]
Return a Bezier curve definition.
Creates a Bezier curve from control points. The curve passes through the first and last control points, with intermediate control points influencing the curve shape without being interpolated.
- Parameters:
control_points (list) – List of 2-4 control points. Length determines curve degree: - 2 points: linear Bezier (straight line) - 3 points: quadratic Bezier - 4 points: cubic Bezier (most common) More than 4 points are supported for higher-degree curves.
- Returns:
Bezier curve definition:
['bezier', [points], {'degree': n}]- Return type:
Examples
>>> # Create a cubic Bezier curve >>> cp = [point(0, 0), point(10, 20), point(30, 20), point(40, 0)] >>> curve = bezier(cp)
>>> # Create a quadratic Bezier curve >>> cp = [point(0, 0), point(15, 30), point(30, 0)] >>> curve = bezier(cp)
Notes
Bezier curves are widely used in vector graphics and CAD systems. The curve is tangent to the control polygon at both endpoints. The degree of the curve is len(control_points) - 1.
- yapcad.geom.bspline(control_points, *, degree=3, closed=False)[source]
Return a B-spline curve definition.
Creates a B-spline curve from control points. B-splines provide local control - moving one control point only affects a limited portion of the curve, making them ideal for complex smooth curves.
- Parameters:
control_points (list) – List of control points (minimum degree+1 points required).
degree (int, optional) – Degree of the B-spline curve (default 3 for cubic). - degree=2: quadratic B-spline - degree=3: cubic B-spline (most common, C2 continuous)
closed (bool, optional) – If True, create a closed (periodic) B-spline (default False).
- Returns:
B-spline curve definition:
['bspline', [points], metadata]- Return type:
Examples
>>> # Create an open cubic B-spline >>> cp = [point(0, 0), point(10, 20), point(20, -10), ... point(30, 15), point(40, 0)] >>> curve = bspline(cp, degree=3)
>>> # Create a closed B-spline for smooth loop >>> cp = [point(0, 0), point(10, 20), point(20, 0), point(10, -20)] >>> curve = bspline(cp, degree=3, closed=True)
Notes
Unlike Bezier curves which use all control points for each evaluation, B-splines only use degree+1 nearby control points. This gives: - Local control: changes affect only nearby curve segments - Uniform smoothness along the entire curve - C^(degree-1) continuity for uniform knot vectors
The B-spline is internally represented using NURBS with uniform weights.
- yapcad.geom.catmullrom(points, closed=False, alpha=0.5)[source]
Return a Catmull-Rom spline definition.
Catmull-Rom splines are interpolating splines that pass through all control points, making them ideal for smooth curves through specific waypoints. They provide C1 continuity (continuous first derivative).
- Parameters:
points (list) – List of control points to interpolate. The spline passes through all points. Requires at least 2 points.
closed (bool, optional) – If True, create a closed loop connecting the last point back to the first (default False).
alpha (float, optional) – Tension parameter controlling curve shape (default 0.5): - alpha=0.0: uniform parameterization (standard Catmull-Rom) - alpha=0.5: centripetal (no loops/cusps, recommended) - alpha=1.0: chordal parameterization
- Returns:
Catmull-Rom spline definition:
['catmullrom', [points], metadata]- Return type:
Examples
>>> # Create a smooth curve through waypoints >>> pts = [point(0, 0), point(10, 20), point(30, 15), point(40, 5)] >>> curve = catmullrom(pts)
>>> # Create a closed loop with centripetal parameterization >>> pts = [point(0, 0), point(10, 10), point(10, -10), point(0, -20)] >>> loop = catmullrom(pts, closed=True, alpha=0.5)
Notes
Unlike Bezier and B-splines, Catmull-Rom splines interpolate all control points rather than approximating them. The centripetal parameterization (alpha=0.5) is recommended as it avoids loops and self-intersections in the curve.
- yapcad.geom.circleCircleTangentsXY(c0, c1)[source]
Value-safe function to compute tangent lines to two coplanar circles
c0andc1lying in the same XY plane. Function will either return two lines orFalse, if the center of the circles are too close together.
- yapcad.geom.cross(a, b)[source]
Compute the cross generalized product of a x b, assuming that both fall into the w=1 hyperplane
- yapcad.geom.ellipse(center, semi_major, semi_minor, *, rotation=0.0, start=0, end=360, normal=None)[source]
Return an ellipse curve definition.
- Parameters:
center (point) – Center point of the ellipse.
semi_major (float) – Semi-major axis length (must be >= semi_minor).
semi_minor (float) – Semi-minor axis length.
rotation (float, optional) – Rotation of major axis from x-axis in degrees (default 0).
start (float, optional) – Start angle in degrees (default 0).
end (float, optional) – End angle in degrees (default 360 for full ellipse).
normal (point, optional) – Normal vector for 3D orientation (default [0,0,1,0]).
- Returns:
Ellipse definition:
['ellipse', center, metadata_dict]- Return type:
Notes
The ellipse is parameterized so that angle=0 corresponds to the positive major axis direction. Angles increase counter-clockwise. When start=0 and end=360, a full ellipse is created.
- yapcad.geom.ellipse_length(e, segments=100)[source]
Approximate the arc length of an ellipse using numerical integration.
- yapcad.geom.homo(a)[source]
Homogenize, or project back to the w=1 plane by scaling all values by w
- yapcad.geom.hyperbola(center, semi_major, semi_minor, *, rotation=0.0, start=-2.0, end=2.0, branch=1, normal=None)[source]
Return a hyperbola curve definition.
- Parameters:
center (point) – Center point of the hyperbola.
semi_major (float) – Semi-major axis length (a), the distance from center to vertex.
semi_minor (float) – Semi-minor axis length (b), determines the opening angle.
rotation (float, optional) – Rotation of the major axis from the x-axis in degrees (default 0).
start (float, optional) – Start parameter value (default -2.0).
end (float, optional) – End parameter value (default 2.0).
branch (int, optional) – Which branch to use: 1 for right branch (+x), -1 for left branch (-x). Default is 1.
normal (point, optional) – Normal vector for 3D orientation (default [0,0,1,0]).
- Returns:
Hyperbola definition:
['hyperbola', center, metadata_dict]- Return type:
Notes
The hyperbola is defined as: x² / a² - y² / b² = 1 Parametric form: x = a * cosh(t), y = b * sinh(t) The parameter t ranges from start to end. At t=0, the point is at (a, 0).
- yapcad.geom.hyperbola_bbox(h, segments=50)[source]
Compute the bounding box of a hyperbola segment.
- yapcad.geom.hyperbola_length(h, segments=100)[source]
Approximate the arc length of a hyperbola segment using numerical integration.
- yapcad.geom.hyperbola_sample(h, u)[source]
Evaluate a point on a hyperbola at parameter u in [0, 1].
- yapcad.geom.hyperbola_tangent(h, u)[source]
Return the tangent vector at parameter u on a hyperbola.
- yapcad.geom.intersectSimpleXY(g1, g2, inside=True, params=False)[source]
value-safe function that determines the intersection of two XY-coplanar non-compound geometric figures
- yapcad.geom.intersectXY(g1, g2, inside=True, params=False)[source]
given two XY-coplanar figures, calculate the intersection of these two figures, and return a list of intersection points, or False if none. If
inside == True, only return intersections that are within the0 <= u <= 1.0interval for both figures. Ifparams == True, instead of returning a list of points, return two lists corresponding to the sampling parameter value of the intersections corresponding to each figure.
- yapcad.geom.isCardinalPlanar(plane='xy', points=[])[source]
utility function to determine if a list of points lies in the specified # cardinal plane, one of XY, YZ, XZ
- yapcad.geom.isclosedgeomlist(a)[source]
Determine if geometry list
ais closed, which is to say determine if the geometry list is continuous and the distance betweensample(a,0.0)andsample(a,1.0)is less than epsilon. NOTE: This test will not detemrine if this geometry list representes a simple closed figure as there could be any number of self intersections.NOTE: The special case of
a==[]will causeisclosedgeomlist(a)to returnTrue, so that set operations such as intersection or difference operations which return an empty result will still be considered valid closed geometry for further operations.
- yapcad.geom.iscontinuousgeomlist(a)[source]
deterine if geometry list
aposesses C0 continuity over sampling interval [0.0,1.0].
- yapcad.geom.isgoodnum(n)[source]
determine if an argument is actually a scalar number, and not boolean
- yapcad.geom.isinsideXY(x, p)[source]
for an XY-coplanar point and figure, determine if the point lies inside the figure. In the case of non-closed figures, such as lines, determine if the point lies within epsilon of one of the lines of the figure.
- yapcad.geom.isinsidearcXY(c, p)[source]
Determine if point
plies on (within epsilon of) the arc ``c`. In the special case wherecis a circle, determine if pointplies anywhere on or inside the circle.
- yapcad.geom.isinsidelineXY(l, p)[source]
inside testing for line – only true of point lies on line, to within epsilon.
- yapcad.geom.isinsidepointXY(x, p)[source]
inside testing for points. Only true if points are the same within epsilon
- yapcad.geom.isinsidepolyXY(a, p)[source]
Determine if point
plies on (within epsilon of) the polyline ``a`. In the case whereais a closed polygon, determine if pointplies anywhere within the polygon by even-odd line intersection method.
- yapcad.geom.lineArcIntersectXY(l, c, inside=True, params=False)[source]
Value safe function to compute the intersection of a line
land an arccthat lie in the same XY plane. Ifinside == Trueonly return intersections that lie within the line and arc segment, otherwise treat the line as infinite and the arc as a circle. Return a list of intersection points, or ifparams == Truereturn a list of intersection parameters instead.
- yapcad.geom.lineLineIntersectXY(l1, l2, inside=True, params=False)[source]
Compute the intersection of two lines that lie in the same XY plane. NOTE: It’s usually preferable to use the generalized
intersectXY()function than this non-type-safe, line-specific one.
- yapcad.geom.linePointXY(l, p, inside=True, distance=False, params=False)[source]
For a point
pand a linelthat lie in the same XY plane, compute the point onlthat is closest top, and return that point. Ifinsideis true, then return the closest distance point between the point and the line segment. Ifdistanceis true, return the closest distance, not the point. Ifparamsis true, return the sampling parameter value of the closest point.
- yapcad.geom.linePointXYDist(l, p, inside=True)[source]
Convenience function wrapping point-line distance calculation using
linePointXY()
- yapcad.geom.mirror(x, plane)[source]
return a mirrored version of a figure. Currently, the following values of “plane” are allowed: ‘xz’, ‘yz’, xy’. Generalized arbitrary reflection plane specification will be added in the future.
NOTE: this operation will reverse the sign of the area of
xif x is a closed polyline or geometry list
- yapcad.geom.nurbs(control_points, *, degree=3, weights=None, knots=None)[source]
Return a NURBS curve definition.
Non-Uniform Rational B-Splines (NURBS) are the most general curve representation, combining the features of B-splines with rational weights to enable exact representation of conic sections (circles, ellipses, etc.) and provide additional shape control.
- Parameters:
control_points (list) – List of control points (minimum degree+1 points required).
degree (int, optional) – Degree of the NURBS curve (default 3 for cubic).
weights (list of float, optional) – Weight for each control point. Higher weights pull the curve closer to that point. If None, uniform weights of 1.0 are used (reduces to standard B-spline). Must match number of control points.
knots (list of float, optional) – Knot vector defining parameter space partitioning. If None, an open uniform knot vector is generated. Length must be n + degree + 1 where n is the number of control points.
- Returns:
NURBS curve definition:
['nurbs', [points], metadata]- Return type:
Examples
>>> # Create a NURBS curve with uniform weights (equivalent to B-spline) >>> cp = [point(0, 0), point(10, 20), point(30, 20), point(40, 0)] >>> curve = nurbs(cp, degree=3)
>>> # Create a weighted NURBS curve with stronger pull to middle points >>> cp = [point(0, 0), point(10, 20), point(30, 20), point(40, 0)] >>> weights = [1.0, 2.0, 2.0, 1.0] >>> curve = nurbs(cp, degree=3, weights=weights)
>>> # Specify custom knot vector for precise control >>> cp = [point(0, 0), point(10, 20), point(30, 20), point(40, 0)] >>> knots = [0, 0, 0, 0, 1, 1, 1, 1] # Clamped at endpoints >>> curve = nurbs(cp, degree=3, knots=knots)
Notes
NURBS are the industry standard for CAD systems because they can exactly represent both free-form curves and analytical shapes like circles and ellipses. The weights provide an additional degree of freedom beyond B-splines, enabling precise control over curve shape.
When all weights are equal (or None), NURBS reduce to standard B-splines. The knot vector controls parameter space distribution - clamped knot vectors make the curve pass through the first and last control points.
- yapcad.geom.orthoXY(a)[source]
compute an orthogonal vector to vector
awhich lies in an XY plane by crossing [a1, a2, a3] with [0, 0, 1]
- yapcad.geom.parabola(vertex, focal_length, *, rotation=0.0, start=-10.0, end=10.0, normal=None)[source]
Return a parabola curve definition.
- Parameters:
vertex (point) – Vertex point of the parabola (the point closest to the focus).
focal_length (float) – Distance from vertex to focus (must be positive). The parabola opens in the positive x-direction (before rotation).
rotation (float, optional) – Rotation of the parabola axis from the x-axis in degrees (default 0).
start (float, optional) – Start parameter value (default -10.0).
end (float, optional) – End parameter value (default 10.0).
normal (point, optional) – Normal vector for 3D orientation (default [0,0,1,0]).
- Returns:
Parabola definition:
['parabola', vertex, metadata_dict]- Return type:
Notes
The parabola is defined as: x = t²/(4p), y = t, where p is the focal length. The parameter t ranges from start to end. At t=0, the point is at the vertex. Positive t values move in the positive y-direction, negative in the negative.
- yapcad.geom.parabola_length(p, segments=100)[source]
Approximate the arc length of a parabola segment using numerical integration.
- yapcad.geom.pointbbox(x)[source]
compute 3D bounding box of point, which is 2 epsilon on a side. Note, this guarantees that two points that are wtihin epsilon of eachother will be within each other’s bbox
- yapcad.geom.poly(*args)[source]
Make a polyline or polygon by copying an existing poly or from a list of points or individual points
- yapcad.geom.polycenter(a)[source]
Compute center of poly
a. Ifais closed, return barycentric center of figure. Ifais not closed, return sampling midpoint.
- yapcad.geom.rotate(x, ang, cent=[0, 0, 0, 1], axis=[0, 0, 1.0, 1], mat=False)[source]
return a rotated version of the figure
- yapcad.geom.sample(x, u)[source]
Given a figure x and a parameter u, return the point on the figure corresponding to the specified sampling parameter.
- yapcad.geom.samplearc(c, u, polar=False)[source]
sample the arc
cat parameteruand return the resulting point. Ifpolaris true, return polar coordinates of angle and radius with cartesian center.
- yapcad.geom.sampleline(l, u)[source]
Sample a parameterized line
l. Values 0 <= u <= 1.0 will fall within the line segment, values u < 0 and u > 1 will fall outside the line segment.
- yapcad.geom.samplepoint(x, u)[source]
whatever parameter you pass to sampling a point, you get the same point
- yapcad.geom.samplepoly(a, u)[source]
Sample the poly
aat parameteruand return the resulting point. Ifais a closed polygon, then sample atu % 1.0. Ifais not closed andu<0, then samples are drawn from the first line in theu<0paramter space of that line. Ifais not closed andu>1, then samples are drawn from the last line in theu>1paramter space of that line.
- yapcad.geom.scale(x, sx=1.0, sy=False, sz=False, cent=[0, 0, 0, 1], mat=False)[source]
return a scaled version of the figure
- yapcad.geom.segment(x, u1, u2)[source]
given a figure x, create a new figure spanning the specified interval in the original figure
- yapcad.geom.segmentarc(c, u1, u2)[source]
Given an arc paramaterized on a 0,1 interval, return a new arc with the same center and radius spanning the interval u1,u2
- yapcad.geom.segmentline(l, u1, u2)[source]
slice out a parameterized segment from a line and return this as a new line segment
- yapcad.geom.segmentpoly(a, u1, u2)[source]
slice out a parameterized segment from polyline or polygon
aand return this as a new polyline
- yapcad.geom.transform(x, m)[source]
return a transformed version of the figure, as specified by the transformation matrix m
- yapcad.geom.unsample(x, p)[source]
Invert the sampling operation: return the parameter corresponding to the closest point on the figure to p as long as the distance is less than epsilon.
- yapcad.geom.unsamplearc(c, p)[source]
unsample the arc
cat pointp, which is to day given a point that is on the circle, return it’s corresponding sample parameter, or False if the point is more than epsilon from the circle.
- yapcad.geom.unsamplegeomlist(gl, p)[source]
anlogous to the unsampleline() and unsamplearc() functions, given a point on a poly, return the corresponding sample parameter, or False if the point is more than epsilon away from any poly line segment
- yapcad.geom.unsampleline(l, p)[source]
function to “unsample” a line – given a point on a line, provide the corresponding parametric value. Return False if the distance of the point from the line is greater than epsilon
- yapcad.geom.unsamplepoly(a, p)[source]
anlogous to the unsampleline() and unsamplearc() functions, given a point on a poly, return the corresponding sample parameter, or False if the point is more than epsilon away from any poly line segment
yapcad.geom3d module
- yapcad.geom3d.addTri2Surface(tri, s, check=False, nfunc=<function normfunc>)[source]
Add triangle
tri(a list of three points) to a surfaces, returning the updated surface. NOTE: There is no enforcement of contiguousness or coplainarity – this function will add any triangle.
- yapcad.geom3d.bbox(x)[source]
Given a figure, surface, or solid x, return the three-dimensional bounding box of that entity.
- yapcad.geom3d.center(x)[source]
Return the point corresponding to the center of surface, solid, or figure x.
- yapcad.geom3d.issolid(s, fast=True)[source]
Check to see if
sis a solid. NOTE: this function only determines if th data structure is correct, it does not verify that the collection of surfaces completely bounds a volume of space without holes
- yapcad.geom3d.issolidclosed(x)[source]
Check if solid x is topologically closed.
A solid is closed if and only if every edge is shared by exactly two faces across all surfaces. This ensures no holes or gaps exist in the solid’s boundary.
The function analyzes face adjacency by: 1. Building a global edge map using vertex positions (not indices) 2. Counting how many faces share each edge 3. Verifying that every edge is shared by exactly 2 faces
- Parameters:
x – A solid data structure
- Returns:
True if the solid is topologically closed, False otherwise
- Raises:
ValueError – if x is not a valid solid
Example
>>> from yapcad.geom3d_util import prism, sphere >>> cube = prism(2, 2, 2) >>> issolidclosed(cube) True
- yapcad.geom3d.linePlaneIntersect(lne, plane='xy', inside=True)[source]
Function to calculate the intersection of a line and a plane.
lineis specified in the usual way as two points.planeis either specified symbolicly as one of["xy","yz","xz"], a list of three points, or a planar coordinate system in the form of[p0,n,forward,reverse], wherep0specifies the origin in world coordinates,nis the normal (equivalent to thezvector), andforwardandreverseare transformation matricies that map from world into local and local into world coordinates respectively.Returns
Falseif the line and plane do not intersect, or ifinside==Trueand the point of intersection is outside the line interval. Returns the point of intersection otherwise.NOTE: if plane is specified as three points, then setting
inside=Truewill also force a check to see if the intersection point falls within the specified triangle.
- yapcad.geom3d.mirror(x, plane)[source]
return a mirrored version of a figure. Currently, the following values of “plane” are allowed: ‘xz’, ‘yz’, xy’. Generalized arbitrary reflection plane specification will be added in the future.
NOTE: this operation will reverse the sign of the area of
xif x is a closed polyline or geometry list
- yapcad.geom3d.mirrorsurface(s, plane)[source]
return a mirrored version of a surface. Currently, the following values of “plane” are allowed: ‘xz’, ‘yz’, xy’. Generalized arbitrary reflection plane specification will be added in the future.
Note that this is a full surface geometry reflection, and not simply a normal reverser.
- yapcad.geom3d.poly2surface(ply, holepolys=[], minlen=0.5, minarea=0.0001, checkclosed=False, basis=None)[source]
Given
ply, a coplanar polygon, return the triangulated surface representation of that polygon and its boundary. Ifholepolysis not the empty list, treat each polygon in that list as a hole inply. Ifcheckclosedis true, make sureplyand all members ofholepolysare a vaid, closed, coplanar polygons. ifboxexists, use it as the bounding box.if
basisexists, use it as the planar coordinate basis to transform the poly into the z=0 plane.Returns surface and boundary
- yapcad.geom3d.poly2surfaceXY(ply, holepolys=[], minlen=0.5, minarea=0.0001, checkclosed=False, box=None)[source]
Given
ply, return a triangulated XY surface (holes supported).
- yapcad.geom3d.rotate(x, ang, cent=[0, 0, 0, 1], axis=[0, 0, 1.0, 1], mat=False)[source]
return a rotated version of the surface, solid, or figure
- yapcad.geom3d.rotatesurface(s, ang, cent=[0, 0, 0, 1], axis=[0, 0, 1.0, 1], mat=False)[source]
return a rotated copy of the surface
- yapcad.geom3d.scale(x, sx=1.0, sy=False, sz=False, cent=[0, 0, 0, 1])[source]
Return a scaled version of the surface, solid, or figure.
- Parameters:
- Returns:
A scaled copy of the input geometry.
- Return type:
- yapcad.geom3d.scalesolid(x, sx=1.0, sy=False, sz=False, cent=[0, 0, 0, 1])[source]
Return a scaled copy of the solid.
- Parameters:
x (solid) – The solid to scale.
sx (float) – Scale factor for x-axis, or uniform scale if sy and sz are False.
sy (float or False) – Scale factor for y-axis, or False for uniform scaling.
sz (float or False) – Scale factor for z-axis, or False for uniform scaling.
cent (point) – Center point for scaling. Default is origin.
- Returns:
A scaled copy of the input solid.
- Return type:
Notes
BREP data is only scaled for uniform scaling (sx == sy == sz). Non-uniform scaling will preserve the mesh but not the BREP representation.
- yapcad.geom3d.scalesurface(s, sx=1.0, sy=False, sz=False, cent=[0, 0, 0, 1])[source]
Return a scaled copy of the surface.
- Parameters:
s (surface) – The surface to scale.
sx (float) – Scale factor for x-axis, or uniform scale if sy and sz are False.
sy (float or False) – Scale factor for y-axis, or False for uniform scaling.
sz (float or False) – Scale factor for z-axis, or False for uniform scaling.
cent (point) – Center point for scaling. Default is origin.
- Returns:
A scaled copy of the input surface.
- Return type:
- yapcad.geom3d.signedFaceDistance(p, face)[source]
given a test point
pand a three-point faceface, determine the minimum signed distance of the test point from the face. Any point lying in the positive normal direction or on the surface of the plane will result in a zero or positive distace. Any point lying in the negative normal direction from the surface of the plane will result in a negative distance.
- yapcad.geom3d.signedPlaneDistance(p, p0, n)[source]
Given a point on the plane
p0, and the unit-length plane normaln, determine the signed distance to the plane.
- yapcad.geom3d.solid(*args)[source]
given a solid or a list of solid parameters as arguments, return a conforming solid representation. Checks arguments for data-type correctness.
- yapcad.geom3d.solid_boolean(a, b, operation, tol=1e-07, *, stitch=False, engine=None)[source]
Perform a boolean operation (union, intersection, difference) on two solids.
Engine selection: - If
engineparameter orYAPCAD_BOOLEAN_ENGINEenv var is set,that engine is used explicitly (backward compatible behavior).
Otherwise, auto-selects OCC BREP engine when available and both solids have BREP metadata, falling back to mesh engine on failure or when BREP data is missing.
Fallback mesh engine is selectable via
YAPCAD_MESH_BOOLEAN_ENGINEenv var (defaults to ‘native’).
Environment variables: -
YAPCAD_BOOLEAN_ENGINE: Force specific engine (‘native’, ‘trimesh’, ‘occ’) -YAPCAD_MESH_BOOLEAN_ENGINE: Fallback mesh engine (‘native’ or ‘trimesh’) -YAPCAD_TRIMESH_BACKEND: Backend for trimesh engine (e.g., ‘manifold’, ‘blender’)
- yapcad.geom3d.solids_intersect(a, b, tol=1e-07)[source]
geom3d – functional 3D geometry representation for yapCAD
The geometric representations of point, line, arc, poly, and geomlist provided by
yapcad.geomare suitable for representing zero- or one-dimensional figures embedded in a three-dimensional space. And while there is no requirement that the representations provided byyapcad.geom(such as an arc, line, or polyline) lie in the XY plane, many of the functions in yapcad.geom are explicitly intended to perform computational geometry operations on XY-planar entities.Further, while a closed figure described by
yapcad.geommay implicitly bound a two-dimensional face, there is no direct support for working with two-dimensional surfaces provided by that module. There is no direct support of any kind for working with three-dimemnsional volumes inyapcad.geom.In this module we specify representations for two-dimensional surfaces and bounded three-dimensional volumes, and provide tools for working with them in implicit, parametric form as well as in explicit, triangulated form.
The goal of the
geom3d.yapcad moduleis to allow for the construction of two-dimensinal surfaces and three-dimensional geometry for the purposes of modeling, computational geometry, and rendering. Specifically, we wish to support the following:(1) Support the implicit representation of three-dimensional geometry, and the performance of constructive solid geometry operations on this implicit geometry (union, intersection, difference) to produce more complex implicit three dimensional forms.
(2) Support the implicit representation of two dimensional surfaces, such as a planar surface specified by three points, or the surface of a three-dimensional object like a sphere, and allow for computational geometry operations on these surfaces, such as intersection operations, to produce explicit one-dimensional objects, such as lines, arcs, etc.
(3) support the conversion of an implicit two-dimensional surface to an explicit, teselated triangluar geometry that may be easily rendered using a conventional 3D graphics rendering pipline, such as OpenGL
(4) Support for the conversion of implicit three-dimenaional constructive solid geometry into an explicit, contiguous closed surface representation using the marching cubes algortihm, or any other user-specified conversion algoritm, for the purposes of interactive 3D rendering and conversion to 3D CAM formats, such as STL.
Structures for 2D/3D geometry
surfaces
surface = ['surface',vertices,normals,faces,boundary,holes], where:verticesis a list ofyapcad.geompoints,normalsis a list ofyapcad.geomdirection vectors of the same length asvertices,facesis the list of faces, which is to say lists of three indices that refer to the vertices of the triangle that represents each face,boundaryis a list of indices for the vertices that form the outer perimeter of the surface, or [] if the surface has no boundary, such as that of a torus or sphereholesis a (potentially zero-length) list of lists of holes, each of which is a non-zero list of three or more indices of vertices that form the perimeter of any holes in the surface.A surface has an inside and an outside. To deterine which side of a surface a point lies on, find the closest face and determine if the point lies on the positive or negative side of the face.
Solids
To represent a completely bounded space (a space for which any point can be unambiguously determined to be inside or outside) there is the
solidrepresentation. A solid is composed of zero or more surfaces, and may be completely empty, as empty solids are legal products of constructive solid geometry operations like intersection and difference.The gurantee, which is not enforced by the representation, is that for any point inside the bounding box of the solid, and for any point chosen outside the bounding box of the solid, a line drawn between the two will have either even (or zero), or odd point intersections (as opposed to tangent intersections), regardless of the choice of the outside-the-bounding-box point.
Solids have optional associated metadata about the material properties of the solid and about how it was constructed.
For example, material properties might include OpenGL-type rendering data, mechanical properties, or a reference to a material dictionary that includes both.
Construction meta-data might include the model-file and material-file name from which the geometry was loaded, the polygon from which the solid was extruded (and associated extrusion parameters), or the function call with parameters for algorithmically-generated geometry.
solid = ['solid', surfaces, material, construction ], where:surfacesis a list of surfaces with contiguous boundaries that completely encloses an interior space,materialis a list of domain-specific representation of the material properties of the solid, which may be empty. This information may be used for rendering or simulating the properties of the solid.constructionis a list that contains information about how the solid was constructed, and may be emptyTopology Analysis
Two key functions are provided for analyzing solid topology:
issolidclosed(solid)– Verifies that a solid is topologically closed by ensuring every edge is shared by exactly two faces across all surfaces. This is essential for determining if a solid properly encloses a volume without gaps or holes. Returns True if closed, False otherwise.volumeof(solid)– Calculates the volume enclosed by a closed solid using the divergence theorem. Requires that the solid be topologically closed (verified by callingissolidclosed()). Returns the volume as a non-negative floating point number.Example usage:
from yapcad.geom3d_util import prism from yapcad.geom3d import issolidclosed, volumeof cube = prism(2, 2, 2) if issolidclosed(cube): vol = volumeof(cube) # Returns 8.0
Assembly
Assemblies are lists of elements, which are solids or assemblies, in which each list has an associated geometric transformation.
assembly = ['assembly', transform, elementlist], where:transform = [xformF, xformR], a pair of forward and inversetransformation matricies such that
xformF*xformR= the identity matrix.elementlist = [element0, elememnt1, ... ], in which eachlist element is either a valid
solidorassembly.
- yapcad.geom3d.surf2lines(surf)[source]
convert a surface representation to a non-redundant set of lines for line-based rendering purposes
- yapcad.geom3d.surface(*args)[source]
given a surface or a list of surface parameters as arguments, return a conforming surface representation. Checks arguments for data-type correctness.
- yapcad.geom3d.translate(x, delta)[source]
return a translated version of the surface, solid, or figure
- yapcad.geom3d.tri2p0n(face, basis=False)[source]
Given
face, a non-degenrate poly of length 3, return the center point and normal of the face, otherwise known as the Hessian Normal Form: https://mathworld.wolfram.com/HessianNormalForm.htmlIn addition, if
basis==True, calculate an orthnormal basis vectors implied by the triangle, with the x’ vector aligned with the p1-p2 edge, the z’ vector as the nornal vector, and the y’ vector as -1 * x’ x z’, and return the transformation matrix that will transform a point in world coordinates to a point in the orthonormal coordinate system with the origin at the center point. Return that transformation matrix and its inverse.
- yapcad.geom3d.triTriIntersect(t1, t2, inside=True, inPlane=False, basis=None)[source]
Function to compute the intersection of two triangles. Returns
Falseif no intersection, a line (a list of two points) if the planes do not overlap and there is a linear intersection, and a polygon (list of three or more points) if the triangles are co-planar and overlap.If
inside == True(default) return line-segment or poly intersection that falls inside both bounded triangles, otherwise return a line segment that lies on the infinite linear intersection of two planes, or False if planes are degenerate.If
inPlane==True, return the intersection as a poly in the planar coordinate system implied byt1, or in the planar coordinate system specified bybasisIf
basisis notFalse, it should be planar coordinate system in the form of[p0,n,forward,reverse], wherep0specifies the origin in world coordinates,nis the normal (equivalent to thezvector), andforwardandreverseare transformation matricies that map from world into local and local into world coordinates respectively.NOTE: when
basisis True andinPlaneis False, it is assumed thatbasisis a planar basis computed by tri2p0n coplanar witht1.
- yapcad.geom3d.volumeof(x)[source]
Calculate the volume enclosed by a solid.
Uses the divergence theorem to compute volume from the surface triangulation. For each triangular face with vertices (p0, p1, p2), the signed volume contribution is: V_i = (1/6) * dot(p0, cross(p1-p0, p2-p0))
The total volume is the sum of absolute values of all face contributions.
- Parameters:
x – A solid data structure (must be topologically closed)
- Returns:
The volume of the solid (always non-negative)
- Return type:
- Raises:
ValueError – if x is not a valid solid or is not closed
Example
>>> from yapcad.geom3d_util import prism >>> cube = prism(2, 2, 2) >>> abs(volumeof(cube) - 8.0) < 0.001 True
yapcad.geom3d_util module
- yapcad.geom3d_util.adaptive_angr_from_radius(radius, chord_error=None, max_chord=None, min_angr=1.0, max_angr=10.0)[source]
Calculate angular resolution (degrees per segment) adaptively based on radius.
This is the inverse of adaptive_arc_segments, providing the angular resolution for functions that take ‘angr’ parameter instead of segment count.
- Parameters:
radius – radius of the circle/arc in mm
chord_error – (deprecated) maximum chord error in mm for legacy mode
max_chord – maximum chord length in mm (preferred method)
min_angr – minimum angular resolution in degrees (default 1.0)
max_angr – maximum angular resolution in degrees (default 10.0)
- Returns:
optimal angular resolution in degrees
- yapcad.geom3d_util.adaptive_arc_segments(radius, chord_error=None, max_chord=None, min_segments=16, max_segments=360)[source]
Calculate the optimal number of arc segments for a given radius based on maximum chord length (preferred) or chord error (legacy).
This ensures that larger objects get more segments for smooth surfaces, while small features don’t waste polygons.
- Parameters:
radius – radius of the circle/arc in mm
chord_error – (deprecated) maximum chord error/sagitta in mm. If specified, uses old algorithm for backward compatibility.
max_chord – maximum chord length in mm. If None, uses adaptive thresholds: - Large objects (R >= 50mm): 1.0mm max chord - Small objects (R <= 2.5mm): 0.1mm max chord - Medium sizes: logarithmic interpolation
min_segments – minimum number of segments (default 16)
max_segments – maximum number of segments (default 360)
- Returns:
optimal number of segments as an integer
New chord-length algorithm (default): For a circle with N segments, chord length = 2*R*sin(π/N). Solving for N: segments = ceil(π / arcsin(max_chord / (2*R)))
This provides much smoother cylinders: - 100mm diameter (R=50mm): ~315 segments with ~1mm chords (vs 50 segments old) - 5mm diameter (R=2.5mm): ~158 segments with ~0.1mm chords (vs 12 segments old)
Legacy chord-error algorithm (when chord_error specified): The chord error is the distance between the actual circle and the straight line segment (sagitta). For a circle of radius r and angle θ:
chord_error = r * (1 - cos(θ/2))
- yapcad.geom3d_util.addVertex(nv, nn, verts, normals)[source]
Utility function that takes a vertex and associated normal and a list of corresponding vertices and normals, and returns an index that corresponds to the given vertex/normal. If the vertex doesn’t exist in the list, the lists are updated to include it and the corresponding normal.
returns the index, and the (potentiall updated) lists
- yapcad.geom3d_util.circleSurface(center, radius, angr=None, zup=True, chord_error=None, max_chord=None)[source]
make a circular surface centered at
centerlying in the XY plane with normals pointing in the positive z direction ifzup == True, negative z otherwise- Parameters:
center – center point of circle
radius – radius of circle
angr – angular resolution in degrees (if None, use adaptive resolution)
zup – if True, normal points +Z, else -Z
chord_error – (deprecated) max chord error/sagitta for legacy mode
max_chord – maximum chord length in mm for adaptive resolution (default: size-adaptive)
- yapcad.geom3d_util.conic(baser, topr, height, center=[0, 0, 0, 1], angr=None, chord_error=None, max_chord=None)[source]
Make a conic frustum splid, center is center of first ‘base’ circle, main axis aligns with positive z. This function can be used to make a cone, a conic frustum, or a cylinder, depending on the parameters.
baseris the radius of the base, must be greater than zero (epsilon).topris the radius of the top, may be zero or positive. If0 <= topr < epsilon, then the top is treated as a single point.heightis distance from base to top, must be greater than epsilon.centeris the location of the center of the base.angris the requested angular resolution in degrees for sampling circles. If None (default), adaptive resolution is used based on the larger of baser and topr. Actual angular resolution will be360/round(360/angr)chord_erroris the (deprecated) maximum chord error/sagitta in mm for legacy mode, ignored if angr is specified.max_chordis the maximum chord length in mm for adaptive resolution (default: size-adaptive), ignored if angr is specified.
- yapcad.geom3d_util.conic_tube(bottom_outer_diameter, top_outer_diameter, wall_thickness, length, center=None, *, base_point=None, minang=None, chord_error=None, max_chord=None, include_caps=True)[source]
Create a conic tube with varying outer diameter.
base_point(orcenterlegacy argument) marks the axial base of the frustum (the larger-diameter end when stacked).- Parameters:
minang – minimum angular resolution in degrees. If None, use adaptive.
chord_error – (deprecated) maximum chord error/sagitta for legacy mode
max_chord – maximum chord length in mm for adaptive resolution (default: size-adaptive)
- yapcad.geom3d_util.contour(poly, distance, direction, samples, scalefunc=<function <lambda>>)[source]
take a closed polygon and apply a scaling function defined on the interval 0,1 that returns a tuple of x,y,z scaling values. For each of
samplesnumber of samples, translate indirectiondirection and scale the contour according toscalefunc(), producing a surface.
- yapcad.geom3d_util.dodecahedron(diameter, center=[0, 0, 0, 1])[source]
Create a regular dodecahedron solid.
A dodecahedron is a Platonic solid with 12 pentagonal faces, 20 vertices, and 30 edges. This implementation uses the golden ratio construction.
- Parameters:
diameter – diameter of circumscribed sphere in mm
center – center point of the dodecahedron (default origin)
- Returns:
yapCAD solid with 12 pentagonal faces (36 triangles)
Example:
>>> d = dodecahedron(20) # 20mm diameter dodecahedron >>> write_stl(d, 'dodeca.stl')
- yapcad.geom3d_util.extrude(surf, distance, direction=[0, 0, 1, 0])[source]
Take a surface and extrude it in the specified direction to create a solid. Return the solid.
- yapcad.geom3d_util.extrude_region2d(profile, height, *, direction=None, metadata=None)[source]
Extrude a 2D region (list of line/arc segments) to create a solid.
This uses OCC’s BRepPrimAPI_MakePrism to create the extruded solid. The profile should be a closed 2D region (list of line/arc segments in XY plane).
- Parameters:
profile – A yapCAD region2d (list of 2D curve segments forming a closed loop)
height – Extrusion distance
direction – Optional direction vector [dx, dy, dz]. Defaults to [0, 0, 1] (Z-up).
metadata – Optional dict of metadata to attach
- Returns:
A yapCAD solid representing the extruded shape
- yapcad.geom3d_util.helical_extrude(profile, height, twist_angle_deg, *, auxiliary_radius=10.0, segments=64, metadata=None)[source]
Extrude a 2D profile along Z with smooth helical twist.
This function creates a helical extrusion where the profile rotates around the Z axis as it extrudes upward. The implementation uses high-resolution lofting through many intermediate sections to produce smooth helical surfaces.
For profiles centered at the origin, the twist rotates the entire profile around Z. This is ideal for helical gears, twisted columns, and spiral features.
- Parameters:
profile – A yapCAD region2d (list of 2D curve segments forming a closed loop) in the XY plane, centered at or near the origin
height – Total extrusion height along Z axis
twist_angle_deg – Total twist angle in degrees over the full height. Positive = counterclockwise when viewed from +Z. Zero twist will produce a simple extrusion.
auxiliary_radius – (Deprecated, kept for API compatibility) Previously used for auxiliary helix. Now ignored.
segments – Number of intermediate sections for lofting (default 64). More segments = smoother helical surface. For helical gears, use at least 64 segments to avoid visible stepping.
metadata – Optional dict of metadata to attach
- Returns:
A yapCAD solid with smooth helical surfaces
Note
This function requires pythonocc-core and will raise RuntimeError if not available. For small twist angles (<10 degrees), the result may be similar to a simple extrusion. The helical effect is most visible with larger twist angles. Using segments=64 or higher is recommended for smooth surfaces.
Example:
>>> # Create a twisted square prism with smooth surfaces >>> from yapcad.geom import line, point >>> square = [ ... line(point(-5, -5), point(5, -5)), ... line(point(5, -5), point(5, 5)), ... line(point(5, 5), point(-5, 5)), ... line(point(-5, 5), point(-5, -5)) ... ] >>> twisted = helical_extrude(square, height=20, twist_angle_deg=90)
- yapcad.geom3d_util.linear_pattern_solid(solid_geom, count, spacing)[source]
Create a linear pattern of solid copies.
Creates multiple copies of a 3D solid arranged in a line with uniform spacing.
- Parameters:
solid_geom – A yapCAD solid to pattern
count – Number of copies (including original)
spacing – Vector defining direction and distance between copies. Can be a 4-tuple [x, y, z, w] or 3-tuple/list [x, y, z]
- Returns:
List of solid copies, each translated by spacing increments
Example:
>>> # Create 5 mounting holes in a row >>> hole = conic(3, 3, 10) # cylinder hole >>> holes = linear_pattern_solid(hole, count=5, spacing=[20, 0, 0]) # 5 holes, 20mm apart
- yapcad.geom3d_util.linear_pattern_surface(surf, count, spacing)[source]
Create a linear pattern of surface copies.
Creates multiple copies of a 3D surface arranged in a line with uniform spacing.
- Parameters:
surf – A yapCAD surface to pattern
count – Number of copies (including original)
spacing – Vector defining direction and distance between copies. Can be a 2D, 3D, or 4D vector
- Returns:
List of surface copies, each translated by spacing increments
Example:
>>> # Create a row of ribs along a structure >>> rib_surface = triangulate_region(rib_profile) >>> ribs = linear_pattern_surface(rib_surface, count=10, spacing=[5, 0, 0])
- yapcad.geom3d_util.loft(profiles, *, segments=None, metadata=None)[source]
Create a solid by lofting between 2D profiles at different Z heights.
This function creates smooth transitions between cross-sectional profiles, useful for creating organic shapes, tapered forms, and complex solids.
- Parameters:
profiles (list) – List of 2D polylines/profiles at different Z heights. Each profile should be a list of points forming a closed polygon. Must have at least 2 profiles, and all profiles must have the same number of points.
segments (int, optional) – Not currently used; reserved for future multi-profile interpolation.
metadata (dict, optional) – Optional metadata dictionary to attach to the solid.
- Returns:
A yapCAD solid created by lofting between the profiles.
- Return type:
Examples
>>> # Create a tapered cylinder (cone frustum) >>> from yapcad.geom import arc, point >>> from yapcad.geom_util import geomlist2poly >>> >>> # Circle at z=0 with radius 10 >>> profile1 = geomlist2poly([arc(point(0, 0, 0), 10)], minang=10) >>> # Smaller circle at z=50 with radius 5 >>> profile2 = geomlist2poly([arc(point(0, 0, 50), 5)], minang=10) >>> # Move profile2 to z=50 >>> profile2 = [point(p[0], p[1], 50) for p in profile2] >>> >>> tapered = loft([profile1, profile2])
>>> # Create a shape from Bezier curves >>> from yapcad.geom import bezier >>> from yapcad.spline import bezier_curve >>> >>> # Create bezier-based profile at z=0 >>> cp1 = [point(0, 0), point(10, 20), point(30, 20), point(40, 0), point(0, 0)] >>> profile1 = bezier_curve(cp1, segments=32) >>> # Transform profile to z=30 >>> profile2 = [point(p[0]*0.5+10, p[1]*0.5, 30) for p in profile1] >>> >>> organic_shape = loft([profile1, profile2])
Notes
Profiles should have matching vertex counts for best results
The function uses makeLoftSolid internally
For more than 2 profiles, intermediate lofts are created and combined
- yapcad.geom3d_util.makeIcoPoints(center, radius)[source]
Procedure to generate the verticies of an icosohedron with the specified
centerandradius.
- yapcad.geom3d_util.makeLoftSolid(lower_loop, upper_loop, *, metadata=None)[source]
Create a solid loft between two planar loops (matching vertex counts). Attempts to attach a native BREP when pythonocc-core is available, otherwise falls back to the tessellated representation.
- yapcad.geom3d_util.makeRevolutionSolid(contour, zStart, zEnd, steps, arcSamples=None, chord_error=None, max_chord=None, metadata=None)[source]
Build a solid of revolution around the Z axis. When pythonocc-core is available, a native BREP is attached; otherwise we fall back to the tessellated representation.
- Parameters:
arcSamples – number of samples around the revolution arc. If None (default), adaptive resolution is used.
chord_error – (deprecated) maximum chord error/sagitta for legacy mode
max_chord – maximum chord length in mm for adaptive resolution (default: size-adaptive)
- yapcad.geom3d_util.makeRevolutionSurface(contour, zStart, zEnd, steps, arcSamples=None, *, chord_error=None, max_chord=None, return_brep=False)[source]
Generate a surface of revolution by sampling a contour function.
- Parameters:
contour – callable mapping
zto a radial distancezStart – lower bound for the
zintervalzEnd – upper bound for the
zintervalsteps – number of contour samples between
zStartandzEndarcSamples – number of samples around the revolution arc. If None (default), adaptive resolution is used.
chord_error – (deprecated) maximum chord error/sagitta for legacy mode
max_chord – maximum chord length in mm for adaptive resolution (default: size-adaptive)
- Returns:
['surface', vertices, normals, faces]list representing the surface
- yapcad.geom3d_util.makeRevolutionThetaSamplingSurface(contour, zStart, zEnd, arcSamples=360, endcaps=False, degrees=True, *, return_brep=False)[source]
Generate a surface of revolution using a theta-dependent contour.
If
return_brepis True and the contour is axisymmetric (identical for all theta andwrap_shift == 0), a native BREP solid is also returned; otherwise the second return value isNone.
- yapcad.geom3d_util.make_occ_helix(radius, pitch, height, left_hand=False)[source]
Create a true helix wire using 2D parametric curve on cylindrical surface.
This produces a mathematically exact helix, not a polyline approximation. Uses the standard OCC technique: 2D line on Geom_CylindricalSurface.
- Parameters:
radius – Radius of the helix cylinder
pitch – Vertical rise per full turn (360 degrees)
height – Total height of the helix
left_hand – If True, create left-handed helix (default False = right-handed)
- Returns:
An OCC TopoDS_Wire representing the helix
Note
This function requires pythonocc-core and will raise RuntimeError if not available.
Example:
>>> # Create a right-handed helix >>> helix = make_occ_helix(radius=10.0, pitch=5.0, height=20.0) >>> # Create a left-handed helix >>> left_helix = make_occ_helix(radius=10.0, pitch=5.0, height=20.0, left_hand=True)
- yapcad.geom3d_util.oblate_spheroid(equatorial_diameter, oblateness, center=[0, 0, 0, 1], depth=3)[source]
Create an oblate spheroid (ellipsoid with two equal equatorial radii).
An oblate spheroid is an ellipsoid with a < b = c (polar radius < equatorial). The oblateness (flattening) f = (a - c) / a where a is equatorial, c is polar. For Earth, f ≈ 0.00335; for Mars, f ≈ 0.00648.
- Parameters:
equatorial_diameter – diameter at the equator (X and Y axes)
oblateness – geometric oblateness/flattening (0 = sphere, higher = flatter)
center – center point of the spheroid
depth – subdivision depth for mesh (default 2)
- Returns:
yapCAD solid representing the oblate spheroid
- yapcad.geom3d_util.prism(length, width, height, center=[0, 0, 0, 1])[source]
make a rectangular prism solid composed of six independent faces
- yapcad.geom3d_util.radial_pattern_solid(solid_geom, count, center=None, axis=None, angle=None)[source]
Create a radial/circular pattern of solid copies.
Creates multiple copies of a 3D solid arranged in a circular pattern around a center point, rotating about a specified axis.
- Parameters:
solid_geom – A yapCAD solid to pattern
count – Number of copies (including original)
center – Center point for rotation (default [0,0,0,1])
axis – Rotation axis vector (default [0,0,1,0] for Z-axis)
angle – Total angle to span in degrees (default 360 = full circle)
- Returns:
List of solid copies, each rotated by angle/count increments
Example:
>>> # Create 6 holes around a circle >>> hole = conic(2.5, 2.5, 10) # cylinder hole >>> holes = radial_pattern_solid(hole, count=6) # 6 holes at 60 degree intervals
- yapcad.geom3d_util.radial_pattern_surface(surf, count, center=None, axis=None, angle=None)[source]
Create a radial/circular pattern of surface copies.
Creates multiple copies of a 3D surface arranged in a circular pattern around a center point, rotating about a specified axis.
- Parameters:
surf – A yapCAD surface to pattern
count – Number of copies (including original)
center – Center point for rotation (default [0,0,0,1])
axis – Rotation axis vector (default [0,0,1,0] for Z-axis)
angle – Total angle to span in degrees (default 360 = full circle)
- Returns:
List of surface copies, each rotated by angle/count increments
Example:
>>> # Create 8 fins around a rocket body >>> fin_surface = triangulate_region(fin_profile) >>> fins = radial_pattern_surface(fin_surface, count=8)
- yapcad.geom3d_util.rectangularPlane(length, width, center=[0, 0, 0, 1])[source]
return a rectangular surface with the normals oriented in the positive z direction
- yapcad.geom3d_util.sphere2cartesian(lat, lon, rad)[source]
Convert spherical polar coordinates to Cartesian coordinates for a sphere centered at the origin.
- Parameters:
lat – latitude in degrees
lon – longitude in degrees
rad – sphere radius
- Returns:
yapcad.geompoint in homogeneous coordinates
- yapcad.geom3d_util.spherical_shell(outer_diameter, wall_thickness, solid_angle=12.566370614359172, center=[0, 0, 0, 1], *, minang=5.0, steps=24)[source]
Create a spherical shell or cap defined by a solid angle.
- yapcad.geom3d_util.stack_solids(solids, *, axis='z', start=0.0, gap=0.0, align='center')[source]
Return translated copies of
solidsstacked along an axis.
- yapcad.geom3d_util.subdivide(f, verts, normals, rad)[source]
Given a face (a list of three vertex indices), a list of vertices, normals, and a radius, subdivide that face into four new faces and update the lists of vertices and normals accordingly.
return the updated vertex and normal lists, and a list of the four new faces.
- yapcad.geom3d_util.sweep_adaptive(profile, spine, *, inner_profiles=None, angle_threshold_deg=5.0, frame_mode='minimal_twist', up_samples=None, ruled=True, metadata=None)[source]
Sweep a profile along a path with adaptive tangent tracking.
The profile normal tracks the path tangent. New profile sections are generated whenever the tangent direction changes by more than the threshold angle. Uses BRepOffsetAPI_ThruSections to loft between sections.
- Parameters:
profile – yapCAD region2d for outer boundary (in XY plane, centered at origin)
spine – path3d dict with line/arc segments
inner_profiles – Optional region2d or list of region2d for inner voids. Supports multiple voids (e.g., split pipe for heat exchanger). Creates hollow solids by boolean subtraction.
angle_threshold_deg – Angle change (degrees) that triggers new section (default 5.0)
frame_mode – One of: - ‘minimal_twist’: Profile ‘up’ stays consistent (default) - ‘frenet’: Natural Frenet frame (may twist at inflections) - ‘custom’: Use up_samples for interpolated orientation
up_samples – For frame_mode=’custom’, list of [t, [ux, uy, uz]] pairs where t in [0,1] is path parameter and [ux,uy,uz] is up vector. Vectors are normalized automatically.
ruled – If True (default), use ruled surfaces that preserve straight edges. If False, use smooth interpolation between sections.
metadata – Optional metadata dict
- Returns:
yapCAD solid created by lofting between adapted sections
- yapcad.geom3d_util.sweep_along_path(profile, path, *, segments=32, metadata=None)[source]
Sweep a 2D profile along a 3D path curve.
This is a convenience wrapper around sweep_profile_along_path that accepts various path representations including Bezier curves and B-splines.
- Parameters:
profile (list or region2d) – A 2D profile (closed polyline) to sweep. The profile should be defined in the XY plane centered at the origin.
path (list) – A 3D path curve, which can be: - A polyline (list of 3D points) - A Bezier curve definition (from bezier()) - A B-spline curve definition (from bspline()) - A Catmull-Rom spline (from catmullrom())
segments (int, optional) – Number of segments when sampling spline paths (default 32).
metadata (dict, optional) – Optional metadata dictionary to attach to the solid.
- Returns:
A yapCAD solid created by sweeping the profile along the path.
- Return type:
Examples
>>> # Sweep a circle along a Bezier curve >>> from yapcad.geom import bezier, arc, point >>> from yapcad.geom_util import geomlist2poly >>> from yapcad.spline import bezier_curve >>> >>> # Create circular profile >>> circle_profile = geomlist2poly([arc(point(0, 0), 2)], minang=10) >>> >>> # Create curved path using Bezier >>> path_cp = [point(0, 0, 0), point(20, 0, 10), point(40, 20, 10), point(60, 20, 0)] >>> path_curve = bezier(path_cp) >>> >>> # Create swept tube >>> tube = sweep_along_path(circle_profile, path_curve, segments=64)
Notes
Profile should be centered at origin in XY plane
The sweep follows the tangent of the path for orientation
For complex paths, use more segments for smoother results
- yapcad.geom3d_util.sweep_profile_along_path(profile, spine, *, inner_profile=None, metadata=None)[source]
Sweep a 2D profile along a 3D path (spine) to create a solid.
This uses OCC’s BRepOffsetAPI_MakePipe to create the swept solid. The profile should be a closed 2D region (list of line/arc segments in XZ plane). The spine is a path3d dict containing line and arc segments.
- Parameters:
profile – A yapCAD region2d (list of 2D curve segments forming a closed loop) This is the OUTER boundary of the profile.
spine –
A path3d dict with format: {
’type’: ‘path3d’, ‘segments’: [
{‘type’: ‘line’, ‘start’: [x,y,z], ‘end’: [x,y,z]}, {‘type’: ‘arc’, ‘center’: [x,y,z], ‘start’: [x,y,z], ‘end’: [x,y,z], ‘normal’: [nx,ny,nz]}, …
]
}
inner_profile – Optional yapCAD region2d for the inner boundary (hole). If provided, creates a hollow profile (like a box girder).
metadata – Optional dict of metadata to attach
- Returns:
A yapCAD solid representing the swept shape
- yapcad.geom3d_util.tube(outer_diameter, wall_thickness, length, center=None, *, base_point=None, minang=None, chord_error=None, max_chord=None, include_caps=True)[source]
Create a cylindrical tube solid.
base_point(or legacycenterargument) identifies the base of the cylindrical wall, i.e. the plane wherez == base_point[2].- Parameters:
minang – minimum angular resolution in degrees. If None, use adaptive.
chord_error – (deprecated) maximum chord error/sagitta for legacy mode
max_chord – maximum chord length in mm for adaptive resolution (default: size-adaptive)
yapcad.geom_util module
- yapcad.geom_util.combineglist(g1, g2, operation)[source]
function to perform set operations on geometry lists.
g1andg2are closed figure geometry lists.operationis one of["union","intersection","difference"]result is a potentially zero-length geometry list representing the result, which may or may not be simply connected, but should always be a closed figure.
- yapcad.geom_util.geomlist2poly_components(gl, minang=5.0, minlen=0.25, checkcont=False)[source]
Return a list of
(outer, holes)tuples extracted fromgl.
- yapcad.geom_util.linear_pattern(geometry, count, spacing)[source]
Create a linear pattern of geometry copies.
Creates multiple copies of a 2D geometry element (line, arc, polyline, or geomlist/region) arranged in a line with uniform spacing.
- Parameters:
geometry – A 2D region, polyline, line, arc, or geomlist to pattern
count – Number of copies (including original)
spacing – Vector defining direction and distance between copies. Can be a 4-tuple [x, y, z, w] or 3-tuple/list [x, y, z]
- Returns:
List of geometry copies, each translated by spacing increments
Example:
>>> # Create 5 mounting holes in a row >>> hole = arc(point(0, 0), 3) >>> holes = linear_pattern(hole, count=5, spacing=[20, 0, 0]) # 5 holes, 20mm apart
- yapcad.geom_util.makeArcSpiral(center, turnRad, turns, dstep=45)[source]
given a center point, the increase in radius per turn, the number of turns, and the angular resolution of the approximation, generate an approximation of the spiral using circular arcs as segments instead of straightlines. Return a yapcqad.geom geomlist approximation of the spiral
- yapcad.geom_util.makeLineSpiral(center, turnRad, turns, dstep=10.0, minlen=0.25)[source]
given a center point, the increase in radius per turn, the number of turns, and the angular resolution of the approximation, generate a yapcqad.geom poly approximation of the spiral
- yapcad.geom_util.polarSampleArc(c, ang, inside=True)[source]
given an arc
c, sample that arc atangdegrees from the start of the arc, proceeding clockwise. Ifsamplereverseis true, sample the arc at-angdegrees from the end, proceeding counterclockwise. Ifcis not a complete circle and the specifiedangfalls outside the closed [start,end] interval andinside == True, returnFalse, otherwise return the sampled value.
- yapcad.geom_util.radial_pattern(geometry, count, center=None, axis=None, angle=None)[source]
Create a radial/circular pattern of geometry copies.
Creates multiple copies of a 2D geometry element (line, arc, polyline, or geomlist/region) arranged in a circular pattern around a center point.
- Parameters:
geometry – A 2D region, polyline, line, arc, or geomlist to pattern
count – Number of copies (including original)
center – Center point for rotation (default [0,0,0,1])
axis – Rotation axis vector (default [0,0,1,0] for Z-axis)
angle – Total angle to span in degrees (default 360 = full circle)
- Returns:
List of geometry copies, each rotated by angle/count increments
Example:
>>> # Create 6 bolt holes around a circle >>> hole = arc(point(10, 0), 2.5) # hole at 10mm radius >>> holes = radial_pattern(hole, count=6) # 6 holes at 60 degree intervals
- yapcad.geom_util.randomArc(bbox, minr=0.0, maxr=10.0, circle=False)[source]
given a bounding box and a minimum and maximum radius, generate an arc with random center and radius that falls within the bounding box. If
circle==False, use randomly generated start and end angles, otherwise generate only full circles
- yapcad.geom_util.randomCenterInBox(bbox, r)[source]
given a bounding box and a radius, generate a random center point such that a circle with the specified radius and center point falls completely inside the box
- yapcad.geom_util.randomPoints(bbox, numpoints)[source]
Given a 3D bounding box and a number of points to generate, return a list of uniformly generated random points within the bounding box
- yapcad.geom_util.randomPoly(bbox, numpoints=10, minr=1.0, maxr=10.0)[source]
given a bounding box, a number of vertices, and a minimum and maximum radius, generate a simple polygon that completely lies inside the bounding box, whose vertices are evenly spaced by angle around a center point, with randomly chosen radius between
minrandmaxr
yapcad.geometry module
object-oriented computational geometry figure classes for yapCAD
Overview
The yapcad.geometry module provides the Geometry class. At its
most basic level, the Geometry class wrapps yapcad.geom
figures and caches properties, such as the figure’s bounding box,
length, center, etc., speeding certain computational geometry
operations.
Why would I use yapcad.geometry vs. yapcad.geom
You might perfer the convenience and simplicity of the object-oriented
interface as a way to access the underlying power of the
yapcad.geom and associated modules. In addition, in many cases it
is actually more efficient to use the Geometry class wrappers for
figures rather than the yapcad.geom figures themselves because of
the memoizing and caching feautres provided.
For examle, Geometry class provides wrappers around the
yapcad.geom3d poly2surface() function for the triangulation of
figures into triangle mesh surfaces, which is cached. This, in turn,
provides the foundations for extrusions and the construction of 3D
triangluated objects.
Likewise, for compound figures above a certain complexity threshold, the Geometry class implements an internal quadtree decomposition of the figure to speed intersection testing. This is done in a lazy way, which is to say that the quadtree is constructed the first time intersection calculation is requested, and persists for as long as the figure’s geometry remains unchanged. NOTE: Fixeme, quadtree-based intersection not yet implemented
object oriented vs. functional approch
The yapcad.geom module generally takes a functional programming
approach, minimizing side effects. This comes at the cost of some
redundant computation, as the representation of yapcad.geom
figures are generally quite minimal, and properties such as centers,
bounding boxes, lengths, etc., must be recomputed each time they
are requested, unless the user has made their own explicit cache.
By contrast, the Geometry class caches these properties, and can
provide higher efficiency for certain types of complex operations. In
addition, derived classes provide representations and functionality
absent from the underlying functional representations, such as
“growable” polygons, boolean operations, etc..
yapcad.geometry conveneince functions
Convenience functions, such as Line(), Arc(), etc., operate
analogously to their uncapitalized counterparts in yapcad.geom,
creating Geometry class instances wrapping the corresponding
figure.
- class yapcad.geometry.Geometry(a=False)[source]
Bases:
objectgeneralized computational geometry base class, also acts as a wrapper around yapcad.geom elements.
Using Geometry subclass qinstances can be more effiient than workng with the corresponding yapcad.geom elements, as the Geometry instance uses lazy evaluation and caching to speed repeated evaluations of various properties.
- property bbox
return 3D bounding box of figure
- property center
return center of figure
- property closed
- property continuous
- property derived
- property elem
- property geom
return yapcad.geom representation of figure
- intersectXY(g, inside=True, params=False)[source]
given two XY-coplanar figures, this figure and
g, calculate the intersection of these two figures, and return a list of intersection points, or False if none.gmust be an instance ofIntersectGeometry, or ayapcad.geomfigure.If
inside == True, only return intersections that are within the0 <= u <= 1.0interval for both figures. Ifparams == True, instead of returning a list of points, return two lists corresponding to the sampling parameter value of the intersections corresponding to each figure.
- property intersectable
- isclosed()[source]
is the figure C0 continuous over the [0,1] interval and is
self.sample(0.0)within epsilon ofself.sample(1.0)
- isderived()[source]
is this an instance of a derived geometry subclass that computes self.geom from self.elem? Set only in constructors for derived geometry subclasses
- isinsideXY(p)[source]
determine if a point is inside a figure. In the case of non-closed figures, such as lines, determine if the point lies within epsilon of one of the lines of the figure.
- property length
return length of figure
- mirror(plane, keepSign=True)[source]
apply a mirror operation to a figure. Currently, the following values of “plane” are allowed: ‘xz’, ‘yz’, xy’. Generalized arbitrary reflection plane specification will be added in the future.
If
keepSign == True(default) the sign of the area will be maintained, meaning that ifmirroris applied to a right-handed closed figure (a figure with positive area) the resulting mirrored figure will also have positive area. This is probably what you want, unless you are specifically turning a face into a hole, or vice-versa.
- sample(u)[source]
If the figure is sampleable, given a parameter u, return the point on the figure corresponding to the specified sampling parameter.
- property sampleable
- surface(minang=5.0, minlen=0.5)[source]
Triangulate a closed polyline or geometry list and return a surface.
- Parameters:
minang – minimum angular resolution (degrees) for sampling arcs
minlen – minimum distance between sampled points
- Returns:
['surface', vertices, normals, faces].verticesandnormalsare aligned lists ofyapcad.geompoints;facesis a list of index triples describing the triangular mesh.
- transform(m)[source]
apply an arbitrary transformation to a figure, as specified by a transformation matrix.
- unsample(p)[source]
Invert the sampling operation: return the parameter corresponding to the closest point on the figure to p as long as the distance is less than epsilon.
- property update
yapcad.geometry_checks module
Validation helpers for yapCAD geometry.
- yapcad.geometry_checks.faces_oriented(surface: Sequence) CheckResult[source]
- yapcad.geometry_checks.is_closed_polygon(points: Sequence[Sequence[float]], tol: float = 5e-06) bool[source]
Return
Trueif a polyline is closed withintol.
- yapcad.geometry_checks.surface_watertight(surface: Sequence) CheckResult[source]
yapcad.geometry_utils module
Common geometric helpers shared across exporters and validators.
- class yapcad.geometry_utils.Triangle(normal: Tuple[float, float, float], v0: Tuple[float, float, float], v1: Tuple[float, float, float], v2: Tuple[float, float, float])[source]
Bases:
objectImmutable triangle representation in XYZ space.
- yapcad.geometry_utils.orient_triangle(v0: Tuple[float, float, float], v1: Tuple[float, float, float], v2: Tuple[float, float, float], preferred_normal: Tuple[float, float, float]) Tuple[Tuple[float, float, float], Tuple[float, float, float], Tuple[float, float, float]][source]
Ensure triangle winding aligns with
preferred_normal.
- yapcad.geometry_utils.to_point(vec: Sequence[float]) Tuple[float, float, float, float][source]
Lift an XYZ tuple into yapCAD homogeneous point form.
- yapcad.geometry_utils.to_vec3(point_like: Sequence[float]) Tuple[float, float, float][source]
Return the XYZ components of a yapCAD point/vector as a tuple.
- yapcad.geometry_utils.to_vector(vec: Sequence[float]) Tuple[float, float, float, float][source]
Lift an XYZ tuple into yapCAD homogeneous vector form (w=0).
- yapcad.geometry_utils.triangle_area(v0: Tuple[float, float, float], v1: Tuple[float, float, float], v2: Tuple[float, float, float]) float[source]
Return the area of a triangle.
- yapcad.geometry_utils.triangle_centroid(v0: Tuple[float, float, float], v1: Tuple[float, float, float], v2: Tuple[float, float, float]) Tuple[float, float, float][source]
Return the centroid of a triangle.
- yapcad.geometry_utils.triangle_is_degenerate(v0: Tuple[float, float, float], v1: Tuple[float, float, float], v2: Tuple[float, float, float], tol: float = 5e-06) bool[source]
Return
Trueif a triangle collapses under the given tolerance.
yapcad.mesh module
Utilities for working with triangulated views of yapCAD surfaces.
- yapcad.mesh.mesh_view(obj: Sequence) Iterator[Tuple[Tuple[float, float, float], Tuple[float, float, float], Tuple[float, float, float], Tuple[float, float, float]]][source]
Yield triangles for a surface or solid as
(normal, v0, v1, v2).Normals are unit vectors. Vertices are returned as
(x, y, z)tuples. Faces with degenerate geometry (zero area) are skipped silently.For BREP-only solids (those with empty surfaces list), tessellation is performed via pythonocc-core if available.
yapcad.metadata module
Metadata helpers for yapCAD geometry objects.
yapcad.native_brep module
Native BREP topology graph for yapCAD.
This module provides native (OCC-independent) BREP data structures for representing boundary representations of 3D solids. These structures can be used alongside or instead of OCC-based BREP data.
Topology hierarchy: - BrepVertex: point in 3D space with tolerance - BrepEdge: parametric curve segment bounded by vertices - BrepTrim: oriented edge reference with UV parameterization on a face - BrepLoop: closed sequence of trims forming a boundary - BrepFace: surface bounded by loops - BrepShell: connected set of faces - BrepSolid: collection of shells (outer + inner voids)
Design principle: Vertices are the source of truth for endpoint positions. Edges store curve type and parameters, not absolute endpoint coordinates. This ensures transformations only need to update vertex locations.
Copyright (c) 2025 Richard DeVaul MIT License
- exception yapcad.native_brep.ShellClosureError(message, details=None)[source]
Bases:
ValueErrorException raised when shell closure validation fails.
- exception yapcad.native_brep.SolidValidationError(message, details=None)[source]
Bases:
ValueErrorException raised when solid validation fails.
- class yapcad.native_brep.TopologyGraph[source]
Bases:
objectContainer for a complete BREP topology graph.
This class manages the relationships between all topology entities (vertices, edges, trims, loops, faces, shells, solids) and provides lookup and traversal operations.
- add_shell(shell, validate_closure=True)[source]
Add a shell to the graph.
- Parameters:
shell (brep_shell) – The shell to add.
validate_closure (bool, optional) – If True (default), validate closure when shell.closed is True. If shell.closed is None, auto-detect and set the closure status.
- Raises:
ShellClosureError – If shell.closed is True but the shell is not topologically closed.
- add_solid(solid, validate=True, tolerance=1e-10)[source]
Add a solid to the graph.
- Parameters:
- Raises:
SolidValidationError – If validation is enabled and the solid is invalid.
- compute_shell_closure(shell_id)[source]
Compute whether a shell is topologically closed.
A shell is closed if: 1. Every edge is used by exactly two faces (manifold condition) 2. The Euler characteristic V - E + F = 2 (for simple closed surfaces)
- Parameters:
shell_id (str) – ID of the shell to check.
- Returns:
(is_closed: bool, details: dict) details contains: - ‘edge_usage’: dict mapping edge_id -> list of face_ids - ‘boundary_edges’: list of edges used by only 1 face - ‘non_manifold_edges’: list of edges used by >2 faces - ‘euler_characteristic’: computed V - E + F - ‘vertex_count’: number of vertices - ‘edge_count’: number of edges - ‘face_count’: number of faces
- Return type:
- evaluate_edge(eid)[source]
Evaluate an edge to get its yapCAD curve geometry.
This constructs the actual curve from vertex positions and edge parameters.
- shell_bbox(shell_id)[source]
Compute bounding box for a shell from its face surfaces.
- Returns:
(min_point, max_point) bounding box, or None if shell is empty.
- Return type:
tuple or None
- shell_contains_point(shell_id, p, tolerance=1e-10)[source]
Test if a point is inside a closed shell using ray casting.
Returns True if point is inside, False otherwise.
- shell_edge_usage(shell_id)[source]
Compute edge usage counts for a shell.
Returns a dict mapping edge_id -> list of face_ids that use that edge within this shell.
- shell_octree(shell_id, rebuild=False)[source]
Get or build an octree for a shell’s tessellated triangles.
The octree is cached in shell metadata for performance.
- Returns:
Octree of shell triangles, or None if shell is empty.
- Return type:
NTree or None
- shells_bboxes_overlap(shell_id1, shell_id2, tolerance=0.0)[source]
Quick check if two shells’ bounding boxes overlap.
Returns False if boxes don’t overlap (shells definitely don’t intersect). Returns True if boxes overlap (shells might intersect).
- shells_intersect(shell_id1, shell_id2, tolerance=1e-10)[source]
Test if two shells intersect using octree acceleration.
Returns True if shells share interior volume or surface intersection.
- tessellate_shell(shell_id, u_divisions=16, v_divisions=16)[source]
Tessellate all faces in a shell into a single surface mesh.
- Returns:
yapCAD surface [‘surface’, verts, normals, faces, …] or None.
- Return type:
list or None
- transform(transform_point_func)[source]
Transform the entire topology graph.
- Parameters:
transform_point_func (callable) – Function that takes a point and returns the transformed point.
transforms (This)
locations (- All vertex)
centers (- All internal geometry points in edges (arc)
etc.)
handling (- Face surfaces would need separate)
- validate_shell_closure(shell_id)[source]
Validate that a shell is topologically closed.
- Parameters:
shell_id (str) – ID of the shell to validate.
- Raises:
ShellClosureError – If the shell is not closed, with details about the failure.
- Returns:
Closure details if validation passes.
- Return type:
- validate_solid(solid_id, tolerance=1e-10)[source]
Validate a BREP solid.
Validates: 1. All shells are closed 2. Shells do not intersect each other 3. Void shells are contained within the outer shell
- Parameters:
- Raises:
SolidValidationError – If validation fails, with details about the failure.
- Returns:
Validation details if successful.
- Return type:
- yapcad.native_brep.arc_edge(start_vertex, end_vertex, *, bulge=None, center=None, orientation=1, **kwargs)[source]
Create an arc edge between two vertices.
Specify either bulge OR center, not both.
- yapcad.native_brep.attach_native_brep_to_solid(yapcad_solid, native_brep_graph)[source]
Attach a native BREP topology graph to a yapCAD solid’s metadata.
- Parameters:
yapcad_solid (list) – A yapCAD solid (from geom3d).
native_brep_graph (TopologyGraph) – The native BREP topology graph to attach.
Notes
This stores the serialized native BREP in the solid’s metadata under the ‘native_brep’ key. The format mirrors the OCC BREP storage pattern used in brep.py.
- yapcad.native_brep.brep_edge(curve_type, start_vertex, end_vertex, *, curve_params=None, sense=True, tolerance=5e-06, tags=None)[source]
Create a BREP edge with parametric curve definition.
The edge stores curve type and parameters, NOT absolute endpoint coordinates. Endpoint positions are derived from the referenced vertices.
- Parameters:
curve_type (str) – Type of curve: ‘line’, ‘arc’, ‘ellipse’, ‘nurbs’.
start_vertex (brep_vertex or str) – Start vertex or vertex ID.
end_vertex (brep_vertex or str) – End vertex or vertex ID.
curve_params (dict, optional) – Type-specific curve parameters (see module docstring).
sense (bool, optional) – True if edge direction agrees with curve direction.
tolerance (float, optional) – Geometric tolerance.
tags (dict, optional) – User metadata.
- Returns:
Edge definition: [‘brep_edge’, curve_type, metadata_dict]
- Return type:
- yapcad.native_brep.brep_face(surface, loops, *, sense=True, tags=None)[source]
Create a BREP face.
- Parameters:
- Returns:
Face definition: [‘brep_face’, surface, metadata_dict]
- Return type:
- yapcad.native_brep.brep_loop(trims, *, loop_type='outer', tags=None)[source]
Create a BREP loop (closed boundary of a face).
- yapcad.native_brep.brep_shell(faces, *, shell_type='outer', closed=None, tags=None)[source]
Create a BREP shell.
- Parameters:
faces (list) – List of faces forming the shell.
shell_type (str, optional) – ‘outer’ for outer shell, ‘void’ for inner void.
closed (bool or None, optional) – True if shell should be closed (validated when added to TopologyGraph). False if shell is explicitly open. None to auto-detect closure when added to TopologyGraph.
tags (dict, optional) – User metadata.
- Returns:
Shell definition: [‘brep_shell’, face_refs, metadata_dict]
- Return type:
Notes
Closure validation is performed when the shell is added to a TopologyGraph. A closed shell satisfies: - Every edge is used by exactly two faces - The Euler characteristic V - E + F = 2 (for simple closed surfaces)
- yapcad.native_brep.brep_trim(edge, *, sense=True, uv_curve=None, tags=None)[source]
Create a BREP trim (oriented edge use on a face).
A trim represents the use of an edge on a particular face, with optional UV parameterization for trimmed surface representation.
- Parameters:
- Returns:
Trim definition: [‘brep_trim’, edge_ref, metadata_dict]
- Return type:
- yapcad.native_brep.brep_vertex(location, *, tolerance=5e-06, tags=None)[source]
Create a BREP vertex.
- yapcad.native_brep.bspline_edge(start_vertex, end_vertex, control_points, knots, degree, *, weights=None, t_start=None, t_end=None, **kwargs)[source]
Create a B-spline edge between two vertices.
- Parameters:
start_vertex (brep_vertex) – The endpoints of the edge.
end_vertex (brep_vertex) – The endpoints of the edge.
control_points (list of points) – Control points for the B-spline.
degree (int) – Degree of the B-spline.
weights (list of float, optional) – Weights for rational B-splines. If None, uniform weights (1.0).
t_start (float, optional) – Start parameter. Default is knots[degree].
t_end (float, optional) – End parameter. Default is knots[-degree-1].
- yapcad.native_brep.circle_edge(start_vertex, end_vertex, center, axis, radius, *, t_start=0.0, t_end=None, **kwargs)[source]
Create a circular arc edge between two vertices.
- Parameters:
start_vertex (brep_vertex) – The endpoints of the edge.
end_vertex (brep_vertex) – The endpoints of the edge.
center (point) – Center of the circle.
axis (vector) – Normal to the plane of the circle.
radius (float) – Radius of the circle.
t_start (float, optional) – Start parameter (angle in radians). Default 0.
t_end (float, optional) – End parameter (angle in radians). Default computed from endpoints.
- yapcad.native_brep.clear_native_brep(yapcad_solid)[source]
Remove native BREP data from a yapCAD solid’s metadata.
- Parameters:
yapcad_solid (list) – A yapCAD solid (from geom3d).
Notes
This is useful when the native BREP becomes stale (e.g., after modifications that don’t update the BREP).
- yapcad.native_brep.deserialize_topology_graph(data)[source]
Reconstruct a TopologyGraph from serialized data.
- Parameters:
data (dict) – Serialized topology graph data.
- Returns:
Reconstructed topology graph.
- Return type:
- yapcad.native_brep.evaluate_edge_curve(edge, start_point, end_point)[source]
Construct a yapCAD curve from edge definition and vertex positions.
- yapcad.native_brep.has_native_brep(yapcad_solid)[source]
Check if a yapCAD solid has native BREP data attached.
- yapcad.native_brep.line_edge(start_vertex, end_vertex, **kwargs)[source]
Create a line edge between two vertices.
- yapcad.native_brep.mirror_native_brep(yapcad_solid, plane)[source]
Apply a mirror transformation to native BREP data in a solid.
- yapcad.native_brep.native_brep_from_solid(yapcad_solid)[source]
Retrieve native BREP topology graph from a yapCAD solid’s metadata.
- Parameters:
yapcad_solid (list) – A yapCAD solid (from geom3d).
- Returns:
The deserialized topology graph, or None if not present.
- Return type:
TopologyGraph or None
- yapcad.native_brep.rotate_native_brep(yapcad_solid, ang, center, axis)[source]
Apply a rotation to native BREP data in a solid.
- yapcad.native_brep.scale_native_brep(yapcad_solid, factor, center=None)[source]
Apply a uniform scale to native BREP data in a solid.
- yapcad.native_brep.serialize_topology_graph(graph)[source]
Serialize a TopologyGraph to a JSON-serializable dict.
- Parameters:
graph (TopologyGraph) – The topology graph to serialize.
- Returns:
JSON-serializable dictionary containing all topology entities.
- Return type:
- yapcad.native_brep.set_vertex_location(v, location)[source]
Set the location of a vertex (for transformations).
- yapcad.native_brep.shell_closed(s)[source]
Return the closure status of a shell.
- Returns:
True if closed, False if open, None if not yet determined.
- Return type:
bool or None
- yapcad.native_brep.transform_edge_params(edge, transform_point_func)[source]
Transform internal geometry points in edge curve parameters.
For edges with internal geometry (like arc centers), this function applies a transformation to those points. Call this after transforming the vertices.
- Parameters:
edge (brep_edge) – The edge to transform (modified in place).
transform_point_func (callable) – Function that takes a point and returns transformed point.
- yapcad.native_brep.transform_topology_graph(graph, transform_fn)[source]
Apply a transformation to all geometry in a TopologyGraph.
- Parameters:
graph (TopologyGraph) – The topology graph to transform (modified in-place).
transform_fn (callable) – A function that takes a point and returns a transformed point.
Notes
This transforms: - All vertex locations - Edge curve parameters (centers, control points, axes) - Face surface parameters (origins, centers, normals, axes) - Invalidates cached octrees
yapcad.occ_native_convert module
OCC ↔ Native BREP conversion utilities.
This module provides bidirectional conversion between OCC (Open CASCADE) BREP representations and yapCAD native BREP representations.
The native BREP representation is the primary/canonical form for yapCAD geometry. OCC representations are derived and used for: - STEP file import/export - Boolean operations (when OCC engine is selected) - Complex surface operations
Conversion functions: - occ_surface_to_native: Convert OCC Geom_Surface to native analytic surface - occ_solid_to_native_brep: Convert OCC TopoDS_Solid to native BREP topology - native_surface_to_occ: Convert native analytic surface to OCC Geom_Surface - native_brep_to_occ: Convert native BREP topology to OCC TopoDS_Solid
Copyright (c) 2025 Richard DeVaul MIT License
- yapcad.occ_native_convert.native_brep_to_occ(graph, fix_shape=True)[source]
Convert a native BREP TopologyGraph to an OCC TopoDS_Solid.
This function converts a complete native BREP representation back to an OCC solid, which can then be used for boolean operations or export.
- Parameters:
graph (TopologyGraph) – The native BREP topology graph.
fix_shape (bool, optional) – If True, apply shape fixing to ensure a valid solid. Default True.
- Returns:
The OCC solid (or shell if conversion to solid fails).
- Return type:
TopoDS_Solid or TopoDS_Shell
- yapcad.occ_native_convert.native_brep_to_occ_from_solid(yapcad_solid, fix_shape=True)[source]
Convert a yapCAD solid’s native BREP to OCC representation.
Convenience function that extracts the native BREP from a yapCAD solid and converts it to OCC format.
- yapcad.occ_native_convert.native_edge_to_occ(edge, graph)[source]
Convert a native BREP edge to an OCC TopoDS_Edge.
- Parameters:
edge (brep_edge) – The native edge to convert.
graph (TopologyGraph) – The topology graph containing the edge’s vertices.
- Returns:
The OCC edge.
- Return type:
TopoDS_Edge
- yapcad.occ_native_convert.native_face_to_occ(face, graph, edge_cache=None)[source]
Convert a native BREP face to an OCC TopoDS_Face.
- Parameters:
face (brep_face) – The native face to convert.
graph (TopologyGraph) – The topology graph containing the face’s loops.
edge_cache (dict, optional) – Cache of edge_id -> TopoDS_Edge for reuse.
- Returns:
The OCC face, or None if conversion fails.
- Return type:
TopoDS_Face
- yapcad.occ_native_convert.native_loop_to_occ_wire(loop, graph, edge_cache=None)[source]
Convert a native BREP loop to an OCC TopoDS_Wire.
- Parameters:
loop (brep_loop) – The native loop to convert.
graph (TopologyGraph) – The topology graph containing the loop’s edges.
edge_cache (dict, optional) – Cache of edge_id -> TopoDS_Edge for reuse.
- Returns:
The OCC wire.
- Return type:
TopoDS_Wire
- yapcad.occ_native_convert.native_surface_to_occ(surf)[source]
Convert a native analytic surface to an OCC Geom_Surface.
- Parameters:
surf (native surface) – A native analytic surface.
- Returns:
The OCC surface, or None if conversion is not supported.
- Return type:
Geom_Surface or None
- yapcad.occ_native_convert.native_vertex_to_occ(vertex)[source]
Convert a native BREP vertex to an OCC TopoDS_Vertex.
- Parameters:
vertex (brep_vertex) – The native vertex to convert.
- Returns:
The OCC vertex.
- Return type:
TopoDS_Vertex
- yapcad.occ_native_convert.occ_edge_to_native(edge: Any, vertex_map: dict = None)[source]
Convert an OCC edge to a native BREP edge.
- yapcad.occ_native_convert.occ_solid_to_native_brep(shape: Any, tessellate_fallback: bool = True)[source]
Convert an OCC solid to native BREP representation.
- Parameters:
shape (TopoDS_Shape) – The OCC shape (solid) to convert.
tessellate_fallback (bool) – If True, use tessellation for unsupported surface types.
- Returns:
(native_solid, topology_graph) where native_solid is the BREP solid and topology_graph is the TopologyGraph containing all entities.
- Return type:
- yapcad.occ_native_convert.occ_surface_to_native(face: Any, tessellate_fallback: bool = True)[source]
Convert an OCC face’s surface to a native analytic surface.
- Parameters:
face (TopoDS_Face) – The OCC face to convert.
tessellate_fallback (bool) – If True, fall back to tessellation for unsupported surface types.
- Returns:
A native analytic surface representation, or None if conversion fails.
- Return type:
native_surface
yapcad.octtree module
quadtree and octtree representations for yapCAD geometry
- class yapcad.octtree.NTree(n=8, geom=None, center=None, mindim=None, maxdepth=None, octree_size=None)[source]
Bases:
objectGeneralized n-tree representation for yapCAD geometry
- addElement(element, tag=None)[source]
add a geometry element to the collection, don’t update the tree – yet
- property depth
- getElements(bbox)[source]
return a list of geometry elements with bounding boxes that overalp the provided bounding box, or the empty list if none.
- property maxdepth
- property mindim
- yapcad.octtree.bbox2oct(bbx, refbox, center)[source]
Utility function to take a bounding box representation and assign it to zero or more octants.
box2oct(bbx,refbox,center)
bbx: 3D bounding box to assign refbox: reference 3D bounding box center: center point for purposes of assignment
returns (potentially empty) list of octants, numbered 0 to 7
- yapcad.octtree.bbox2quad(bbx, refbox, center)[source]
- Utility Function to take a bounding box representation and assign
to zero or more quads
box2quad(bbx,refbox,center)
bbx: 2D bounding box to assign refbox: reference 2D bounding box center: center point for purposes of assignment
returns (potentially empty) list of quadrants, numbered 0 to 3
- yapcad.octtree.box2boxes(bbox, center, n, type='centersplit', elm=[])[source]
Function to take a bounding box (2d or 3D) and return a quad- or octtree decomposition of the box based on the value of center point, the type of split, and (potentially) the list of bounding boxes to be divvied up.
- yapcad.octtree.boxoverlap2(bbx1, bbx2, dim3=True)[source]
Determine if two bounding boxes overlap. if dim3==True, treat the bounding boxes as 3D, otherwise treat them as co-planar 2D boxes.
First, check to see if the maximum coordinates of one box are smaller than the minimum coordinates of the other, or vice versa. If so, no overlap is possible; return False
if overlap is possible by test #1, check for the box-in-box special case for each box. If so, return True
Finally, for the 2D case: determine if horizontal lines of box1 intersect with vertical lines of box2, and vice versa. If any intersections found, return True, else return False
For the 3D case, project the boxes into the XY, YZ, and XZ planes, and perform the 2D lines intersection check, as above. Return True if and only if intersections are reported for each projection, otherwise return False
yapcad.poly module
- class yapcad.poly.Polygon(a=None)[source]
Bases:
GeometryMulti-element closed figure derived geometry class
- property geom
return yapcad.geom representation of figure
yapcad.pyglet_drawable module
- class yapcad.pyglet_drawable.Material(**kwargs)[source]
Bases:
objectRepresentation of an OpenGL-style material
- property ambient
- property desc
- property diffuse
- property emission
- property material
- property shininess
- property specular
- class yapcad.pyglet_drawable.pygletDraw[source]
Bases:
DrawableyapCAD
drawablesubclass for OpenGL rendering with pyglet- property cameradist
- draw_surface(points, normals=None, faces=None, name=None)[source]
render a surface, either as part of default scene geometry (if
nameis not specified) or as a part of a named object.
- property magnify
- make_object(name, **kwargs)[source]
Create a new three-dmensional object with specified material properties and 6DOF in world-space that can be animated
- property objectdict
- property rx
- property ry
yapcad.spline module
Spline helpers for yapCAD.
Provides evaluation and sampling routines for spline primitives defined in
yapcad.geom, including Bezier, B-spline, Catmull-Rom and NURBS curves.
- yapcad.spline.bezier_curve(control_points, segments: int = 32) List[list][source]
Sample a Bezier curve as a polyline.
- Parameters:
- Returns:
List of points suitable for use as a yapCAD polyline.
- Return type:
Examples
>>> cp = [point(0, 0), point(10, 20), point(30, 20), point(40, 0)] >>> polyline = bezier_curve(cp, segments=32) >>> # polyline can be used anywhere a yapCAD polyline is expected
- yapcad.spline.bezier_point(control_points, t: float) list[source]
Evaluate a Bezier curve at parameter t using De Casteljau’s algorithm.
- Parameters:
- Returns:
Point on the curve at parameter t as a yapCAD point.
- Return type:
Examples
>>> cp = [point(0, 0), point(10, 20), point(30, 20), point(40, 0)] >>> p = bezier_point(cp, 0.5) # Point at middle of curve
- yapcad.spline.bezier_tangent(control_points, t: float) list[source]
Compute the tangent vector of a Bezier curve at parameter t.
The tangent is the first derivative of the curve with respect to t. For a Bezier curve of degree n, the derivative is a Bezier curve of degree n-1 with control points: n * (P_{i+1} - P_i).
- Parameters:
- Returns:
Tangent vector at parameter t as a yapCAD direction vector [x, y, z, 0].
- Return type:
Examples
>>> cp = [point(0, 0), point(10, 20), point(30, 20), point(40, 0)] >>> tangent = bezier_tangent(cp, 0.5)
- yapcad.spline.bspline_curve(control_points, degree: int = 3, closed: bool = False, segments: int = 64) List[list][source]
Sample a B-spline curve as a polyline.
- Parameters:
- Returns:
List of points suitable for use as a yapCAD polyline.
- Return type:
- yapcad.spline.bspline_point(control_points, t: float, degree: int = 3, closed: bool = False) list[source]
Evaluate a B-spline curve at parameter t.
- yapcad.spline.bspline_tangent(control_points, t: float, degree: int = 3, closed: bool = False) list[source]
Compute the tangent vector of a B-spline curve at parameter t.
Uses numerical differentiation for robustness.
- yapcad.spline.evaluate_bezier(curve, t: float) list[source]
Evaluate a Bezier curve definition at parameter
tin [0, 1].- Parameters:
curve (list) – A Bezier curve definition from
yapcad.geom.bezier().t (float) – Parameter value in [0, 1].
- Returns:
Point on the curve at parameter t.
- Return type:
- yapcad.spline.evaluate_bspline(curve, t: float) list[source]
Evaluate a B-spline curve definition at parameter
tin [0, 1].- Parameters:
curve (list) – A B-spline curve definition from
yapcad.geom.bspline().t (float) – Parameter value in [0, 1].
- Returns:
Point on the curve at parameter t.
- Return type:
- yapcad.spline.evaluate_catmullrom(curve, u: float) list[source]
Evaluate a Catmull-Rom spline at parameter
uin[0, 1].
- yapcad.spline.evaluate_nurbs(curve, u: float) list[source]
Evaluate a NURBS curve at parameter
uin[0, 1].
- yapcad.spline.is_catmullrom(curve) bool[source]
Return
Trueif curve is a Catmull-Rom spline definition.
- yapcad.spline.sample_bezier(curve, *, segments: int = 32) List[list][source]
Sample a Bezier curve definition into a list of points.
- Parameters:
curve (list) – A Bezier curve definition from
yapcad.geom.bezier().segments (int, optional) – Number of line segments in output (default 32).
- Returns:
List of points suitable for use as a yapCAD polyline.
- Return type:
- yapcad.spline.sample_bspline(curve, *, segments: int = 64) List[list][source]
Sample a B-spline curve definition into a list of points.
- Parameters:
curve (list) – A B-spline curve definition from
yapcad.geom.bspline().segments (int, optional) – Number of line segments in output (default 64).
- Returns:
List of points suitable for use as a yapCAD polyline.
- Return type:
yapcad.text3d module
3D Text generation for yapCAD.
This module provides functions for creating 3D text suitable for labeling 3D printed parts. It includes both extruded (raised) text and engraved (cut-in) text capabilities using a simple, printable block font or TrueType/OpenType fonts.
Example usage:
from yapcad.text3d import text_solid, engrave_text from yapcad.io.stl import write_stl
# Create raised text using TrueType font (Arial) label = text_solid(“ROBOT”, height=10.0, depth=2.0) write_stl(label, “robot_label.stl”)
# Create text with a specific font file label = text_solid(“ROBOT”, height=10.0, depth=2.0,
font=”/path/to/font.ttf”)
# Use block font explicitly label = text_solid(“ROBOT”, height=10.0, depth=2.0, font=”block”)
# Engrave text into a surface plate = prism(50, 30, 5) engraved = engrave_text(plate, “V1.0”, point(0, 0, 2.5),
vect(0, 0, 1, 0), height=4.0, depth=0.5)
Fit-aware text generation:
- from yapcad.text3d import (
validate_text_fit, text_solid_fitted, calculate_text_height_for_width
)
# Check if text fits before creating fits, width, msg = validate_text_fit(“DARK MATTER LAB”,
height=15, max_width=160)
- if not fits:
print(f”Warning: {msg}”) # Auto-fit instead solid, actual_height = text_solid_fitted(“DARK MATTER LAB”,
max_width=160, depth=2)
print(f”Created text at height {actual_height:.1f}mm”)
- else:
solid = text_solid(“DARK MATTER LAB”, height=15, depth=2)
# Calculate exact height for a target width height = calculate_text_height_for_width(“ROBOT V1”, target_width=100) label = text_solid(“ROBOT V1”, height=height, depth=2)
- yapcad.text3d.calculate_text_height_for_width(text, target_width, spacing=1.0, font=None)[source]
Calculate the character height needed to achieve a target text width.
Given a desired total text width, this function calculates the character height that will produce text of approximately that width. Useful for fitting text precisely into a known space.
- Parameters:
text – String to size
target_width – Desired total text width in mm
spacing – Character spacing (default 1.0)
font – Font specification (same as text_solid)
- Returns:
Character height in mm that will produce the target width
- Return type:
Float
Example
>>> height = calculate_text_height_for_width("ROBOT V1", target_width=100) >>> solid = text_solid("ROBOT V1", height=height, depth=2) >>> # solid will be approximately 100mm wide
- yapcad.text3d.engrave_text(target_solid, text, position, normal, height=3.0, depth=0.5, spacing=1.0, font=None)[source]
Cut text into a face of a solid (boolean difference).
Creates text as a solid and subtracts it from the target solid to create engraved (cut-in) text.
- Parameters:
target_solid – yapCAD solid to engrave into
text – Text string to engrave
position – Point on face where text starts (bottom-left of first char)
normal – Face normal vector (determines orientation of text)
height – Character height in mm (default 3.0)
depth – Engraving depth in mm (default 0.5)
spacing – Character spacing (default 1.0)
font – Font specification (same as text_solid)
- Returns:
New solid with text engraved into the specified face
- yapcad.text3d.find_system_font(font_name)[source]
Find a font by name in system font directories.
- Parameters:
font_name – Name of the font (e.g., “Arial”, “Helvetica”)
- Returns:
Path to the font file, or None if not found
- yapcad.text3d.get_supported_characters()[source]
Return a string of all supported characters.
- Returns:
String containing all characters that can be rendered
- yapcad.text3d.text_on_surface(text: str, surface_center, surface_normal, up_direction, max_width: float, depth: float = 1.5, margin: float = 0.0, font=None)[source]
Place text on a surface, automatically handling all rotations.
Creates 3D text positioned on an arbitrary surface. The text is automatically sized to fit within max_width and rotated to face outward along the surface normal, with its “up” direction aligned with the specified up_direction.
This is a convenience function that handles the complex coordinate frame transformation needed to place text on non-XY-plane surfaces.
- Parameters:
text – String to render
surface_center – (x, y, z) center point where text should be placed
surface_normal – (nx, ny, nz) outward-pointing normal of the surface
up_direction – (ux, uy, uz) “up” direction on the surface (text baseline to top)
max_width – Maximum text width in mm (text will be auto-scaled to fit)
depth – How far text protrudes from surface in mm (default 1.5)
margin – Gap between text back and surface (default 0 = touching)
font – Font specification (same as text_solid)
- Returns:
yapCAD solid (text positioned and oriented on surface)
The text will: - Face outward along surface_normal - Have its “up” direction aligned with up_direction - Be centered at surface_center - Protrude outward by depth - Fit within max_width
- Example for front face of battery cage (+Y face):
- text_on_surface(
“DARK MATTER LAB”, surface_center=(0, 66.5, 100), # front face, centered, Z=100 surface_normal=(0, 1, 0), # faces +Y up_direction=(0, 0, 1), # text stands up in Z max_width=180, depth=1.5
)
- Example for top face:
- text_on_surface(
“TOP”, surface_center=(0, 0, 50), # top surface surface_normal=(0, 0, 1), # faces +Z (up) up_direction=(0, 1, 0), # text reads toward +Y max_width=40, depth=1.0
)
- yapcad.text3d.text_solid(text, height=5.0, depth=1.0, spacing=1.0, center=None, font=None)[source]
Create extruded 3D text solid.
Generates a solid from the given text string by extruding each character polygon in the Z direction. Properly handles letters with interior holes (counters) like P, D, B, A, R, O, Q, etc.
- Parameters:
text – String to render
height – Character height in mm (default 5.0)
depth – Extrusion depth in mm (default 1.0)
spacing – Character spacing (default 1.0) - For block font: fraction of character width - For TrueType: additional space in mm
center – Optional center point for the text block
font – Font specification (default None): - None: Auto-detect Arial or fall back to block font - “block”: Use simple block font - Font name (e.g., “Arial”): Search system fonts - Path to .ttf/.otf file: Use specified font file
- Returns:
yapCAD solid (combined extruded text)
- yapcad.text3d.text_solid_fitted(text, max_width, depth, spacing=1.0, font=None, min_height=3.0)[source]
Create 3D text that fits within max_width by auto-scaling height.
This function automatically calculates the optimal character height to ensure the text fits within the specified maximum width. It will not go below min_height to maintain readability.
- Parameters:
text – String to render
max_width – Maximum allowed width in mm
depth – Extrusion depth in mm
spacing – Character spacing (default 1.0)
font – Font specification (same as text_solid)
min_height – Minimum character height in mm (default 3.0)
- Returns:
- float)
solid: The generated yapCAD solid
actual_height: The character height that was used
- Return type:
Tuple of (solid, actual_height
Example
>>> solid, height = text_solid_fitted("DARK MATTER LAB", max_width=160, depth=2) >>> print(f"Text created with height {height:.1f}mm") >>> # solid is guaranteed to fit within 160mm width
- Workflow:
When creating text for a surface with known dimensions, use this function to ensure the text will fit:
>>> # Check if preferred size fits >>> fits, width, msg = validate_text_fit("LABEL", height=15, max_width=160) >>> if not fits: ... # Auto-fit instead ... solid, height = text_solid_fitted("LABEL", max_width=160, depth=2) ... else: ... # Use preferred size ... solid = text_solid("LABEL", height=15, depth=2)
- yapcad.text3d.text_to_polygons(text, height=5.0, spacing=1.0, font=None)[source]
Convert text string to list of 2D polygons.
Each character becomes one or more closed polygons suitable for extrusion or boolean operations.
- Parameters:
text – String to convert
height – Character height in mm (default 5.0)
spacing – Space between characters as fraction of char width (default 1.0)
font – Font specification (default None): - None: Auto-detect Arial or fall back to block font - “block”: Use simple block font - Font name (e.g., “Arial”): Search system fonts - Path to .ttf/.otf file: Use specified font file
- Returns:
List of closed polygons (each polygon is a list of points)
- yapcad.text3d.text_width(text, height=5.0, spacing=1.0, font=None)[source]
Calculate the total width of rendered text.
Useful for positioning and centering text.
- Parameters:
text – String to measure
height – Character height in mm (default 5.0)
spacing – Character spacing (default 1.0)
font – Font specification (same as text_solid)
- Returns:
Total width in mm
- yapcad.text3d.validate_text_fit(text, height, max_width, spacing=1.0, font=None)[source]
Check if text will fit within a maximum width.
This function validates whether the generated text will fit within a specified maximum width, useful for ensuring text fits on target surfaces before creating the 3D solid.
- Parameters:
text – String to validate
height – Character height in mm
max_width – Maximum allowed width in mm
spacing – Character spacing (default 1.0)
font – Font specification (same as text_solid)
- Returns:
- bool, actual_width: float, message: str)
fits: True if text fits within max_width
actual_width: The calculated width of the text
message: Human-readable status message
- Return type:
Tuple of (fits
Example
>>> fits, width, msg = validate_text_fit("ROBOT", height=10, max_width=50) >>> if not fits: ... print(f"Warning: {msg}")
yapcad.threadgen module
Thread profile generator for yapCAD.
- class yapcad.threadgen.ThreadProfile(D_nominal: 'float', P_pitch: 'float', thread_angle: 'float' = 60.0, crest_flat_ratio: 'float' = 0.125, root_flat_ratio: 'float' = 0.25, thread_depth_ratio: 'float' = 0.54127, handedness: 'str' = 'right', starts: 'int' = 1, internal: 'bool' = False, taper_ratio: 'float' = 0.0)[source]
Bases:
object
- yapcad.threadgen.metric_profile(d_nominal_mm: float, pitch_mm: float, *, strts: int = 1, internal: bool = False) ThreadProfile[source]
yapcad.triangulator module
Triangulation helpers for yapCAD surfaces.
We delegate to mapbox-earcut (the fast ear clipping implementation
used by Mapbox GL) to keep the logic compact and reliable. The helper
routine in this file simply normalises yapCAD polygon inputs into the
format expected by earcut and converts the resulting indices back into
triangle vertex tuples.
- yapcad.triangulator.triangulate_polygon(outer: Sequence[Sequence[float]], holes: Iterable[Sequence[Sequence[float]]] | None = None) List[List[Tuple[float, float]]][source]
Return triangles covering
outerminus anyholes.outerand each entry inholesis expected to be a sequence of XY-like points. Degenerate loops (fewer than three distinct points) are ignored. The returned triangles are lists of three(x, y)pairs. Downstream code is responsible for lifting the coordinates into 3D and enforcing winding to match the target surface normal.
yapcad.xform module
- class yapcad.xform.Matrix(a=False, trans=False)[source]
Bases:
object4x4 transformation matrix class for transforming homogemenous 3D coordinates
- mul(x)[source]
Return the product of this matrix and
x.xmay be anotherMatrix, a 4D vector, or a scalar. In each case the appropriate matrix multiplication is performed. Ifxis none of these types, aValueErroris raised.