/// <summary> /// Creates instance objects based on a string identifying an item's type in PowerSHAPE. /// </summary> /// <param name="powerSHAPE">The base instance to interact with PowerShape.</param> /// <param name="type">The identifier PowerSHAPE uses to identify this type of entity.</param> /// <param name="id">The identifier of the entity.</param> /// <param name="name">The name of the entity.</param> /// <returns>The new entity.</returns> internal static object CreateEntity(PSAutomation powerSHAPE, string type, int id, string name) { PSEntity entity = null; switch (type.ToUpper()) { case PSAnnotation.ANNOTATION_IDENTIFIER: entity = new PSAnnotation(powerSHAPE, id, name); break; case PSArc.ARC_IDENTIFIER: entity = new PSArc(powerSHAPE, id, name); break; case PSCompCurve.COMPCURVE_IDENTIFIER: case "COMPOSITE CURVE": entity = new PSCompCurve(powerSHAPE, id, name); break; case PSCurve.CURVE_IDENTIFIER: entity = new PSCurve(powerSHAPE, id, name); break; case PSElectrode.ELECTRODE_IDENTIFIER: entity = new PSElectrode(powerSHAPE, id, name); break; case PSLine.LINE_IDENTIFIER: entity = new PSLine(powerSHAPE, id, name); break; case PSPoint.POINT_IDENTIFIER: entity = new PSPoint(powerSHAPE, id, name); break; case PSSolid.SOLID_IDENTIFIER: entity = (PSEntity)PSSolidFactory.CreateSolid(powerSHAPE, id, name); break; case PSMesh.MESH_IDENTIFIER: entity = new PSMesh(powerSHAPE, id, name); break; case PSSurface.SURFACE_IDENTIFIER: entity = (PSEntity)PSSurfaceFactory.CreateSurface(powerSHAPE, id, name); break; case PSWorkplane.WORKPLANE_IDENTIFIER: entity = new PSWorkplane(powerSHAPE, id, name); break; } return(entity); }
static void BuildingCylinder() { double radius = length * (38.0 / defaultLength); // Points Point circleCenter = new Point(0.0, distanceToCentralCenter, 0.0); Point startPoint = new Point(radius, distanceToCentralCenter, 0.0); // Circle PSArc circle = psModel.Arcs.CreateArcCircle(circleCenter, startPoint, radius); // Extrusion psModel.Solids.CreateSolidExtrusionFromWireframe(circle, width, 0.0); }
static void CuttingCirclesInBase() { double lengthToCircleCenter = length * (50.0 / defaultLength); double widthToBottomCircleCenter = length * (17.0 / defaultLength); double widthToUpperCircleCenter = length * (63.0 / defaultLength); double radius = length * (7.0 / defaultLength); // Points Point leftBottomCircleCenter = new Point(-lengthToCircleCenter, 0.0, widthToBottomCircleCenter); Point leftUpperCircleCenter = new Point(-lengthToCircleCenter, 0.0, widthToUpperCircleCenter); Point rightBottomCircleCenter = new Point(lengthToCircleCenter, 0.0, widthToBottomCircleCenter); Point rightUpperCircleCenter = new Point(lengthToCircleCenter, 0.0, widthToUpperCircleCenter); Point leftBottomCircleStartingPoint = new Point(-lengthToCircleCenter, 0.0 + radius, widthToBottomCircleCenter); Point leftUpperCircleStartingPoint = new Point(-lengthToCircleCenter, 0.0 + radius, widthToUpperCircleCenter); Point rightBottomCircleStartingPoint = new Point(lengthToCircleCenter, 0.0 + radius, widthToBottomCircleCenter); Point rightUpperCircleStartingPoint = new Point(lengthToCircleCenter, 0.0 + radius, widthToUpperCircleCenter); // Circles PSArc leftBottomCircle = psModel.Arcs.CreateArcCircle(leftBottomCircleCenter, leftBottomCircleStartingPoint, radius); PSArc leftUpperCircle = psModel.Arcs.CreateArcCircle(leftUpperCircleCenter, leftUpperCircleStartingPoint, radius); PSArc rightBottomCircle = psModel.Arcs.CreateArcCircle(rightBottomCircleCenter, rightBottomCircleStartingPoint, radius); PSArc rightUpperCircle = psModel.Arcs.CreateArcCircle(rightUpperCircleCenter, rightUpperCircleStartingPoint, radius); // Rotating circles to the correct plane leftBottomCircle.Rotate(Autodesk.Axes.X, 90.0, 0, leftBottomCircleCenter); leftUpperCircle.Rotate(Autodesk.Axes.X, 90.0, 0, leftUpperCircleCenter); rightBottomCircle.Rotate(Autodesk.Axes.X, 90.0, 0, rightBottomCircleCenter); rightUpperCircle.Rotate(Autodesk.Axes.X, 90.0, 0, rightUpperCircleCenter); // Extruding cylinders which'll be subtracted psModel.Solids.CreateSolidExtrusionFromWireframe(leftBottomCircle, (8.0 / defaultLength) * width + 20.0, 0.0); psModel.Solids.CreateSolidExtrusionFromWireframe(leftUpperCircle, (8.0 / defaultLength) * width + 20.0, 0.0); psModel.Solids.CreateSolidExtrusionFromWireframe(rightBottomCircle, (8.0 / defaultLength) * width + 20.0, 0.0); psModel.Solids.CreateSolidExtrusionFromWireframe(rightUpperCircle, (8.0 / defaultLength) * width + 20.0, 0.0); #pragma warning disable CS0618 // Using raw macro for subtraction powerSHAPE.Execute("add Solid \"3\"", "add Solid \"4\"", "add Solid \"5\"", "add Solid \"6\"", "CREATE FEATURE SUBTRACTION", "select clearlist"); #pragma warning restore CS0618 // Using raw macro for subtraction }
/// <summary> /// Creates instance objects based on a string identifying an item's type in PowerSHAPE. /// </summary> /// <param name="powerSHAPE">The base instance to interact with PowerShape.</param> /// <param name="type">The identifier PowerSHAPE uses to identify this type of entity.</param> /// <param name="id">The identifier of the entity.</param> /// <param name="name">The name of the entity.</param> /// <returns>The new entity.</returns> internal static object CreateEntity( PSAutomation powerSHAPE, int type, int id, string name, string description, string level) { PSEntity entity = null; switch (type) { case 61: entity = new PSAnnotation(powerSHAPE, id, name); break; case 52: entity = new PSArc(powerSHAPE, id, name); break; case 59: entity = new PSCompCurve(powerSHAPE, id, name); break; case 53: entity = new PSCurve(powerSHAPE, id, name); break; case 58: entity = new PSLine(powerSHAPE, id, name); break; case 49: entity = new PSPoint(powerSHAPE, id, name); break; case 40: entity = (PSEntity)PSSolidFactory.CreateSolid(powerSHAPE, id, name, description); break; case 60: switch (description) { case "Mesh": entity = new PSMesh(powerSHAPE, id, name); break; case "Point": entity = new PSPoint(powerSHAPE, id, name); break; case "Electrode": entity = new PSElectrode(powerSHAPE, id, name); break; } break; case 21: entity = (PSEntity)PSSurfaceFactory.CreateSurface(powerSHAPE, id, name, description); break; case 54: entity = new PSWorkplane(powerSHAPE, id, name); break; } if (entity != null) { entity._levelNumber = int.Parse(level); } return(entity); }