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 bool TryGet(string name, out IXDrawingView ent) { var view = GetSwViews().FirstOrDefault( x => string.Equals(x.Name, name, StringComparison.CurrentCultureIgnoreCase)); if (view != null) { ent = m_Draw.CreateObjectFromDispatch <SwDrawingView>(view); } else { ent = null; } return(ent != null); }
public bool TryGet(string name, out IXSheet ent) { var sheet = m_Drawing.Drawing.Sheet[name]; if (sheet != null) { ent = m_Drawing.CreateObjectFromDispatch <SwSheet>(sheet); return(true); } else { ent = null; return(false); } }