public string GetVaribleValByName(IPart7 part_, string PropertyName) { string res = ""; try { IKompasDocument3D _IKompasDocument3D = (IKompasDocument3D)GetIKompasDocument(part_.FileName, false, false); part_ = _IKompasDocument3D.TopPart; if (part_ != null) { IFeature7 IF = (IFeature7)part_; Object[] ars = null; if (IF != null && IF.VariablesCount[false, true] > 0) { ars = IF.Variables[false, true]; } if (ars != null) { foreach (var v in ars) { string Expression = (v as IVariable7).Expression; if ((v as IVariable7).Name == PropertyName) { res = (v as IVariable7).Value.ToString(); break; } } } } } catch { ShowMsgBox($"Ошибка при обработке компонента {part_.FileName}\nНе удалось найти Переменную {PropertyName} в списке переменных!", MessageBoxIcon.Error); } return(res); }
public static double GetThickBeVarible(IPart7 part_, bool inSource = true) { double res = 0; if (part_ != null) { IFeature7 IF = (IFeature7)part_; Object[] ars = null; if (IF != null && IF.VariablesCount[false, inSource] > 0) { ars = IF.Variables[false, inSource]; } if (ars != null) { foreach (var v in ars) { string Expression = (v as IVariable7).Expression; if ((v as IVariable7).Name == "SM_Thickness") { res = Convert.ToDouble((v as IVariable7).Value); break; } } } } return(res); }
private void getBodyResoure(IPart7 Part, ComponentInfo componentInfo, TreeListNode node) { IFeature7 feature = (IFeature7)Part; var RB = feature.ResultBodies; if (RB == null) { return; } try { foreach (IBody7 _body in RB) { try { ComponentInfo componentInfo_Copy = Add_BodyInfo_In_Component(Part, _body, componentInfo); TreeListNode TempNode; TempNode = AddNode(node, componentInfo_Copy, true); TempNode.Tag = componentInfo_Copy; } catch { } } } catch { IBody7 _body = (IBody7)RB; ComponentInfo componentInfo_Copy = Add_BodyInfo_In_Component(Part, _body, componentInfo); TreeListNode TempNode; TempNode = AddNode(node, componentInfo_Copy, true); TempNode.Tag = componentInfo_Copy; } }
public static bool isVaribale(IPart7 part_, bool inSource = true) { bool res = false; if (part_ != null) { IFeature7 IF = (IFeature7)part_; Object[] ars = null; if (IF != null && IF.VariablesCount[false, inSource] > 0) { try { ars = IF.Variables[false, inSource]; } catch (Exception exc) { } } if (ars != null) { foreach (var v in ars) { string Expression = (v as IVariable7).Expression; if ((v as IVariable7).Name == "SM_Thickness") { res = true; break; } } } } return(res); }