Esempio n. 1
0
        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");
            }
        }
Esempio n. 2
0
 public virtual IXMassProperty PreCreateMassProperty()
 {
     if (OwnerApplication.IsVersionNewerOrEqual(Enums.SwVersion_e.Sw2020))
     {
         return(new SwMassProperty(this, m_MathUtils));
     }
     else
     {
         return(new SwLegacyMassProperty(this, m_MathUtils));
     }
 }
Esempio n. 3
0
        public ISwEntity CreateResilient()
        {
            var safeEnt = Entity.GetSafeEntity();

            if (safeEnt == null)
            {
                throw new NullReferenceException("Failed to get safe entity");
            }

            return(OwnerApplication.CreateObjectFromDispatch <SwEntity>(safeEnt, OwnerDocument));
        }
Esempio n. 4
0
 IXAssemblyMassProperty IXAssembly.PreCreateMassProperty()
 {
     if (OwnerApplication.IsVersionNewerOrEqual(Enums.SwVersion_e.Sw2020))
     {
         return new SwAssemblyMassProperty(this, m_MathUtils);
     }
     else
     {
         return new SwAssemblyLegacyMassProperty(this, m_MathUtils);
     }
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
 public OwnerController(OwnerApplication ownerApplication) : base(ownerApplication)
 {
     this._ownerApplication = ownerApplication;
 }