Example #1
0
        //public static BCOM.Level getLevel(string name)
        //{
        //    BCOM.Levels levels = App.ActiveDesignFile.Levels;

        //    var activeModel =  App.ActiveModelReference;
        //    activeModel.Levels.IncludeHidden = true;

        //    try
        //    {
        //        return activeModel.Levels[name];
        //    }
        //    catch (Exception) {} // не найден


        //    BCOM.Level activeLevel = App.ActiveSettings.Level;

        //    try
        //    {
        //        Addin.Instance.sendKeyin(
        //            string.Format("level set active {0}", name));

        //        activeModel.Levels.IncludeHidden = true;
        //        return activeModel.Levels[name];
        //    }
        //    catch (Exception)
        //    {
        //        return null;
        //    }
        //    finally
        //    {
        //        App.ActiveSettings.Level = activeLevel;
        //    }
        //}

        //public static BCOM.Level getLevelOrActive(string name)
        //{
        //    return getLevel(name) ?? App.ActiveSettings.Level;
        //}


        /// <summary>
        /// Поиск пересечений с элементами по диапазону заданного элемента в
        /// в пространстве заданной модели
        /// </summary>
        public static IEnumerable <BCOM.Element> scanIntersectsInElementRange(
            this BCOM.Element element, BCOM.ModelReference model = null)
        {
            model = model ?? App.ActiveModelReference;

            BCOM.ElementScanCriteria criteria = new BCOM.ElementScanCriteriaClass();
            criteria.ExcludeAllTypes();
            criteria.ExcludeNonGraphical();
            criteria.IncludeType(BCOM.MsdElementType.CellHeader);

            BCOM.Range3d scanRange = getElementScanRange(element, model);

            criteria.IncludeOnlyWithinRange(scanRange);
            return(model.Scan(criteria).BuildArrayFromContents());
        }
Example #2
0
        private void scanInfoPerModel(BCOM.ModelReference model)
        {
            BCOM.CellElement cell = getTaskCell();
            if (cell == null)
            {
                return;
            }

            //BCOM.ModelReference activeModel = App.ActiveModelReference;

            BCOM.ElementScanCriteria criteria = new BCOM.ElementScanCriteriaClass();
            criteria.ExcludeAllTypes();
            criteria.ExcludeNonGraphical();
            criteria.IncludeType(BCOM.MsdElementType.CellHeader);

            BCOM.Range3d scanRange = cell.Range;

#if CONNECT
            // корректировака для версии CONNECT
            if (cell.ModelReference.IsAttachmentOf(model)) // TODO ПРОВЕРИТЬ
            {
                // здесь есть различия с V8i:
                double k = model.UORsPerStorageUnit / cell.ModelReference.UORsPerStorageUnit;
                scanRange.High = App.Point3dScale(scanRange.High, k);
                scanRange.Low  = App.Point3dScale(scanRange.Low, k);
            }
#endif

            criteria.IncludeOnlyWithinRange(scanRange);

            BCOM.ElementEnumerator res = model.Scan(criteria);

            foreach (BCOM.Element current in res?.BuildArrayFromContents())
            {
                TFCOM.TFElementList tfList = AppTF.CreateTFElement();
                tfList.InitFromElement(current);

                if (tfList.AsTFElement == null)
                {
                    continue;
                }

                int tfType = tfList.AsTFElement.GetApplicationType();

                if (tfList.AsTFElement.GetIsCompoundCellType())
                {
                    CompoundsIntersected.Add(tfList);
                }
                else if (tfList.AsTFElement.GetIsFormType())
                {
                    bool coorrectType = isAvaliableTFFromType(tfType);

                    if (isAvaliableTFFromType(tfType))
                    {
                        TFFormsIntersected.Add(tfList);
                    }
                }
            }

            projectLocationPointOnTFForm(TFFormsIntersected);
        }
Example #3
0
        private void findFlanges()
        {
            BCOM.CellElement cell = getTaskCell();
            if (cell == null)
            {
                return;
            }

            BCOM.ModelReference taskModel = // TODO
                                            App.MdlGetModelReferenceFromModelRefP(modelRefP);
            BCOM.ModelReference activeModel = App.ActiveModelReference;

            FlangesGeom.Clear();

            // Поиск фланцев
            BCOM.ElementScanCriteria criteria = new BCOM.ElementScanCriteriaClass();
            //criteria.IncludeOnlyVisible();
            criteria.ExcludeAllTypes();
            criteria.ExcludeNonGraphical();
            criteria.IncludeType(BCOM.MsdElementType.CellHeader);

            BCOM.Range3d scanRange = cell.Range;
            // App.Range3dScaleAboutCenter(cell.Range, 1.01);

            if (taskModel.IsAttachment)
            {
                double k = taskModel.UORsPerStorageUnit / activeModel.UORsPerStorageUnit;
                scanRange.High = App.Point3dScale(scanRange.High, k);
                scanRange.Low  = App.Point3dScale(scanRange.Low, k);
            }

            criteria.IncludeOnlyWithinRange(scanRange);

            BCOM.ElementEnumerator res = taskModel.Scan(criteria);

            foreach (BCOM.Element current in res?.BuildArrayFromContents())
            {
                // todo использовать только один тип точек
                PenetrTaskFlange flangeTask = null;
                //Element curEl = Element.FromElementID((ulong)current.ID,
                //    (IntPtr)current.ModelReference.MdlModelRefP());

                if (PenetrTaskFlange.getFromElement(current, out flangeTask))
                {
                    BCOM.Range3d range = current.Range;

                    if (flangeTask.Oid.Equals(Oid))
                    {
                        FlangesGeom.Add(flangeTask);
                    }
                }
            }

            //BCOM.Transform3d tran = App.Transform3dInverse(
            //    App.Transform3dFromMatrix3d(Rotation));
            //cell.Transform(tran);

            // TODO проверить корректность transform отн. rawLocation_
            transformToBase(cell, rawLocation_);

            if (FlangesCount != FlangesGeom.Count)
            {
                Warnings.Add(string.Format("Несоответствие количества фланцев, " +
                                           "указанных в атрибутах - {0} и заданных геометрически - {1}",
                                           FlangesCount, FlangesGeom.Count));
            }

            if (FlangesCount == 1 && FlangesGeom.Count > 0)
            {
                BCOM.Element flangeEl = taskModel.GetElementByID(FlangesGeom[0].elemId);

                //flangeEl.Transform(tran);

                // TODO проверить корректность transform отн. rawLocation_
                transformToBase(flangeEl, rawLocation_);

                SingleFlangeSide = App.Vector3dSubtractPoint3dPoint3d(
                    ElementHelper.getCenter(flangeEl),
                    ElementHelper.getCenter(cell));
            }
            else
            {
                SingleFlangeSide = App.Vector3dFromXYZ(0, 0, -1);
            }
        }