Пример #1
0
        /// <summary>
        /// Проверка на пересечения с другими закладными элементами.
        /// TRUE - если проверка пройдена
        /// </summary>
        private bool checkForIntersects(PenetrVueTask task, PenetrInfo penInfo)
        {
            task.scanInfo();

            BCOM.Element penElement =
                PenetrHelper.getPenElementWithoutFlanges(task, penInfo);

            IEnumerable <BCOM.Element> intersects =
                ElementHelper.scanIntersectsInElementRange(penElement,
                                                           App.ActiveModelReference);

            foreach (BCOM.Element intersection in intersects)
            {
                if (intersection.IsPenetrationCell())
                {
                    var body = getBodyWithOutFlanges(intersection.AsCellElement());

                    var contrIntersects =
                        ElementHelper.scanIntersectsInElementRange(body,
                                                                   App.ActiveModelReference);

                    BCOM.Range3d res = App.Range3dInit();
                    if (App.Range3dIntersect2(ref res, body.Range, penElement.Range))
                    {
                        return(false);
                    }
                }
                else if (intersection.IsCompundCell())
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #2
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());
        }
Пример #3
0
        public static bool IsPlanarAndIntersectsElement(
            this TFCOM.TFBrepFace face, BCOM.Element element, out TFCOM.TFPlane tfPlane)
        {
            if (face.IsPlanar(out tfPlane))
            {
                //faceList.AsTFBrepFace.GetLabel(out faceLabel);
                BCOM.Point3d[] faceVerts;
                face.GetVertexLocations(out faceVerts);
                var faceShape = App.CreateShapeElement1(null, faceVerts);

                BCOM.Range3d result = new BCOM.Range3d();
                if (App.Range3dIntersect2(ref result, element.Range, faceShape.Range))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
        public static BCOM.Range3d getElementScanRange(
            BCOM.Element element, BCOM.ModelReference model = null)
        {
            BCOM.Range3d scanRange = element.Range;

#if CONNECT
            // корректировака для версии CONNECT
            if (element.ModelReference.IsAttachmentOf(model))
            {
                // здесь есть различия с V8i: // TODO проверить
                double k = model.UORsPerStorageUnit /
                           element.ModelReference.UORsPerStorageUnit;
                scanRange.High = App.Point3dScale(scanRange.High, k);
                scanRange.Low  = App.Point3dScale(scanRange.Low, k);
            }
#endif
            return(scanRange);
        }
Пример #5
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);
        }
Пример #6
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);
            }
        }
Пример #7
0
 public static double getWidth(this BCOM.Range3d range)
 {
     return(range.High.X - range.Low.X);
 }
Пример #8
0
 public static double getHeight(this BCOM.Range3d range)
 {
     return(range.High.Y - range.Low.Y);
 }