public static KLgraph.KLshapePart KL_GetShapePart(Component2 comp, SldWorks swApplication) { var body = (Body2)comp.GetBody(); var model = (ModelDoc2)comp.GetModelDoc2(); var path = model.GetPathName(); DirectoryInfo parentDir = Directory.GetParent(path.EndsWith("\\") ? path : String.Concat(path, "\\")); var pathParentDir = parentDir.Parent.FullName; //var pathComponent = Path.GetFileName(comp.GetPathName()); var componentName = comp.Name2; componentName = (componentName.Split('/').Last()); componentName = componentName.Replace("_", string.Empty); componentName = componentName.Substring(0, componentName.LastIndexOf('-')); componentName = componentName.Replace(" ", string.Empty); //componentName = FolderUtilities.FolderUtilities.RemoveDiacritics(componentName); //var componentName = ((pathComponent.Split(new[] { " - " }, StringSplitOptions.None).Last()).Replace(" ", string.Empty)).Replace("/", string.Empty); /* * // Per essere coerente con le varie cazzate di Matteo, quando cerco le armoniche sferiche di una parte, non posso cercare il file con il suo nome, * // devo prendere come nome dall'ultimo spazio in poi, * // perché fare il trim degli spazi era troppo complicato per un "genio" come lui! * * var componentName = comp.Name; * componentName = componentName.Split(Convert.ToChar(" ")).Last(); * componentName = componentName.Split(Convert.ToChar("/")).Last(); * componentName = (componentName.Split(Convert.ToChar("."))).First(); * //componentName = FolderUtilities.FolderUtilities.RemoveDiacritics(componentName); */ var prop = model.Extension.CreateMassProperty(); prop.AddBodies(body); var part = (PartDoc)model; var volume = prop.Volume; var surface = prop.SurfaceArea; var listFirstModel = ReadSHdescriptor(swApplication, pathParentDir, componentName); var shapePart = new KLgraph.KLshapePart(volume, surface, listFirstModel); return(shapePart); }