Example #1
0
        public CarGen(string oplstr)
        {
            OPLStr = oplstr;
            string[] parts = oplstr.Split(',');

            PosX          = float.Parse(parts[0].Trim(), CultureInfo.InvariantCulture);
            PosY          = float.Parse(parts[1].Trim(), CultureInfo.InvariantCulture);
            PosZ          = float.Parse(parts[2].Trim(), CultureInfo.InvariantCulture);
            RotX          = float.Parse(parts[3].Trim(), CultureInfo.InvariantCulture);
            RotY          = float.Parse(parts[4].Trim(), CultureInfo.InvariantCulture);
            Length        = float.Parse(parts[5].Trim(), CultureInfo.InvariantCulture);
            ModelName     = parts[6].Trim().ToLowerInvariant();
            CarColor1     = int.Parse(parts[7].Trim(), CultureInfo.InvariantCulture);
            CarColor2     = int.Parse(parts[8].Trim(), CultureInfo.InvariantCulture);
            CarColor3     = int.Parse(parts[9].Trim(), CultureInfo.InvariantCulture);
            SpecularColor = int.Parse(parts[10].Trim(), CultureInfo.InvariantCulture);
            Flags         = uint.Parse(parts[11].Trim(), CultureInfo.InvariantCulture);
            Alarm         = int.Parse(parts[12].Trim(), CultureInfo.InvariantCulture);
            Unk2          = int.Parse(parts[13].Trim(), CultureInfo.InvariantCulture);

            //if (model.StartsWith("hash:"))
            //{
            //    ModelName = model.Substring(5);
            //    if (ModelName == "0") ModelName = string.Empty;
            //}
            //else
            //{
            //    ModelName = model;
            //}
            if (ModelName.StartsWith("hash:"))
            {
                string[] hparts = ModelName.Split(':');
                uint     hash;
                if (uint.TryParse(hparts[1].Trim(), out hash))
                {
                    string str = JenkIndex.TryGetString(hash);
                    if (!string.IsNullOrEmpty(str))
                    {
                        ModelName = str.ToLowerInvariant();
                    }
                    else
                    {
                        ModelName = "hash_" + hash.ToString("X").ToLowerInvariant();
                    }
                }
            }
        }
Example #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);

                    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;
                    }
                }
            }
        }