An automatic complex topology lightweight structure generation method (ACTLSGM) is presented to automatically generate 3D models of lightweight truss structures with a boundary surface of any shape. The core idea of the ACTLSGM is to use the PIMesh, a mesh generation algorithm developed by the authors, to generate node distributions inside the object representing the boundary surface of the target complex topology structures; raw lightweight truss structures are then generated based on the node distributions; the resulting lightweight truss structure is then created by adjusting the radius of the raw truss structures using an optimization algorithm based on finite element truss analysis. The finite element analysis-based optimization algorithm can ensure that the resulting structures satisfy the design requirements on stress distributions or stiffness. Three demos, including a lightweight structure for a cantilever beam, a femur bone scaffold, and a 3D shoe sole model with adaptive stiffness, can be used to adjust foot pressure distributions for patients with diabetic foot problems and are generated to demonstrate the performance of the ACTLSGM. The ACTLSGM is not limited to generating 3D models of medical devices, but can be applied in many other fields, including 3D printing infills and other fields where customized lightweight structures are required.