// META-2043 Extend CAD CAT module to create component-level Parameters for CAD Model's Parameters void CADModuleImportExtension(CyPhy.CADModel ProcessedCADModel) { // When the user imports a CAD Model, the current implementation creates a CyPhy CADModel object. After this point: int numComponentParams = 0; foreach (CyPhy.CADParameter parm in ProcessedCADModel.Children.CADParameterCollection) { // - For each CADParameter object, create a corresponding Property object under the parent Component. // - Give the Property the same name CyPhy.Property newprop = CyPhyClasses.Property.Create(GetCurrentComp()); newprop.Name = parm.Name; if (!String.IsNullOrWhiteSpace(parm.Attributes.Value)) { newprop.Attributes.Value = parm.Attributes.Value; } // - Create a CADParameterPortMap connection from the Property to the CADParameter CyPhy.CADParameterPortMap ppmap = CyPhyClasses.CADParameterPortMap.Connect(newprop, parm); ppmap.Name = parm.Name; // - Perform some layout "niceification" on the resulting objects. foreach (MgaPart item in (newprop.Impl as MgaFCO).Parts) { item.SetGmeAttrs(null, PARAMETER_START_X, greatest_current_y + PARAMETER_START_Y + (numComponentParams * PARAMETER_ADJUST_Y)); } numComponentParams++; } }
// META-2043 Extend CAD CAT module to create component-level Parameters for CAD Model's Parameters void CADModuleImportExtension(CyPhy.CADModel ProcessedCADModel) { // When the user imports a CAD Model, the current implementation creates a CyPhy CADModel object. After this point: int numComponentParams = 0; foreach (CyPhy.CADParameter parm in ProcessedCADModel.Children.CADParameterCollection) { // - For each CADParameter object, create a corresponding Property object under the parent Component. // - Give the Property the same name CyPhy.Property newprop = CyPhyClasses.Property.Create((CyPhy.Component)GetCurrentDesignElement()); newprop.Name = parm.Name; if (!String.IsNullOrWhiteSpace(parm.Attributes.Value)) { newprop.Attributes.Value = parm.Attributes.Value; } if (String.IsNullOrWhiteSpace(parm.Attributes.Unit) == false) { if (map == null) { map = new CyPhyUnitMap(); map._cyPhyMLRootFolder = CyPhyClasses.RootFolder.GetRootFolder(ProcessedCADModel.Impl.Project); map.init(true); } CyPhy.unit unit; if (map._unitSymbolCyPhyMLUnitMap.TryGetValue(parm.Attributes.Unit, out unit)) { newprop.Referred.unit = unit; } } // - Create a CADParameterPortMap connection from the Property to the CADParameter CyPhy.CADParameterPortMap ppmap = CyPhyClasses.CADParameterPortMap.Connect(newprop, parm); ppmap.Name = parm.Name; // - Perform some layout "niceification" on the resulting objects. foreach (MgaPart item in (newprop.Impl as MgaFCO).Parts) { item.SetGmeAttrs(null, PARAMETER_START_X, greatest_current_y + PARAMETER_START_Y + (numComponentParams * PARAMETER_ADJUST_Y)); } numComponentParams++; } }