$$\rightleftharpoonup{xx}$$
$$\longleftharp{xx}$$,
$$\longrightharp{xx}$$,
Automatically generating accurate SysML models from natural-language requirements can substantially accelerate the adoption of Model-Based Systems Engineering (MBSE) in complex system development. However, using large language models (LLMs) to generate model code often fails to meet the strict syntactic constraints of formal modeling languages, and consistently ensuring semantic alignment between generated models and requirements remains challenging. To address these challenges, this paper presents MAS4SysML, a multi-agent collaborative framework for SysML v2 code generation that improves syntactic correctness and semantic consistency under a constrained repair budget. The framework decomposes a modeling task into hierarchical subtasks, formalizes them as structured task cards, and generates model code in a bottom-up manner. During generation, an official validation environment is used for syntax diagnostics; after completion, the framework verifies semantic consistency between the code and the task cards. If syntax or semantic validation fails, the framework iteratively repairs and revalidates the code within a predefined repair budget, guided by diagnostic feedback, until the validation criteria are satisfied or the budget is exhausted. To evaluate the proposed method, we construct a SysML v2 dataset spanning five core task types—requirements, use cases, structure, parametrics, and state machines—and conduct comparative experiments. Results show that MAS4SysML reduces the average syntax error rate to 2.63, increases semantic similarity to 0.91, and outperforms existing code-generation methods overall.