With the development of humanoid robots, lightweight construction and energy efficiency play an important role. In state-of-the-art processes and methods concerning structural optimization it is assumed that there exists a set of external loads or load functions acting on the part. But humanoid robots are very complex mechatronic systems. The fact that the system's dynamic properties and its overall behavior may change due to geometric modifications of a part caused by an optimization process is typically neglected. In order to take into account the interaction between the part, dynamic system, control system and the changing mechanical behavior with all its consequences for the optimization process, a simulation of the complete mechatronic system is integrated into the optimization process within the research work presented in this paper. A hybrid multibody system (MBS) simulation, that is, a MBS containing flexible bodies, in conjunction with a co-simulation of the control system represented by tools of the Computer Aided Control Engineering (CACE) is integrated into the optimization process. By an inner optimization loop the controller parameter are adopted new in each iteration of the topology optimization in order to provide realistic load cases. The research work presented in this paper is a contribution towards the integration of existing CAE methods into a continuous process for structural optimization. The benefits will be illustrated by an optimization of parts of the humanoid robot ARMAR of the collaborative research centre for "Humanoid Robots". The new process allows an efficient optimization of structures "within" their surrounding mechatronic system.