In mechanical design, optimization procedures have mostly been implemented solely by CAE codes combined by optimization routine, in which the model is built, analyzed and optimized. In the complex geometries, however, CAD is indispensable tool for the efficient and accurate modeling. This paper presents a method to carry out optimization, in which CAD and CAE are used for modeling and analysis respectively and integrated in an optimization routine. Application Programming Interface (API) function is exploited to automate CAD modeling, which enables direct access to CAD. The advantage of this method is that the user can create very complex object in Parametric and automated way, which is impossible in CAE codes. Unigraphics and ANSYS are adopted as CAD and CAE tools. In ANSYS, automated analysis is done using codes made by a script language, APDL(ANSYS Parametric Design Language). Optimization is conducted by VisualDOC and IDESIGN respectively. As an illustrative example, a mold design problem is studied, which is to minimize temperature deviation over a diagonal line of the surface of the mold in contact with hot glass.