Ejemplo n.º 1
0
        private void CreateStructuralInterfaceEquivalent(CyPhy.Component cyphycomp)
        {
            CyPhy.CADModel cadmodel = cyphycomp.Children.CADModelCollection.FirstOrDefault(x => x.Attributes.FileFormat.ToString() == "Creo");
            if (cadmodel != null)
            {
                string uri;
                cadmodel.TryGetResourcePath(out uri);
                char[] start = new char[] { '/', '\\' };
                if (!String.IsNullOrEmpty(uri))
                {
                    uri = uri.TrimStart(start);

                    string absPath;
                    cadmodel.TryGetResourcePath(out absPath, ComponentLibraryManager.PathConvention.ABSOLUTE);
                    var hyperlink = cyphycomp.ToHyperLink(Traceability);
                    missingFile = Task.Run(() => CheckFileExists(hyperlink, uri, absPath));

                    // META-1382
                    //ModelName = UtilityHelpers.CleanString2(Path.GetFileNameWithoutExtension(uri));
                    ModelName = Path.GetFileName(uri);
                    List <string> tokens_2 = ModelName.Split('.').ToList <string>();
                    int           index    = tokens_2.FindIndex(x => x.ToUpper() == "PRT");
                    if (index != -1)
                    {
                        ModelType = "Part";
                        ModelName = string.Join("", tokens_2.GetRange(0, index).ToArray());
                    }
                    else
                    {
                        index = tokens_2.FindIndex(x => x.ToUpper() == "ASM");
                        if (index != -1)
                        {
                            ModelType = "Assembly";
                            ModelName = string.Join("", tokens_2.GetRange(0, index).ToArray());
                        }
                    }
                    // It shouldn't be an empty string
                    if (ModelType.Length == 0)
                    {
                        ModelType = "Part";
                    }
                }
                else
                {
                    Logger.Instance.AddLogMessage("CADModel Resource Path information unavailable for component [" + cyphycomp.Path + "," + DisplayID + "]!", Severity.Warning);
                }

                ModelURI = uri.Length > 0 ? Path.GetDirectoryName(uri) : "";
                //ModelType = cadmodel.Attributes.FileType.ToString();

                foreach (var param in cadmodel.Children.CADParameterCollection)
                {
                    CADParameter acadparam = new CADParameter(param);
                    CadParameters.Add(acadparam);
                }

                // META-947: Connector replaced StructuralInterface
                //           Not dealing with nested Connectors right now.
                // foreach (var item in cyphycomp.Children.StructuralInterfaceCollection)
                foreach (CyPhy.Connector item in cyphycomp.Children.ConnectorCollection)
                {
                    FindMatchingSolidModelingFeatures(item, cadmodel);
                }

                foreach (CyPhy.CADDatum item in cyphycomp.Children.CADDatumCollection)
                {
                    // only Coordinate System is supported
                    if (item is CyPhy.CoordinateSystem)
                    {
                        FindMatchingSolidModelingFeatures(item, cadmodel);
                    }
                    //else
                    //    Logger.Instance.AddLogMessage("Only CoordinateSystem datums outside of a Connector are supported, other datum types not supported.", Severity.Warning);
                }

                // Materials
                if (cyphycomp.Children.MaterialRefCollection.Any())
                {
                    CyPhy.MaterialRef matRef   = cyphycomp.Children.MaterialRefCollection.First();
                    CyPhy.Material    material = matRef.Referred.Material;
                    if (material != null)
                    {
                        this.MaterialName = material.Attributes.Name;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void CreateStructuralInterfaceEquivalent(CyPhy.Component cyphycomp)
        {
            CyPhy.CADModel cadmodel = cyphycomp.Children.CADModelCollection.FirstOrDefault(x => x.Attributes.FileFormat.ToString() == "Creo");
            if (cadmodel != null)
            {
                string uri;
                cadmodel.TryGetResourcePath(out uri);
                char[] start = new char[] { '/', '\\' };
                if (!String.IsNullOrEmpty(uri))
                {
                    uri = uri.TrimStart(start);

                    // META-1382
                    //ModelName = UtilityHelpers.CleanString2(Path.GetFileNameWithoutExtension(uri));
                    ModelName = Path.GetFileName(uri);
                    List<string> tokens_2 = ModelName.Split('.').ToList<string>();
                    int index = tokens_2.FindIndex(x => x.ToUpper() == "PRT");
                    if (index != -1)
                    {
                        ModelType = "Part";
                        ModelName = string.Join("", tokens_2.GetRange(0, index).ToArray());
                    }
                    else
                    {
                        index = tokens_2.FindIndex(x => x.ToUpper() == "ASM");
                        if (index != -1)
                        {
                            ModelType = "Assembly";
                            ModelName = string.Join("", tokens_2.GetRange(0, index).ToArray());
                        }
                    }
                    // It shouldn't be an empty string
                    if (ModelType.Length == 0) ModelType = "Part";
                }
                else
                {
                    Logger.Instance.AddLogMessage("CADModel Resource Path information unavailable for component [" + cyphycomp.Path + "," + DisplayID + "]!", Severity.Warning);
                }

                // META-1917: probably needs to be removed later b/c CAD Model Type attribute will be removed from metamodel
                if (String.IsNullOrEmpty(ModelType))
                {
                    Logger.Instance.AddLogMessage("Creo file extension can not be deduced from CADModel Resource Path for component [" + Name + "," + DisplayID + "], using CAD Model Type attribute instead!", Severity.Warning);
                    ModelType = cadmodel.Attributes.FileType.ToString();
                }
                // end META-1917

                ModelURI = uri.Length > 0 ? Path.GetDirectoryName(uri) : "";
                //ModelType = cadmodel.Attributes.FileType.ToString();

                foreach (var param in cadmodel.Children.CADParameterCollection)
                {
                    CADParameter acadparam = new CADParameter(param);
                    CadParameters.Add(acadparam);
                }

                // META-947: Connector replaced StructuralInterface 
                //           Not dealing with nested Connectors right now.
                // foreach (var item in cyphycomp.Children.StructuralInterfaceCollection)
                foreach (CyPhy.Connector item in cyphycomp.Children.ConnectorCollection)
                {
                    FindMatchingSolidModelingFeatures(item, cadmodel);
                }

                foreach (CyPhy.CADDatum item in cyphycomp.Children.CADDatumCollection)
                {
                    // only Coordinate System is supported
                    if (item is CyPhy.CoordinateSystem)
                        FindMatchingSolidModelingFeatures(item, cadmodel);
                    //else
                    //    Logger.Instance.AddLogMessage("Only CoordinateSystem datums outside of a Connector are supported, other datum types not supported.", Severity.Warning);
                }

                // Materials
                if (cyphycomp.Children.MaterialRefCollection.Any())
                {
                    CyPhy.MaterialRef matRef = cyphycomp.Children.MaterialRefCollection.First();
                    CyPhy.Material material = matRef.Referred.Material;
                    if (material != null)
                    {
                        this.MaterialName = material.Attributes.Name;
                    }
                }
            }
        }