private ISwSelObject ConvertObjectBoxed(object obj) { if (obj is ISwSelObject) { if (OwnerApplication.IsVersionNewerOrEqual(Enums.SwVersion_e.Sw2018)) { var disp = (obj as ISwSelObject).Dispatch; var corrDisp = DrawingView.GetCorresponding(disp); if (corrDisp != null) { return(m_Drawing.CreateObjectFromDispatch <ISwSelObject>(corrDisp)); } else { throw new Exception("Failed to convert the pointer of the object"); } } else { throw new NotSupportedException("This API only available in SOLIDWORKS 2018 onwards"); } } else { throw new InvalidCastException("Object is not SOLIDWORKS object"); } }
public virtual IXMassProperty PreCreateMassProperty() { if (OwnerApplication.IsVersionNewerOrEqual(Enums.SwVersion_e.Sw2020)) { return(new SwMassProperty(this, m_MathUtils)); } else { return(new SwLegacyMassProperty(this, m_MathUtils)); } }
IXAssemblyMassProperty IXAssembly.PreCreateMassProperty() { if (OwnerApplication.IsVersionNewerOrEqual(Enums.SwVersion_e.Sw2020)) { return new SwAssemblyMassProperty(this, m_MathUtils); } else { return new SwAssemblyLegacyMassProperty(this, m_MathUtils); } }
private string GetPropertyValue(ICustomPropertyManager prpMgr, string prpName) { string resVal; if (OwnerApplication.IsVersionNewerOrEqual(SwVersion_e.Sw2018)) { prpMgr.Get6(prpName, false, out _, out resVal, out _, out _); } else if (OwnerApplication.IsVersionNewerOrEqual(SwVersion_e.Sw2014)) { prpMgr.Get5(prpName, false, out _, out resVal, out _); } else { prpMgr.Get4(prpName, false, out _, out resVal); } return(resVal); }
private IConfiguration Create(CancellationToken cancellationToken) { IConfiguration conf; if (OwnerApplication.IsVersionNewerOrEqual(SwVersion_e.Sw2018)) { conf = m_Doc.Model.ConfigurationManager.AddConfiguration2(Name, "", "", (int)swConfigurationOptions2_e.swConfigOption_DontActivate, "", "", false); } else { conf = m_Doc.Model.ConfigurationManager.AddConfiguration(Name, "", "", (int)swConfigurationOptions2_e.swConfigOption_DontActivate, "", ""); } if (conf == null) { throw new Exception("Failed to create configuration"); } return(conf); }