public Datum(string name, string type, string compid, bool guide) { DatumName = name; if (type == "CoordinateSystem") { Type = DatumType.CSYS; } else if (type == "Point") { Type = DatumType.Point; } else if (type == "Surface") { Type = DatumType.Surface; } else if (type == "Axis") { Type = DatumType.Axis; } ComponentID = compid; DatumID = UtilityHelpers.MakeUdmID(); Guide = guide; }
protected override void AddAnalysisToXMLOutput(CAD.AssemblyType cadassembly) { base.AddAnalysisToXMLOutput(cadassembly); CAD.AnalysesType cadanalysis = GetCADAnalysis(cadassembly); CAD.BlastType blastanalysis = new CAD.BlastType(); blastanalysis._id = UtilityHelpers.MakeUdmID(); blastanalysis.AnalysisID = blastConfig.analysis.ID; if (referencePlaneType != Survivability.ReferencePlaneTypeEnum.None) { CAD.ReferencePlaneType refplane = new CAD.ReferencePlaneType(); refplane._id = UtilityHelpers.MakeUdmID(); refplane.Type = referencePlaneType.ToString(); blastanalysis.ReferencePlane = new CAD.ReferencePlaneType[1]; // cardinality should be changed to have 0..1 in CAD_Uml.xme blastanalysis.ReferencePlane[0] = refplane; } List <CAD.MetricType> metrics = MetricsToCADXMLOutput(Computations, cadassembly.ConfigurationID); if (metrics.Count > 0) { blastanalysis.Metrics = new CAD.MetricsType(); blastanalysis.Metrics._id = UtilityHelpers.MakeUdmID(); blastanalysis.Metrics.Metric = metrics.ToArray(); } if (blastanalysis.ReferencePlane != null || blastanalysis.Metrics != null) { cadanalysis.Blast = new CAD.BlastType[] { blastanalysis }; } }
public CAD.GeometryType ToCADXMLOutput() { CAD.GeometryType geometryout = new CAD.GeometryType(); geometryout._id = UtilityHelpers.MakeUdmID(); CAD.FeaturesType featuresout = new CAD.FeaturesType(); featuresout._id = UtilityHelpers.MakeUdmID(); featuresout.FeatureInterfaceType = "CAD_DATUM"; // fixed featuresout.FeatureGeometryType = featureType.ToString(); //featuresout.FeatureGeometryType = "POINT"; featuresout.GeometryType = GeometryType; featuresout.FeatureID = FeatureID; featuresout.PrimaryGeometryQualifier = PrimaryQualifier; featuresout.SecondaryGeometryQualifier = SecondaryQualifier; List <CAD.FeatureType> featureList = new List <CAD.FeatureType>(); foreach (var item in GeometryFeatures) { CAD.FeatureType feature = new CAD.FeatureType { _id = UtilityHelpers.MakeUdmID(), ComponentID = item.ComponentID, Name = item.DatumName, MetricID = item.MetricID }; featureList.Add(feature); } featuresout.Feature = featureList.ToArray(); geometryout.Features = new CAD.FeaturesType[1]; geometryout.Features[0] = featuresout; return(geometryout); }
protected override void AddAnalysisToXMLOutput(CAD.AssemblyType cadassembly) { base.AddAnalysisToXMLOutput(cadassembly); CAD.AnalysesType cadanalysis = GetCADAnalysis(cadassembly); CAD.BallisticType ballisticanalysis = new CAD.BallisticType(); ballisticanalysis._id = UtilityHelpers.MakeUdmID(); ballisticanalysis.AnalysisID = AnalysisID; if (referencePlaneType != Survivability.ReferencePlaneTypeEnum.None) { CAD.ReferencePlaneType refplane = new CAD.ReferencePlaneType(); refplane._id = UtilityHelpers.MakeUdmID(); refplane.Type = referencePlaneType.ToString(); ballisticanalysis.ReferencePlane = refplane; } if (customShotlineList.Any()) { CAD.ShotlinesType cadshotlinesuite = new CAD.ShotlinesType(); cadshotlinesuite._id = UtilityHelpers.MakeUdmID(); List <CAD.ShotlineType> shotlineList = new List <CAD.ShotlineType>(); foreach (var shotline in customShotlineList) { CAD.ShotlineType cadshotline = new CAD.ShotlineType(); cadshotline._id = UtilityHelpers.MakeUdmID(); cadshotline.Azimuth = shotline.Azimuth; cadshotline.Elevation = shotline.Elevation; cadshotline.BallisticThreatRef = shotline.BallisticThreatRef; cadshotline.ComponentID = shotline.ComponentID; cadshotline.DatumPoint = shotline.DatumPoint; cadshotline.ShotlineName = shotline.ShotlineName; shotlineList.Add(cadshotline); } cadshotlinesuite.Shotline = shotlineList.ToArray(); ballisticanalysis.Shotlines = cadshotlinesuite; } List <CAD.MetricType> metrics = MetricsToCADXMLOutput(Computations, cadassembly.ConfigurationID); if (metrics.Count > 0) { ballisticanalysis.Metrics = new CAD.MetricsType(); ballisticanalysis.Metrics._id = UtilityHelpers.MakeUdmID(); ballisticanalysis.Metrics.Metric = metrics.ToArray(); } if (ballisticanalysis.Metrics != null || ballisticanalysis.ReferencePlane != null || ballisticanalysis.Shotlines != null) { cadanalysis.Ballistic = new CAD.BallisticType[] { ballisticanalysis }; } }
public virtual CAD.AnalysisConstraintType ToCADXMLOutput() { CAD.AnalysisConstraintType constraintout = new CAD.AnalysisConstraintType(); constraintout._id = UtilityHelpers.MakeUdmID(); if (Geometry != null) { constraintout.Geometry = Geometry.ToCADXMLOutput(); } return(constraintout); }
public virtual CAD.LoadType ToCADXMLOutput() { CAD.LoadType loadout = new CAD.LoadType(); loadout._id = UtilityHelpers.MakeUdmID(); if (Geometry != null) { loadout.Geometry = Geometry.ToCADXMLOutput(); } return(loadout); }
public override CAD.AnalysisConstraintType ToCADXMLOutput() { CAD.AnalysisConstraintType constraintout = base.ToCADXMLOutput(); constraintout.Pin = new CAD.PinType(); constraintout.Pin._id = UtilityHelpers.MakeUdmID(); constraintout.Pin.AxialDisplacement = new CAD.AxialDisplacementType(); constraintout.Pin.AxialDisplacement._id = UtilityHelpers.MakeUdmID(); constraintout.Pin.AxialDisplacement.Property = AxialDisplacement; constraintout.Pin.AxialRotation = new CAD.AxialRotationType(); constraintout.Pin.AxialRotation._id = UtilityHelpers.MakeUdmID(); constraintout.Pin.AxialRotation.Property = AxialRotation; return(constraintout); }
public CAD.AssembliesType ToCADXMLOutput(TestBenchModel.TestBenchBase tb, bool metalink = false) { CAD.AssembliesType outputAssembliesType = new CAD.AssembliesType(); outputAssembliesType.VersionInfo = ""; List <CAD.AssemblyType> asmlist = new List <CAD.AssemblyType>(); foreach (var item in assemblies.Values) { CAD.AssemblyType assembly = item.ToCADXMLOutput(tb); asmlist.Add(assembly); pointCoordinatesList.AddRange(item.PointCoordinatesList); } if (asmlist.Count > 1 && metalink) { Logger.Instance.AddLogMessage("There's more than one unconnected assembly in the model. Meta-Link may not work with this model.", Severity.Warning); } if (orphans.Any()) { if (metalink) { CAD.AssemblyType topAssembly = asmlist.First(); List <CAD.CADComponentType> cadcomponentlist = topAssembly.CADComponent.CADComponent.ToList(); foreach (var orphan in orphans) { cadcomponentlist.Add(orphan.ToCADXMLOutput(tb.GetRepresentation(orphan))); } topAssembly.CADComponent.CADComponent = cadcomponentlist.ToArray(); } else { List <CAD.CADComponentType> orphanlist = new List <CAD.CADComponentType>(); CAD.UnassembledComponentsType orphancomponentParent = new CAD.UnassembledComponentsType(); orphancomponentParent._id = UtilityHelpers.MakeUdmID(); foreach (var orphan in orphans) { orphanlist.Add(orphan.ToCADXMLOutput(tb.GetRepresentation(orphan))); } orphancomponentParent.CADComponent = orphanlist.ToArray(); outputAssembliesType.UnassembledComponents = orphancomponentParent; } } outputAssembliesType.Assembly = asmlist.ToArray(); return(outputAssembliesType); }
public KinematicJointPair(KinematicJoint a, KinematicJoint b) { XmlID = UtilityHelpers.MakeUdmID(); if (a.TopLevelID != null) { XmlID = a.TopLevelID; } else if (b.TopLevelID != null) { XmlID = b.TopLevelID; } A = a; B = b; }
public CAD.GeometryMarkerType ToCADXml() { CAD.GeometryMarkerType marker = new CAD.GeometryMarkerType(); marker._id = UtilityHelpers.MakeUdmID(); marker.ComponentID = ComponentID; marker.x = x; marker.y = y; marker.z = z; marker.i = i; marker.j = j; marker.k = k; marker.pi = pi; return(marker); }
protected CAD.AnalysesType GetCADAnalysis(CAD.AssemblyType assembly) { CAD.AnalysesType analysis; if (assembly.Analyses == null) { analysis = new CAD.AnalysesType() { _id = UtilityHelpers.MakeUdmID() }; assembly.Analyses = analysis; } else { analysis = assembly.Analyses; } return(analysis); }
private CAD.PairType MakeRootConstraint(string location, string componentDispID, string assemblyID, bool rootIsAsmType, Datum datum) { CAD.PairType pair = new CAD.PairType(); pair._id = UtilityHelpers.MakeUdmID(); pair.FeatureGeometryType = "SURFACE"; pair.FeatureAlignmentType = "ALIGN"; pair.FeatureInterfaceType = "CAD_DATUM"; List <CAD.ConstraintFeatureType> featurelist = new List <CAD.ConstraintFeatureType>(); CAD.ConstraintFeatureType constraintFeature = new CAD.ConstraintFeatureType(); constraintFeature._id = UtilityHelpers.MakeUdmID(); constraintFeature.ComponentID = componentDispID; constraintFeature.FeatureOrientationType = "SIDE_A"; if (rootIsAsmType) { constraintFeature.FeatureName = "ASM_" + location; } else { constraintFeature.FeatureName = location; } // META-3555 hack if (datum != null && datum.Marker != null) { constraintFeature.GeometryMarker = datum.Marker.ToCADXml(); } featurelist.Add(constraintFeature); CAD.ConstraintFeatureType asmConstraint = new CAD.ConstraintFeatureType(); asmConstraint._id = UtilityHelpers.MakeUdmID(); asmConstraint.ComponentID = assemblyID; asmConstraint.FeatureOrientationType = "SIDE_A"; asmConstraint.FeatureName = "ASM_" + location; featurelist.Add(asmConstraint); pair.ConstraintFeature = featurelist.ToArray(); return(pair); }
public override CAD.LoadType ToCADXMLOutput() { CAD.LoadType loadout = base.ToCADXMLOutput(); loadout.ForceMoment = new CAD.ForceMomentType(); loadout.ForceMoment._id = UtilityHelpers.MakeUdmID(); loadout.ForceMoment.Force = new CAD.ForceType(); loadout.ForceMoment.Force._id = Force_id; loadout.ForceMoment.Force.Units = ForceUnit; loadout.ForceMoment.Force.x = Force_X; loadout.ForceMoment.Force.y = Force_Y; loadout.ForceMoment.Force.z = Force_Z; loadout.ForceMoment.Moment = new CAD.MomentType(); loadout.ForceMoment.Moment._id = Moment_id; loadout.ForceMoment.Moment.Units = MomentUnit; loadout.ForceMoment.Moment.x = Moment_X; loadout.ForceMoment.Moment.y = Moment_Y; loadout.ForceMoment.Moment.z = Moment_Z; return(loadout); }
public override CAD.AnalysisConstraintType ToCADXMLOutput() { CAD.AnalysisConstraintType constraintout = base.ToCADXMLOutput(); constraintout.Displacement = new CAD.DisplacementType(); constraintout.Displacement._id = UtilityHelpers.MakeUdmID(); constraintout.Displacement.Rotation = new CAD.RotationType(); constraintout.Displacement.Rotation._id = UtilityHelpers.MakeUdmID(); constraintout.Displacement.Rotation.Units = RotationUnits; constraintout.Displacement.Rotation.x = Rotation_X; constraintout.Displacement.Rotation.y = Rotation_Y; constraintout.Displacement.Rotation.z = Rotation_Z; constraintout.Displacement.Translation = new CAD.TranslationType(); constraintout.Displacement.Translation._id = UtilityHelpers.MakeUdmID(); constraintout.Displacement.Translation.Units = TranslationUnits; constraintout.Displacement.Translation.x = Translation_X; constraintout.Displacement.Translation.y = Translation_Y; constraintout.Displacement.Translation.z = Translation_Z; return(constraintout); }
protected void AddStaticAnalysisMetrics(CAD.AssemblyType assemblyRoot) { if (ExportComponentPoints && cadDataContainer.PointCoordinatesList.Any()) { StaticAnalysisMetrics.AddRange(cadDataContainer.PointCoordinatesList.Where(x => !StaticAnalysisMetrics.Exists(r => r.MetricID == x.MetricID))); } if (StaticAnalysisMetrics.Any()) { CAD.AnalysesType cadanalysis = GetCADAnalysis(assemblyRoot); CAD.StaticType staticanalysis = GetStaticAnalysis(cadanalysis); //CAD.StaticType staticanalysis = new CAD.StaticType(); List <CAD.MetricType> metriclist = MetricsToCADXMLOutput(StaticAnalysisMetrics); staticanalysis.Metrics = new CAD.MetricsType(); staticanalysis.Metrics._id = UtilityHelpers.MakeUdmID(); staticanalysis.Metrics.Metric = metriclist.ToArray(); cadanalysis.Static = new CAD.StaticType[] { staticanalysis }; } }
/* * public List<CAD.MetricType> MetricsToCADXMLOutput(string componentID) * { * List<CAD.MetricType> metriclist = new List<CAD.MetricType>(); * foreach (var item in Computations) * { * CAD.MetricType metric = new CAD.MetricType(); * metric._id = UtilityHelpers.MakeUdmID(); * metric.ComponentID = componentID; * metric.MetricID = item.MetricID; * metric.RequestedValueType = "Scalar"; * metric.MetricType1 = item.ComputationType.ToString(); * metric.Details = ""; * metric.MetricName = item.MetricName ?? ""; * metriclist.Add(metric); * } * * return metriclist; * } */ public List <CAD.MetricType> MetricsToCADXMLOutput(List <TBComputation> dataSet, string componentID = "") { List <CAD.MetricType> metriclist = new List <CAD.MetricType>(); foreach (var item in dataSet) { CAD.MetricType ptout = new CAD.MetricType(); ptout._id = UtilityHelpers.MakeUdmID(); ptout.ComponentID = item.ComponentID; ptout.MetricID = item.MetricID; ptout.MetricType1 = item.ComputationType.ToString(); ptout.RequestedValueType = item.RequestedValueType; ptout.ComponentID = String.IsNullOrEmpty(componentID) ? item.ComponentID : componentID; // PointCoordinate metric is tied to a specific Component ptout.Details = item.Details ?? ""; ptout.MetricName = item.MetricName ?? ""; metriclist.Add(ptout); } return(metriclist); }
protected override void AddAnalysisToXMLOutput(CAD.AssemblyType cadassembly) { base.AddAnalysisToXMLOutput(cadassembly); CAD.AnalysesType cadanalysis = GetCADAnalysis(cadassembly); CAD.CFDType cfdanalysis = new CAD.CFDType(); cfdanalysis._id = UtilityHelpers.MakeUdmID(); cfdanalysis.AnalysisID = AnalysisID; List <CAD.MetricType> metrics = MetricsToCADXMLOutput(Computations, cadassembly.ConfigurationID); if (metrics.Count > 0) { cfdanalysis.Metrics = new CAD.MetricsType(); cfdanalysis.Metrics._id = UtilityHelpers.MakeUdmID(); cfdanalysis.Metrics.Metric = metrics.ToArray(); } // Hydrostatics solver setting will go to the CadAssembly.xml as it is interpreted by CadCreateAssembly.exe foreach (var config in cfdConfigs.Where(cfg => cfg is CFDConfig.HydrostaticsSolverSettings)) { CFDConfig.HydrostaticsSolverSettings hconfig = config as CFDConfig.HydrostaticsSolverSettings; cfdanalysis.HydrostaticsSolverSettings = new CAD.HydrostaticsSolverSettingsType[1]; cfdanalysis.HydrostaticsSolverSettings[0] = new CAD.HydrostaticsSolverSettingsType() { VehicleVelocity = 1, FluidMaterial = hconfig.FluidMaterial.ToString(), FluidTemperature = hconfig.FluidTemperature, PitchAngleStart = hconfig.PitchAngleStart, PitchAngleEnd = hconfig.PitchAngleEnd, PitchAngleStepSize = hconfig.PitchAngleStep, RollAngleStart = hconfig.RollAngleStart, RollAngleEnd = hconfig.RollAngleEnd, RollAngleStepSize = hconfig.RollAngleStep }; } cadanalysis.CFD = new CAD.CFDType[] { cfdanalysis }; AddStaticAnalysisMetrics(cadassembly); }
protected CAD.StaticType GetStaticAnalysis(CAD.AnalysesType analyses) { CAD.StaticType staticAnalysis; if (analyses.Static == null) { analyses.Static = new CAD.StaticType[1] { new CAD.StaticType() { _id = UtilityHelpers.MakeUdmID(), AnalysisID = AnalysisID } }; staticAnalysis = analyses.Static[0]; } else { staticAnalysis = analyses.Static.FirstOrDefault(); } return(staticAnalysis); }
private void TraverseComposites(CyPhy.Component component) { foreach (var material in component.Children.MaterialContentsCollection) { CAD.ElementType cadElement = new CAD.ElementType() { _id = UtilityHelpers.MakeUdmID(), ElementType1 = "SURFACE" }; MgaModel materialMga = material.Impl as MgaModel; List <MgaFCO> startDirPts = new List <MgaFCO>(); List <MgaFCO> endDirPts = new List <MgaFCO>(); startDirPts = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(materialMga, "Start_Direction"); endDirPts = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(materialMga, "End_Direction"); if (startDirPts.Count != 1 && endDirPts.Count != 1) { Logger.Instance.AddLogMessage("Material Content must contain one Start_Direction and one End_Direction point.", Severity.Warning); continue; } CyPhy.Point startDirPt = CyPhyClasses.Point.Cast(startDirPts[0]); string startDirPtDatumName = GetFeatureName(startDirPt); CyPhy.Point endDirPt = CyPhyClasses.Point.Cast(endDirPts[0]); string endDirPtDatumName = GetFeatureName(endDirPt); CAD.OrientationType cadOrientation = new CAD.OrientationType() { _id = UtilityHelpers.MakeUdmID() }; CAD.GeometryType cadGeometry = new CAD.GeometryType() { _id = UtilityHelpers.MakeUdmID() }; CAD.FeatureType cadStartFeature = new CAD.FeatureType() { _id = UtilityHelpers.MakeUdmID(), ComponentID = DisplayID, Name = startDirPtDatumName, MetricID = DisplayID + ":" + startDirPtDatumName }; TestBenchModel.TBComputation startFeatureComputation = new TestBenchModel.TBComputation() { ComponentID = DisplayID, ComputationType = TestBenchModel.TBComputation.Type.POINTCOORDINATES, Details = startDirPtDatumName, FeatureDatumName = startDirPtDatumName, MetricID = DisplayID + ":" + startDirPtDatumName, RequestedValueType = "Vector" }; pointCoordinatesList.Add(startFeatureComputation); if (String.IsNullOrEmpty(startDirPtDatumName)) { Logger.Instance.AddLogMessage("Empty point datum name [" + startDirPt.Path + "]", Severity.Warning); } CAD.FeatureType cadEndFeature = new CAD.FeatureType() { _id = UtilityHelpers.MakeUdmID(), ComponentID = DisplayID, Name = endDirPtDatumName, MetricID = DisplayID + ":" + endDirPtDatumName }; TestBenchModel.TBComputation endFeatureComputation = new TestBenchModel.TBComputation() { ComponentID = DisplayID, ComputationType = TestBenchModel.TBComputation.Type.POINTCOORDINATES, Details = endDirPtDatumName, FeatureDatumName = endDirPtDatumName, MetricID = DisplayID + ":" + endDirPtDatumName, RequestedValueType = "Vector" }; pointCoordinatesList.Add(endFeatureComputation); if (String.IsNullOrEmpty(endDirPtDatumName)) { Logger.Instance.AddLogMessage("Empty point datum name [" + endDirPt.Path + "]", Severity.Warning); } CAD.FeaturesType cadFeatures = new CAD.FeaturesType() { _id = UtilityHelpers.MakeUdmID(), FeatureID = material.ID, GeometryType = "Vector", FeatureInterfaceType = "CAD_DATUM", FeatureGeometryType = "POINT", PrimaryGeometryQualifier = "", SecondaryGeometryQualifier = "" }; cadFeatures.Feature = new CAD.FeatureType[2]; cadFeatures.Feature[0] = cadStartFeature; cadFeatures.Feature[1] = cadEndFeature; cadGeometry.Features = new CAD.FeaturesType[1]; cadGeometry.Features[0] = cadFeatures; cadOrientation.Geometry = cadGeometry; // Material Layups CAD.MaterialLayupType cadLayers = new CAD.MaterialLayupType() { _id = UtilityHelpers.MakeUdmID(), Position = material.Attributes.Position.ToString().ToUpper(), Offset = (material.Attributes.Position.ToString().ToUpper() != "OFFSET_BY_VALUE") ? 0 : (material.Attributes.PositionOffset), Direction = material.Attributes.MaterialLayupDirection.ToString().ToUpper() }; int layerCnt = material.Children.MaterialLayerCollection.Count(); if (layerCnt > 0) { cadLayers.Layer = new CAD.LayerType[layerCnt]; int k = 0; foreach (var layer in material.Children.MaterialLayerCollection.OrderBy(i => i.Attributes.LayerID)) { CAD.LayerType cadLayer = new CAD.LayerType() { _id = UtilityHelpers.MakeUdmID(), ID = layer.Attributes.LayerID, Drop_Order = layer.Attributes.DropOrder, Material_Name = layer.Attributes.LayerMaterial, Orientation = layer.Attributes.LayerOrientation, Thickness = layer.Attributes.LayerThickness }; cadLayers.Layer[k] = cadLayer; k++; } } CAD.ElementContentsType cadElementContents = new CAD.ElementContentsType(); cadElementContents._id = UtilityHelpers.MakeUdmID(); cadElementContents.Orientation = cadOrientation; cadElementContents.MaterialLayup = cadLayers; cadElement.ElementContents = cadElementContents; if (material.DstConnections.ContentsToGeometryCollection.Count() < 1 || material.DstConnections.ContentsToGeometryCollection.Count() > 1) { Logger.Instance.AddLogMessage("Material Content need to connect to one Face geometry.", Severity.Warning); continue; } // Face, Polygon, or Extrusion Geometry CyPhy.ContentsToGeometry conn = material.DstConnections.ContentsToGeometryCollection.FirstOrDefault(); if (conn != null) { CyPhy.Face faceGeometry = conn.DstEnds.Face; CyPhy.Polygon polgonGeometry = conn.DstEnds.Polygon; CyPhy.Extrusion extrusionGeometry = conn.DstEnds.Extrusion; int countGeometryTypes = 0; if (faceGeometry != null) { ++countGeometryTypes; } if (polgonGeometry != null) { ++countGeometryTypes; } if (extrusionGeometry != null) { ++countGeometryTypes; } if (countGeometryTypes != 1) { Logger.Instance.AddLogMessage("MaterialContents must be connected to one and only one geometry type (i.e. FACE, POLOGON, or EXTRUSION).", Severity.Warning); continue; } // Approach when only FACE was supported //String primBoundaryQ = faceGeometry.Attributes.BoundaryQualifier.ToString().Replace("_", string.Empty); //MgaModel faceMga = faceGeometry.Impl as MgaModel; //List<MgaFCO> normalDirPts = new List<MgaFCO>(); //normalDirPts = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(faceMga, "Direction_Reference_Point"); String primBoundaryQ = ""; MgaModel faceMga; List <MgaFCO> normalDirPts = new List <MgaFCO>(); if (faceGeometry != null) { primBoundaryQ = faceGeometry.Attributes.BoundaryQualifier.ToString().Replace("_", string.Empty); faceMga = faceGeometry.Impl as MgaModel; normalDirPts = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(faceMga, "Direction_Reference_Point"); } else if (polgonGeometry != null) { primBoundaryQ = polgonGeometry.Attributes.BoundaryQualifier.ToString().Replace("_", string.Empty); faceMga = polgonGeometry.Impl as MgaModel; normalDirPts = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(faceMga, "Direction_Reference_Point"); } else if (extrusionGeometry != null) { primBoundaryQ = extrusionGeometry.Attributes.BoundaryQualifier.ToString().Replace("_", string.Empty); faceMga = extrusionGeometry.Impl as MgaModel; normalDirPts = CyPhy2CAD_CSharp.DataRep.CADGeometry.FindByRole(faceMga, "Direction_Reference_Point"); } if (normalDirPts.Count != 1) { Logger.Instance.AddLogMessage("Geometry (FACE, POLYGON, or EXTRUSION) can contain only one Direction_Reference_Point point.", Severity.Warning); continue; } CyPhy.Point normalDirPt = CyPhyClasses.Point.Cast(normalDirPts.FirstOrDefault()); string normalPtFeatureName = GetFeatureName(normalDirPt); if (String.IsNullOrEmpty(normalPtFeatureName)) { Logger.Instance.AddLogMessage("Direction_Reference_Point point of the Face/Ploygon/Extrusion geometry doesn't have a datum name. Make sure it is connected to a valid point inside a CADModel.", Severity.Warning); continue; } CyPhy2CAD_CSharp.DataRep.CADGeometry faceOrExtruOrPolyGeometryRep = null; if (faceGeometry != null) { faceOrExtruOrPolyGeometryRep = CyPhy2CAD_CSharp.DataRep.CADGeometry.CreateGeometry(faceGeometry); if (faceOrExtruOrPolyGeometryRep == null) { Logger.Instance.AddLogMessage("Unsuccessfully created a representation of a Face Geometry.", Severity.Warning); continue; } } else if (polgonGeometry != null) { faceOrExtruOrPolyGeometryRep = CyPhy2CAD_CSharp.DataRep.CADGeometry.CreateGeometry(polgonGeometry); if (faceOrExtruOrPolyGeometryRep == null) { Logger.Instance.AddLogMessage("Unsuccessfully created a representation of a Polygon Geometry.", Severity.Warning); continue; } } else if (extrusionGeometry != null) { faceOrExtruOrPolyGeometryRep = CyPhy2CAD_CSharp.DataRep.CADGeometry.CreateGeometry(extrusionGeometry); if (faceOrExtruOrPolyGeometryRep == null) { Logger.Instance.AddLogMessage("Unsuccessfully created a representation of a Extrusion Geometry.", Severity.Warning); continue; } } // Element/Geometry CAD.GeometryType cadFaceOrExtruOrPolyGeometryOut = faceOrExtruOrPolyGeometryRep.ToCADXMLOutput(); if (cadFaceOrExtruOrPolyGeometryOut == null) { Logger.Instance.AddLogMessage("Unsuccessfully converted a representation of a Face/Ploygon/Extrusion Geometry to CAD xml.", Severity.Warning); continue; } cadElement.Geometry = cadFaceOrExtruOrPolyGeometryOut; foreach (var faceOrExtruOrPolyGeomFeatures in cadFaceOrExtruOrPolyGeometryOut.Features) { foreach (var feature_temp in faceOrExtruOrPolyGeomFeatures.Feature) { TestBenchModel.TBComputation faceGeometryComputation = new TestBenchModel.TBComputation() { ComponentID = DisplayID, ComputationType = TestBenchModel.TBComputation.Type.POINTCOORDINATES, Details = feature_temp.Name, FeatureDatumName = feature_temp.Name, MetricID = feature_temp.MetricID, RequestedValueType = "Vector" }; pointCoordinatesList.Add(faceGeometryComputation); } } // Element/Geometry string direction_temp = ""; if (faceGeometry != null) { direction_temp = (faceGeometry.Attributes.NormalDirection == CyPhyClasses.Face.AttributesClass.NormalDirection_enum.Toward_Reference_Point) ? "TOWARD" : "AWAY"; } else if (polgonGeometry != null) { direction_temp = (polgonGeometry.Attributes.NormalDirection == CyPhyClasses.Polygon.AttributesClass.NormalDirection_enum.Toward_Reference_Point) ? "TOWARD" : "AWAY"; } else if (extrusionGeometry != null) { direction_temp = (extrusionGeometry.Attributes.NormalDirection == CyPhyClasses.Extrusion.AttributesClass.NormalDirection_enum.Toward_Reference_Point) ? "TOWARD" : "AWAY"; } CAD.SurfaceNormalType cadSurfaceNormal = new CAD.SurfaceNormalType() { _id = UtilityHelpers.MakeUdmID(), Direction = direction_temp }; CAD.FeaturesType cadSurfaceNormFeatures = new CAD.FeaturesType() { _id = UtilityHelpers.MakeUdmID(), FeatureID = normalDirPt.ID, GeometryType = "POINT", FeatureInterfaceType = "CAD_DATUM", FeatureGeometryType = "POINT", Feature = new CAD.FeatureType[1], PrimaryGeometryQualifier = primBoundaryQ, SecondaryGeometryQualifier = "" }; cadSurfaceNormFeatures.Feature[0] = new CAD.FeatureType() { _id = UtilityHelpers.MakeUdmID(), Name = normalPtFeatureName, ComponentID = DisplayID, MetricID = DisplayID + ":" + normalPtFeatureName }; TestBenchModel.TBComputation surfNormalComputation = new TestBenchModel.TBComputation() { ComponentID = DisplayID, ComputationType = TestBenchModel.TBComputation.Type.POINTCOORDINATES, Details = normalPtFeatureName, FeatureDatumName = normalPtFeatureName, MetricID = DisplayID + ":" + normalPtFeatureName, RequestedValueType = "Vector" }; pointCoordinatesList.Add(surfNormalComputation); if (String.IsNullOrEmpty(normalPtFeatureName)) { Logger.Instance.AddLogMessage("Empty point datum name [" + normalDirPt.Path + "]", Severity.Warning); } CAD.GeometryType cadSurfaceNormGeom = new CAD.GeometryType() { _id = UtilityHelpers.MakeUdmID(), Features = new CAD.FeaturesType[1], }; cadSurfaceNormGeom.Features[0] = cadSurfaceNormFeatures; cadSurfaceNormal.Geometry = cadSurfaceNormGeom; cadElement.SurfaceNormal = cadSurfaceNormal; } this.CadElementsList.Add(cadElement); } }
/* * private void FindMatchingSolidModelingFeatures(CyPhy.CADDatum datum, * CyPhy.CADModel acadmodel) * { * // META-947: Creates a virtual connector * * Dictionary<string, DataRep.Datum> featuremap = new Dictionary<string, DataRep.Datum>(); * FindMatchingDatums(datum, * acadmodel, * featuremap); * * if (featuremap.Count > 0) * { * // virtual connector * DataRep.StructuralInterfaceConstraint sirep = new StructuralInterfaceConstraint(datum, this.Id); * sirep.DatumList = featuremap; * sirep.DegreeFreedom = sirep.GetDegreesOfFreedom(); * StructuralInterfaceNodes[datum.ID] = sirep; * } * } * * private void FindMatchingSolidModelingFeatures(CyPhy.Connector a, * CyPhy.CADModel acadmodel) * { * // META-947: Connector instead of StructuralInterface * // [1] Connectors can be nested so find all cad datums within a connector recursively * // [2] Find connected datums * // Skip Connector without any Datum Ports * * List<CyPhy.CADDatum> CadDatum_List = new List<CyPhy.CADDatum>(); * FindCadDatumsInConnector(a, CadDatum_List); * * Dictionary<string, DataRep.Datum> featuremap = new Dictionary<string, DataRep.Datum>(); * * if (CadDatum_List.Count() > 0) * { * foreach (CyPhy.CADDatum item in CadDatum_List) * { * FindMatchingDatums(item, * acadmodel, * featuremap); * } * * } * * if (featuremap.Count > 0) * { * DataRep.StructuralInterfaceConstraint sirep = new StructuralInterfaceConstraint(a, this.Id); * sirep.DatumList = featuremap; * sirep.DegreeFreedom = sirep.GetDegreesOfFreedom(); * StructuralInterfaceNodes[a.ID] = sirep; * } * } * * * private void FindMatchingDatums(CyPhy.CADDatum datum, * CyPhy.CADModel cadmodel, * Dictionary<string, DataRep.Datum> featuremap) * { * string cadmodel_id = cadmodel.ID; * string alignment = "ALIGN"; * string orientation = "NONE"; * * * if (datum.Kind == "Surface") * { * alignment = (datum as CyPhy.Surface).Attributes.Alignment.ToString(); * } * * CadDatumTraversal traversal = new CadDatumTraversal(datum, * cadmodel_id); * * if (traversal.datumFound.Count > 0) * { * if (traversal.datumFound.Count > 1) * { * Logger.Instance.AddLogMessage("Connector datum connected to multiple datums in the same CADModel [" + datum.Path + "]", Severity.Error); * return; * } * * CyPhy2CAD_CSharp.DataRep.Datum datumRep = new DataRep.Datum(traversal.datumFound.First().Attributes.DatumName, * datum.Kind, * this.DisplayID); * if (datum.Kind == "Surface") * { * if (traversal.ReverseMap) * orientation = "SIDE_B"; * else * orientation = "SIDE_A"; * } * * if (datum.Kind == "CoordinateSystem") * { * alignment = "CSYS"; * } * * datumRep.Alignment = alignment; * datumRep.Orientation = orientation; * * if (!featuremap.ContainsKey(datum.Name)) * { * featuremap[datum.Name] = datumRep; * } * } * } * * // Connectors can be nested! * private void FindCadDatumsInConnector(CyPhy.Connector connector, * List<CyPhy.CADDatum> caddatum_list) * { * caddatum_list.AddRange(connector.Children.CADDatumCollection); * * //foreach (CyPhy.Connector conn in connector.Children.ConnectorCollection) * //{ * // FindCadDatumsInConnector(conn, caddatum_list); * //} * * } */ public CAD.CADComponentType ToCADXMLOutput(string representation) { CAD.CADComponentType cadoutput = new CAD.CADComponentType(); cadoutput._id = UtilityHelpers.MakeUdmID(); cadoutput.Type = ModelType.ToUpper(); cadoutput.Standalone = false; cadoutput.SpecialInstruction = Size2Fit ? "SIZE_TO_FIT" : ""; if (!String.IsNullOrEmpty(SpecialInstructions)) { cadoutput.SpecialInstruction += (cadoutput.SpecialInstruction.Length != 0 ? "," : "") + SpecialInstructions; } cadoutput.Name = String.IsNullOrEmpty(ModelName) ? "" : ModelName; cadoutput.DisplayName = Name; cadoutput.MaterialID = MaterialName; cadoutput.ComponentID = DisplayID; cadoutput.Classification = Classification; if (CadParameters.Any()) { CAD.ParametricParametersType parameterRoot = new CAD.ParametricParametersType(); parameterRoot._id = UtilityHelpers.MakeUdmID(); List <CAD.CADParameterType> paramarray = new List <CAD.CADParameterType>(); foreach (var item in CadParameters) { CAD.CADParameterType parameter = new CAD.CADParameterType(); parameter._id = UtilityHelpers.MakeUdmID(); parameter.Type = item.Type; parameter.Name = item.Name; parameter.Value = item.Value; parameter.Units = new CAD.UnitsType(); parameter.Units._id = UtilityHelpers.MakeUdmID(); parameter.Units.Value = item.Unit; paramarray.Add(parameter); } parameterRoot.CADParameter = paramarray.ToArray(); cadoutput.ParametricParameters = parameterRoot; } if (ManufacturingParameters != null && ManufacturingParameters.Count != 0) { cadoutput.ManufacturingParameter = new CAD.ManufacturingParameterType[ManufacturingParameters.Count]; int i = 0; foreach (var param in ManufacturingParameters) { cadoutput.ManufacturingParameter[i++] = new CAD.ManufacturingParameterType() { Name = param.Key, Value = param.Value }; } } if (MetaData != null && MetaData.Count != 0) { cadoutput.MetaData = new CAD.MetaDataType[MetaData.Count]; int i = 0; foreach (var param in MetaData) { cadoutput.MetaData[i++] = new CAD.MetaDataType() { Key = param.Key, Value = param.Value }; } } cadoutput.Representation = representation; if (this.CadElementsList.Count > 0) { cadoutput.Elements = new CAD.ElementsType() { _id = UtilityHelpers.MakeUdmID() }; cadoutput.Elements.Element = this.CadElementsList.ToArray(); } return(cadoutput); }
public CAD.JointType ToCADXMLOutput() { CAD.JointType jointOut = new CAD.JointType(); jointOut._id = UtilityHelpers.MakeUdmID(); /* * if (JointGeometry.Count > 0) * { * jointOut.ConstraintPairs = new CAD.ConstraintPairsType(); * jointOut.ConstraintPairs._id = UtilityHelpers.MakeUdmID(); * * List<CAD.JointPairType> jointPairs = new List<CAD.JointPairType>(); * foreach (var item in JointGeometry) * { * CAD.JointPairType pair = new CAD.JointPairType(); * pair._id = UtilityHelpers.MakeUdmID(); * pair.PairID = item.Key; * pair.Type = item.Value; * } * jointOut.ConstraintPairs.JointPair = jointPairs.ToArray(); * } */ jointOut.ID = XmlID; jointOut.Type = A.JointType.ToString(); List <CAD.LimitType> limits = new List <CAD.LimitType>(); double?RotationLimitDefault = A.RotationLimitDefault; if (!RotationLimitDefault.HasValue) { RotationLimitDefault = B.RotationLimitDefault; } if (RotationLimitDefault.HasValue) { CAD.LimitType limit = new CAD.LimitType(); limit.Role = "RotationDefault"; limit.Value = RotationLimitDefault.Value; limits.Add(limit); } double?RotationLimitMax = A.RotationLimitMax; if (!RotationLimitMax.HasValue) { RotationLimitMax = B.RotationLimitMax; } if (RotationLimitMax.HasValue) { CAD.LimitType limit = new CAD.LimitType(); limit.Role = "RotationMax"; limit.Value = RotationLimitMax.Value; limits.Add(limit); } double?RotationLimitMin = A.RotationLimitMin; if (!RotationLimitMin.HasValue) { RotationLimitMin = B.RotationLimitMin; } if (RotationLimitMin.HasValue) { CAD.LimitType limit = new CAD.LimitType(); limit.Role = "RotationMin"; limit.Value = RotationLimitMin.Value; limits.Add(limit); } double?TranslationLimitDefault = A.TranslationLimitDefault; if (!TranslationLimitDefault.HasValue) { TranslationLimitDefault = B.TranslationLimitDefault; } if (TranslationLimitDefault.HasValue) { CAD.LimitType limit = new CAD.LimitType(); limit.Role = "TranslationDefault"; limit.Value = TranslationLimitDefault.Value; limits.Add(limit); } double?TranslationLimitMax = A.TranslationLimitMax; if (!TranslationLimitMax.HasValue) { TranslationLimitMax = B.TranslationLimitMax; } if (TranslationLimitMax.HasValue) { CAD.LimitType limit = new CAD.LimitType(); limit.Role = "TranslationMax"; limit.Value = TranslationLimitMax.Value; limits.Add(limit); } double?TranslationLimitMin = A.TranslationLimitMin; if (!TranslationLimitMin.HasValue) { TranslationLimitMin = B.TranslationLimitMin; } if (TranslationLimitMin.HasValue) { CAD.LimitType limit = new CAD.LimitType(); limit.Role = "TranslationMin"; limit.Value = TranslationLimitMin.Value; limits.Add(limit); } jointOut.Limit = limits.ToArray(); List <CAD.LimitReferenceType> limitrefs = new List <CAD.LimitReferenceType>(); if (A.RotationDefaultReference != null) { limitrefs.Add(CreateLimitRef(A.RotationDefaultReference, "RotationDefault")); } if (B.RotationDefaultReference != null) { limitrefs.Add(CreateLimitRef(B.RotationDefaultReference, "RotationDefault")); } if (A.TranslationDefaultReference != null) { limitrefs.Add(CreateLimitRef(A.TranslationDefaultReference, "TranslationDefault")); } if (B.TranslationDefaultReference != null) { limitrefs.Add(CreateLimitRef(B.TranslationDefaultReference, "TranslationDefault")); } jointOut.LimitReference = limitrefs.ToArray(); List <CAD.GeometryMarkerType> markers = new List <CAD.GeometryMarkerType>(); if (A.Marker != null) { markers.Add(A.Marker.ToCADXml()); } if (B.Marker != null) { markers.Add(B.Marker.ToCADXml()); } if (markers.Count > 0) { jointOut.GeometryMarker = markers.ToArray(); } return(jointOut); }
public object ToMultibodyOutput() { if (KinematicJointPair != null) { if (KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.PRISMATIC || KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.CYLINDRICAL || KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.REVOLUTE) // Joint_One_Axis_Given { Multibody.ModelAssemblyJointsJoint_One_Axis_Given joint = new Multibody.ModelAssemblyJointsJoint_One_Axis_Given(); joint.ComponentA = new Multibody.ModelAssemblyJointsJoint_One_Axis_GivenComponentA(); joint.ComponentA.ComponentID = Src.DisplayID; joint.ComponentA.Location_MetricID = SrcPortID; joint.ComponentB = new Multibody.ModelAssemblyJointsJoint_One_Axis_GivenComponentB(); joint.ComponentB.ComponentID = Dst.DisplayID; joint.ComponentB.Location_MetricID = DstPortID; joint.ID = KinematicJointPair.XmlID; if (KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.PRISMATIC) { joint.Type = Multibody.ModelAssemblyJointsJoint_One_Axis_GivenType.Translational; } else if (KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.REVOLUTE) { joint.Type = Multibody.ModelAssemblyJointsJoint_One_Axis_GivenType.Revolute; } else { joint.Type = Multibody.ModelAssemblyJointsJoint_One_Axis_GivenType.Cylindrical; } joint.Geometry = new Multibody.ModelAssemblyJointsJoint_One_Axis_GivenGeometry(); joint.Geometry.MetricID = UtilityHelpers.MakeUdmID(); joint.Geometry.Type = "Vector"; return(joint); } else // Joint_Locations_Only { Multibody.ModelAssemblyJointsJoint_Locations_Only joint = new Multibody.ModelAssemblyJointsJoint_Locations_Only(); joint.ComponentA = new Multibody.ModelAssemblyJointsJoint_Locations_OnlyComponentA(); joint.ComponentA.ComponentID = Src.DisplayID; joint.ComponentA.Location_MetricID = SrcPortID; joint.ComponentB = new Multibody.ModelAssemblyJointsJoint_Locations_OnlyComponentB(); joint.ComponentB.ComponentID = Dst.DisplayID; joint.ComponentB.Location_MetricID = DstPortID; joint.ID = KinematicJointPair.XmlID; if (KinematicJointPair.JointType == DataRep.KinematicJoint.KinematicJointType.SPHERICAL) { joint.Type = Multibody.ModelAssemblyJointsJoint_Locations_OnlyType.Spherical; } else { joint.Type = Multibody.ModelAssemblyJointsJoint_Locations_OnlyType.Fixed; } return(joint); } } else { return(null); } }
public CAD.ConstraintType ToCADXMLOutput(TestBenchModel.TestBenchBase testBenchBase) { CAD.ConstraintType constraintout = new CAD.ConstraintType(); constraintout._id = UtilityHelpers.MakeUdmID(); CADComponent src = Src as CADComponent; CADComponent dst = Dst as CADComponent; string srcid = src.DisplayID; string dstid = dst.DisplayID; if (ConstraintPairs.Any()) { List <CAD.PairType> pairlist = new List <CAD.PairType>(); foreach (var item in ConstraintPairs) { List <CAD.ConstraintFeatureType> constrainfeaturelist = new List <CAD.ConstraintFeatureType>(); CAD.PairType pair = new CAD.PairType(); pair._id = UtilityHelpers.MakeUdmID(); pair.FeatureAlignmentType = item.Item1.Alignment; pair.FeatureGeometryType = item.Item1.Type.ToString().ToUpper(); pair.FeatureInterfaceType = "CAD_DATUM"; if (item.Item1.Guide || item.Item2.Guide) { pair.Guide = "True"; } CAD.ConstraintFeatureType afeature = new CAD.ConstraintFeatureType(); afeature._id = UtilityHelpers.MakeUdmID(); afeature.ComponentID = item.Item1.ComponentID; afeature.FeatureName = item.Item1.DatumName; afeature.FeatureOrientationType = item.Item1.Orientation; if (item.Item1.Marker != null) { afeature.GeometryMarker = item.Item1.Marker.ToCADXml(); } CAD.ConstraintFeatureType bfeature = new CAD.ConstraintFeatureType(); bfeature._id = UtilityHelpers.MakeUdmID(); bfeature.ComponentID = item.Item2.ComponentID; bfeature.FeatureName = item.Item2.DatumName; bfeature.FeatureOrientationType = item.Item2.Orientation; if (item.Item2.Marker != null) { bfeature.GeometryMarker = item.Item2.Marker.ToCADXml(); } constrainfeaturelist.Add(afeature); constrainfeaturelist.Add(bfeature); pair.ConstraintFeature = constrainfeaturelist.ToArray(); pairlist.Add(pair); } constraintout.Pair = pairlist.ToArray(); // META-3124 if (KinematicJointPair != null) { constraintout.Joint = KinematicJointPair.ToCADXMLOutput(); } // Associated geomnetries List <CAD.GeometryType> geoms = new List <CAD.GeometryType>(); foreach (var geom in SrcIntf.Geometry.Union(DstIntf.Geometry)) { geoms.Add(geom.ToCADXMLOutput()); } constraintout.Geometry = geoms.ToArray(); // Adjoining surface treatment (if any) if (testBenchBase is TestBenchModel.FEATestBench) { string surftreatment = GetAdjoiningSurfaceTreatment(testBenchBase as TestBenchModel.FEATestBench); constraintout.AdjoiningSurfaceType = surftreatment; } } return(constraintout); }
public CAD.AssemblyType ToCADXMLOutput(TestBenchModel.TestBenchBase tb) { CAD.AssemblyType cadassemblyoutput = new CAD.AssemblyType(); cadassemblyoutput._id = UtilityHelpers.MakeUdmID(); cadassemblyoutput.ConfigurationID = ConfigID; CAD.CADComponentType cadassemblycomponentoutput = new CAD.CADComponentType(); cadassemblycomponentoutput._id = UtilityHelpers.MakeUdmID(); cadassemblycomponentoutput.ComponentID = ConfigID; cadassemblycomponentoutput.Type = "ASSEMBLY"; cadassemblycomponentoutput.Standalone = false; cadassemblycomponentoutput.SpecialInstruction = ""; cadassemblycomponentoutput.Name = this.Name; cadassemblycomponentoutput.DisplayName = DisplayName; cadassemblycomponentoutput.MaterialID = ""; cadassemblycomponentoutput.Representation = ""; cadassemblycomponentoutput.Classification = ""; Dictionary <string, List <CAD.ConstraintType> > compidToConstraint = new Dictionary <string, List <CAD.ConstraintType> >(); // Dictionary<Id, List<Constraints>> var sortedEdges = ChildEdges.OrderBy(x => x.DstPortName).ToList(); foreach (CADEdge edge in sortedEdges) //foreach (CADEdge edge in ChildEdges) { CAD.ConstraintType constraintout = edge.ToCADXMLOutput(tb); if (!compidToConstraint.ContainsKey(edge.Dst.Id)) { compidToConstraint.Add(edge.Dst.Id, new List <CAD.ConstraintType>()); } compidToConstraint[edge.Dst.Id].Add(constraintout); } var sortedS2FEdges = ChildSize2FitEdges.OrderBy(x => x.DstPortName).ToList(); foreach (CADEdge edge in sortedS2FEdges) //foreach (CADEdge edge in ChildSize2FitEdges) { CAD.ConstraintType constraintout = edge.ToCADXMLOutput(tb); if (!compidToConstraint.ContainsKey(edge.Dst.Id)) { compidToConstraint.Add(edge.Dst.Id, new List <CAD.ConstraintType>()); } compidToConstraint[edge.Dst.Id].Add(constraintout); } // META-2885 //Dictionary<string, CAD.CADComponentType> tmpComponents = new Dictionary<string, CAD.CADComponentType>(); List <CAD.CADComponentType> tmpComponents = new List <CAD.CADComponentType>(); var sortedComponents = ChildComponents.OrderBy(x => x.Value.Name).ToDictionary(x => x.Key, x => x.Value).Values.ToList(); foreach (CADComponent component in sortedComponents) //foreach (CADComponent component in ChildComponents.Values) { CAD.CADComponentType componentout = component.ToCADXMLOutput(tb.GetRepresentation(component)); // root constraint if (component.Id == RootComponentID) { bool rootIsAsmType = component.ModelType == "Assembly"; //bool rootIsAsmType = component.ModelType == "PART"; List <CAD.PairType> pairlist = new List <CAD.PairType>(); CAD.ConstraintType rootconstraintout = new CAD.ConstraintType(); rootconstraintout._id = UtilityHelpers.MakeUdmID(); // front pair pairlist.Add(MakeRootConstraint("FRONT", component.DisplayID, ConfigID, rootIsAsmType, component.SpecialDatums.Where(d => d.DatumName == "FRONT").FirstOrDefault())); // top pair pairlist.Add(MakeRootConstraint("TOP", component.DisplayID, ConfigID, rootIsAsmType, component.SpecialDatums.Where(d => d.DatumName == "TOP").FirstOrDefault())); // right pair pairlist.Add(MakeRootConstraint("RIGHT", component.DisplayID, ConfigID, rootIsAsmType, component.SpecialDatums.Where(d => d.DatumName == "RIGHT").FirstOrDefault())); rootconstraintout.Pair = pairlist.ToArray(); componentout.Constraint = new CAD.ConstraintType[1]; componentout.Constraint[0] = rootconstraintout; } else { if (compidToConstraint.ContainsKey(component.Id)) { componentout.Constraint = compidToConstraint[component.Id].ToArray(); } } //tmpComponents[component.Id] = componentout; tmpComponents.Add(componentout); // 3/7/2016 - Export_All_Component_Points at TB level pointCoordinatesList.AddRange(component.PointCoordinatesList); } var size2fitCompSorted = ChildSize2FitComponents.OrderBy(x => x.Value.Name).ToDictionary(x => x.Key, x => x.Value).Values.ToList(); foreach (CADComponent component in size2fitCompSorted)//foreach (CADComponent component in ChildSize2FitComponents.Values) // META-2885 { CAD.CADComponentType componentout = component.ToCADXMLOutput(tb.GetRepresentation(component)); if (compidToConstraint.ContainsKey(component.Id)) { componentout.Constraint = compidToConstraint[component.Id].ToArray(); } //tmpComponents[component.Id] = componentout; tmpComponents.Add(componentout); // 3/7/2016 - Export_All_Component_Points at TB level pointCoordinatesList.AddRange(component.PointCoordinatesList); } // Fill MetaLinkData. Only needed in case if data is prepared for Meta-Link communication if (MetaLinkData != null && MetaLinkData.Components.Count > 0) { cadassemblyoutput.MetaLinkData = new CAD.MetaLinkDataType(); cadassemblyoutput.MetaLinkData.CadComponentMLData = new CAD.CadComponentMLDataType[MetaLinkData.Components.Count]; int i = 0; foreach (MetaLinkData.Component comp in MetaLinkData.Components) { cadassemblyoutput.MetaLinkData.CadComponentMLData[i] = new CAD.CadComponentMLDataType(); cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ID = comp.ID; cadassemblyoutput.MetaLinkData.CadComponentMLData[i].AvmID = comp.AvmID; if (comp.Connectors.Count > 0) { cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData = new CAD.ConnectorMLDataType[comp.Connectors.Count]; int j = 0; foreach (MetaLinkData.Connector conn in comp.Connectors) { cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j] = new CAD.ConnectorMLDataType(); cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].ID = conn.ID; cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DisplayName = conn.DisplayName; if (conn.Datums.Count > 0) { cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData = new CAD.DatumMLDataType[conn.Datums.Count]; int k = 0; foreach (MetaLinkData.Datum d in conn.Datums) { cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k] = new CAD.DatumMLDataType(); cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k].ID = d.ID; cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k].DisplayName = d.DisplayName; k++; } } j++; } } i++; } } cadassemblycomponentoutput.CADComponent = tmpComponents.ToArray(); //cadassemblycomponentoutput.CADComponent = tmpComponents.Values.ToArray(); cadassemblyoutput.CADComponent = cadassemblycomponentoutput; CAD.PropertiesType asmproperties = new CAD.PropertiesType(); asmproperties._id = UtilityHelpers.MakeUdmID(); CAD.UnitsType asmunit = new CAD.UnitsType(); asmunit._id = UtilityHelpers.MakeUdmID(); asmunit.Value = "value1"; asmproperties.Units = asmunit; cadassemblyoutput.Properties = asmproperties; return(cadassemblyoutput); }
public void AddDataExchangeFormatToXMLOutput(CAD.AssembliesType assembliesRoot) { if (STEP_DataExchangeFormats.Count > 0 || NonSTEP_DataExchangeFormats.Count > 0 || SpecialDataFormatInstructions.Count > 0) { CAD.DataExchangeType dataexchangeout = new CAD.DataExchangeType(); dataexchangeout._id = UtilityHelpers.MakeUdmID(); List <CAD.STEPFormatType> exchangelist = new List <CAD.STEPFormatType>(); foreach (var item in STEP_DataExchangeFormats) { CAD.STEPFormatType formatout = new CAD.STEPFormatType(); formatout._id = UtilityHelpers.MakeUdmID(); formatout.Name = item; exchangelist.Add(formatout); } List <CAD.NonSTEPFormatType> stllist = new List <CAD.NonSTEPFormatType>(); foreach (var item in NonSTEP_DataExchangeFormats) { CAD.NonSTEPFormatType formatout = new CAD.NonSTEPFormatType(); formatout._id = UtilityHelpers.MakeUdmID(); switch (item.ToLower()) { case "inventor": case "parasolid": formatout.FormatType = item; formatout.FormatSubType = ""; break; case "stereolithography_ascii": formatout.FormatType = "Stereolithography"; formatout.FormatSubType = "ASCII"; break; case "stereolithography_binary": formatout.FormatType = "Stereolithography"; formatout.FormatSubType = "BINARY"; break; case "dxf_2013": formatout.FormatType = "DXF"; formatout.FormatSubType = "2013"; break; default: Logger.Instance.AddLogMessage("AddDataExchangeFormatToXMLOutput received an unknown NonSTEP_DataExchangeFormat, recieved value: " + item + " This would be due to a programming error/bug.", Severity.Error); break; } stllist.Add(formatout); } List <CAD.SpecialDataFormatInstructionType> specialInst = new List <CAD.SpecialDataFormatInstructionType>(); foreach (var item in SpecialDataFormatInstructions) { CAD.SpecialDataFormatInstructionType formatout = new CAD.SpecialDataFormatInstructionType(); formatout._id = UtilityHelpers.MakeUdmID(); formatout.Instruction = item; specialInst.Add(formatout); } if (exchangelist.Count > 0) { dataexchangeout.STEPFormat = exchangelist.ToArray(); } if (stllist.Count > 0) { dataexchangeout.NonSTEPFormat = stllist.ToArray(); } if (specialInst.Count > 0) { dataexchangeout.SpecialDataFormatInstruction = specialInst.ToArray(); } assembliesRoot.DataExchange = dataexchangeout; } }