Esempio n. 1
0
        public void ConvertToTCBolt(int ObjectId)
        {
            PsObjectProperties psObjectProperties = new PsObjectProperties();
            PsTransaction      psTransaction      = new PsTransaction();

            psObjectProperties.readFrom(ObjectId);
            if (psObjectProperties.ObjectType == ObjectType.kBolt)
            {
                PsBolt standardBolt = new PsBolt();
                psTransaction.GetObject((long)ObjectId, PsOpenMode.kForWrite, ref standardBolt);
                if ((new ArrayList(new string[] { "A325 SHOP", "A325 FIELD", "A490 SHOP", "A490 FIELD" })).Contains(standardBolt.BoltStyleName))
                {
                    SetStandardBoltParams(standardBolt.Diameter, standardBolt.BoltStyleName, standardBolt.LengthAddition);
                    Length      = standardBolt.Length;
                    Diameter    = standardBolt.Diameter;
                    KlemmLength = standardBolt.KlemmLength;
                    InsertPoint = standardBolt.InsertPoint;
                    XAxis       = standardBolt.XAxis;
                    YAxis       = standardBolt.YAxis;
                    PsPoint  psEndPoint = new PsPoint();
                    PsVector tempVector = new PsVector();
                    tempVector.SetFromCrossProduct(XAxis, YAxis);
                    tempVector.Normalize();
                    ZAxis      = tempVector.Clone();
                    psEndPoint = InsertPoint.Clone();
                    psEndPoint.AddScaled(ZAxis, KlemmLength);
                    CreateByTwoPoints(InsertPoint, psEndPoint);
                    psTransaction.Close();
                    psTransaction.EraseLongId((long)ObjectId);
                }
                psTransaction.Close();
            }
        }
Esempio n. 2
0
        public int CreateAnchorCode111(PsPoint Point1, PsPoint Point2)
        {
            PsCreatePrimitive psCylinder   = new PsCreatePrimitive();
            PsCreatePrimitive psWasher     = new PsCreatePrimitive();
            PsCreatePrimitive psNut        = new PsCreatePrimitive();
            PsPolygon         psNutPolygon = new PsPolygon();

            PsVector psVector1 = new PsVector();
            PsVector psVector2 = new PsVector();
            PsVector psVector3 = new PsVector();
            PsVector psVector  = new PsVector();

            psVector1.SetFromPoints(Point1, Point2);
            psVector2 = psVector.GetPerpendicularVector(psVector1);
            psVector3.SetFromCrossProduct(psVector1, psVector2);

            InsertPoint = Point1;

            psVector1.Normalize();
            psVector2.Normalize();
            psVector3.Normalize();

            ZAxis = psVector1;
            XAxis = psVector2;
            YAxis = psVector3;

            PsVector XAxisNegative = new PsVector();

            XAxisNegative = XAxis.Clone();
            XAxisNegative.Invert();

            //Cylinder
            PsPoint CylinderInsertPoint = new PsPoint();

            CylinderInsertPoint = InsertPoint.Clone();
            CylinderInsertPoint.AddScaled(ZAxis, -1 * (Length - Embedment - PartThickness));

            psCylinder.SetXYPlane(XAxis, YAxis);
            psCylinder.SetInsertPoint(CylinderInsertPoint);
            psCylinder.CreateCylinder(Diameter / 2, Length);
            // Washer
            psWasher.SetXYPlane(XAxisNegative, YAxis);
            psWasher.SetInsertPoint(InsertPoint);
            psWasher.CreateCylinder(WasherOuterDiameter / 2, WasherThickness);

            // Nut
            PsPoint nutInsertPoint = new PsPoint();

            nutInsertPoint = InsertPoint.Clone();
            nutInsertPoint.AddScaled(ZAxis, -1 * WasherThickness);
            psNutPolygon.createPolygon(6, NutKeySize / 2, false);
            psNut.SetXYPlane(XAxisNegative, YAxis);
            psNut.SetPolygon(psNutPolygon);
            psNut.SetInsertPoint(nutInsertPoint);
            psNut.CreateExtrusion(NutHeight, 0D, 0D);

            // Unite all
            int cylinderId = psCylinder.ObjectId;
            int washerId   = psWasher.ObjectId;
            int nutId      = psNut.ObjectId;

            int[] ids = { washerId, nutId };

            PsCutObjects psUniteObjects = new PsCutObjects();

            psUniteObjects.SetObjectId(cylinderId);
            PsTransaction psTransaction = new PsTransaction();

            foreach (int i in ids)
            {
                psUniteObjects.SetAsBooleanCut(i);
                psUniteObjects.SetSubBodyType(SubBodyType.kAddBody);
                psUniteObjects.CreateLogicalLink = false;
                psUniteObjects.Apply();
                psTransaction.EraseLongId((long)i);
                psTransaction.Close();
            }

            PsUnits            psUnits            = new PsUnits();
            PsObjectProperties psObjectProperties = new PsObjectProperties();

            psObjectProperties.Name         = Type + " " + psUnits.ConvertToText(Diameter) + "x" + psUnits.ConvertToText(Length);
            psObjectProperties.ColorIndex   = Color;
            psObjectProperties.PartListFlag = PartListFlag;
            psObjectProperties.FamilyClass  = PartFamilyClassIndex;
            psObjectProperties.Length       = Length;
            psObjectProperties.writeTo(cylinderId);
            PsPrimitive psPrimitive = new PsPrimitive();

            psTransaction.GetObject((long)cylinderId, PsOpenMode.kForWrite, ref psPrimitive);
            psPrimitive.writeProps(psObjectProperties);
            psTransaction.Close();
            ObjectId = cylinderId;
            return(ObjectId);
        }
Esempio n. 3
0
        public void CreateByTwoPoints(PsPoint StartPoint, PsPoint EndPoint)
        {
            PsCreatePrimitive psCylinder   = new PsCreatePrimitive();
            PsCreatePrimitive psHead1      = new PsCreatePrimitive();
            PsCreatePrimitive psHead2      = new PsCreatePrimitive();
            PsCreatePrimitive psWasher     = new PsCreatePrimitive();
            PsCreatePrimitive psNut        = new PsCreatePrimitive();
            PsPolygon         psNutPolygon = new PsPolygon();

            PsVector psVector1 = new PsVector();
            PsVector psVector2 = new PsVector();
            PsVector psVector3 = new PsVector();
            PsVector psVector  = new PsVector();

            psVector1.SetFromPoints(StartPoint, EndPoint);
            psVector2 = psVector.GetPerpendicularVector(psVector1);
            psVector3.SetFromCrossProduct(psVector1, psVector2);

            InsertPoint = StartPoint;
            KlemmLength = psVector1.Length;

            psVector1.Normalize();
            psVector2.Normalize();
            psVector3.Normalize();

            ZAxis = psVector1;
            XAxis = psVector2;
            YAxis = psVector3;

            psCylinder.SetXYPlane(XAxis, YAxis);
            psCylinder.SetInsertPoint(InsertPoint);
            Length = Math.Round((KlemmLength + WasherThickness + NutHeight + LengthAdd + 0.375D) * 4, MidpointRounding.ToEven) / 4;
            psCylinder.CreateCylinder(Diameter / 2, Length);

            // Head
            PsVector XAxisNegative = new PsVector();

            XAxisNegative = XAxis.Clone();
            XAxisNegative.Invert();

            psHead1.SetXYPlane(XAxisNegative, YAxis);
            psHead1.SetInsertPoint(InsertPoint);
            psHead1.CreateCylinder(HeadDiameter / 2, HeadHeight / 4);

            PsPoint head2InsertPoint = new PsPoint();

            head2InsertPoint = InsertPoint.Clone();
            head2InsertPoint.AddScaled(ZAxis, -1 * HeadHeight / 4);

            psHead2.SetXYPlane(XAxisNegative, YAxis);
            psHead2.SetInsertPoint(head2InsertPoint);
            psHead2.CreateCone(HeadDiameter / 2, HeadDiameter / 6, 0.75 * HeadHeight);

            // Washer
            psWasher.SetXYPlane(XAxis, YAxis);
            psWasher.SetInsertPoint(EndPoint);
            psWasher.CreateCylinder(WasherOuterDiameter / 2, WasherThickness);

            // Nut
            PsPoint nutInsertPoint = new PsPoint();

            nutInsertPoint = EndPoint.Clone();
            nutInsertPoint.AddScaled(ZAxis, WasherThickness);
            psNutPolygon.createPolygon(6, NutKeySize / 2, false);
            psNut.SetXYPlane(XAxis, YAxis);
            psNut.SetPolygon(psNutPolygon);
            psNut.SetInsertPoint(nutInsertPoint);
            psNut.CreateExtrusion(NutHeight, 0D, 0D);

            // Unite all
            int cylinderId = psCylinder.ObjectId;
            int head1Id    = psHead1.ObjectId;
            int head2Id    = psHead2.ObjectId;
            int washerId   = psWasher.ObjectId;
            int nutId      = psNut.ObjectId;

            int[] ids = { head1Id, head2Id, washerId, nutId };

            PsCutObjects psUniteObjects = new PsCutObjects();

            psUniteObjects.SetObjectId(cylinderId);
            PsTransaction psTransaction = new PsTransaction();

            foreach (int i in ids)
            {
                psUniteObjects.SetAsBooleanCut(i);
                psUniteObjects.SetSubBodyType(SubBodyType.kAddBody);
                psUniteObjects.CreateLogicalLink = false;
                psUniteObjects.Apply();
                psTransaction.EraseLongId((long)i);
                psTransaction.Close();
            }

            PsUnits            psUnits            = new PsUnits();
            PsMaterialTable    psMaterialTable    = new PsMaterialTable();
            PsObjectProperties psObjectProperties = new PsObjectProperties();

            psObjectProperties.Name = Type + " " + psUnits.ConvertToText(Diameter) + "x" + psUnits.ConvertToText(Length) +
                                      " " + MaterialName;
            psObjectProperties.Material   = psMaterialTable.get_MaterialIndexFromName(MaterialName);
            psObjectProperties.ColorIndex = Color;
            PartListFlag = true;
            psObjectProperties.PartListFlag = PartListFlag;
            PartFamilyClassIndex            = -1;
            psObjectProperties.FamilyClass  = PartFamilyClassIndex;
            psObjectProperties.Length       = Length;
            psObjectProperties.writeTo(cylinderId);

            PsPrimitive psPrimitive = new PsPrimitive();

            psTransaction.GetObject((long)cylinderId, PsOpenMode.kForWrite, ref psPrimitive);
            psPrimitive.writeProps(psObjectProperties);
            psTransaction.Close();
        }