public PhotoShopOperation(FileInfo fileInfo) { _fileInfo = fileInfo; //初始化对象 Application = new Photoshop.Application(); //设置为毫米 _oldPsUnits = Application.Preferences.RulerUnits; //重置颜色 ResetColor(); }
private void InvertExpandContractFeatherSelection() { Selection MySelection = appRef.ActiveDocument.Selection; PsUnits startRulerUnits = appRef.Preferences.RulerUnits; appRef.Preferences.RulerUnits = PsUnits.psPixels; MySelection.Invert(); MySelection.Expand(5); // 5 pixels MySelection.Feather(5); // 5 pixels appRef.Preferences.RulerUnits = startRulerUnits; }
private void SaveJpegDocument(string jpgFilename) // Page 32 { PsUnits originalRulerUnits = appRef.Preferences.RulerUnits; appRef.Preferences.RulerUnits = PsUnits.psPixels; JPEGSaveOptions myJPEGOptions = new JPEGSaveOptions(); myJPEGOptions.EmbedColorProfile = true; myJPEGOptions.FormatOptions = PsFormatOptionsType.psStandardBaseline; myJPEGOptions.Matte = PsMatteType.psNoMatte; myJPEGOptions.Quality = 1; appRef.ActiveDocument.SaveAs(jpgFilename, myJPEGOptions, true, PsExtensionType.psLowercase); }
private void cmdInsertStiffenerOne(object sender, System.EventArgs e) { PsUnits psUnits = new PsUnits(); string stiffenerLabel = this.stiffenerNameTextBox.Text; string stiffenerMaterial = this.stiffenerMaterialComboBox.Text; double stiffenerThickness = psUnits.ConvertToNumeric(this.stiffenerThicknessComboBox.Text); int positionIndex = this.stiffenerPositionComboBox.SelectedIndex; SaveInToTemplate(); GSFStiffenerControl.CloseForm(); InsertOne(stiffenerLabel, stiffenerMaterial, stiffenerThickness, positionIndex); GSFStiffenerControl.ShowForm(m_addIn); }
private void HelloWorld() // page 19 { // Modified from Page 19 of Script PsUnits originalRulerUnits = appRef.Preferences.RulerUnits; appRef.Preferences.RulerUnits = PsUnits.psInches; Document docRef = appRef.Documents.Add(2, 4); ArtLayer artLayerRef = docRef.ArtLayers.Add(); artLayerRef.Kind = PsLayerKind.psTextLayer; //Normal Layer TextItem textItemRef = artLayerRef.TextItem; textItemRef.Contents = "Hello World"; appRef.Preferences.RulerUnits = originalRulerUnits; }
private void PhotoResizeExample(string sFile) // Document Object Example page 35 { PsUnits startRulerUnits = appRef.Preferences.RulerUnits; appRef.Preferences.RulerUnits = PsUnits.psInches; Document docRef = appRef.Open(sFile); docRef.ResizeImage(4, 4); docRef.ResizeCanvas(4, 4); docRef.Trim(PsTrimType.psTopLeftPixel, true, false, true, false); appRef.Preferences.RulerUnits = PsUnits.psPixels; int[] MyArray = { 100, 200, 400, 500 }; docRef.Crop(MyArray, 45, 20, 20); docRef.FlipCanvas(PsDirection.psHorizontal); // Restore units appRef.Preferences.RulerUnits = startRulerUnits; }
private void SavePDFDocument(string pdfFilename) // Page 30 { PsUnits originalRulerUnits = appRef.Preferences.RulerUnits; appRef.Preferences.RulerUnits = PsUnits.psPixels; // Create a PDF option object PDFOpenOptions pdfOpenOptionsRef = new PDFOpenOptions(); pdfOpenOptionsRef.AntiAlias = true; pdfOpenOptionsRef.Mode = PsOpenDocumentMode.psOpenRGB; pdfOpenOptionsRef.Resolution = 72; pdfOpenOptionsRef.Page = 3; Document docref = appRef.Open(pdfFilename, pdfOpenOptionsRef); //Restore Units appRef.Preferences.RulerUnits = originalRulerUnits; }
public static string[] PopulateComboBoxWithLengths(string Table, double Criteria) { List <double> list = new List <double>(); String connect = "Provider=Microsoft.ACE.OLEDB.12.0;data source=H:\\GSF\\WorkSpace\\ProStructures\\Data\\Bolts\\GSF_Bolts.mdb"; OleDbConnection connection = new OleDbConnection(connect); connection.Open(); OleDbDataReader reader = null; OleDbCommand command = new OleDbCommand(); command.Connection = connection; command.CommandText = "SELECT Length FROM [" + Table + "] WHERE Diameter = " + Criteria; reader = command.ExecuteReader(); PsUnits psUnits = new PsUnits(); while (reader.Read()) { double d = reader.GetDouble(0); list.Add(Math.Round(d, 3)); } connection.Close(); List <double> newList = new List <double>(); foreach (double s in list) { if (!newList.Contains(s)) { newList.Add(s); } } newList.Sort(); double[] arr = newList.ToArray(); string[] result = new string[arr.Length]; for (int a = 0; a < arr.Length; a++) { result[a] = psUnits.ConvertToText(arr[a]); } return(result); }
public void SetParams(double TcBoltDiameter, string TcBoltType, double BoltAddLength) { PsUnits psUnits = new PsUnits(); Diameter = TcBoltDiameter; LengthAdd = BoltAddLength; if (TcBoltDiameter == 0.5D) { HeadHeight = 0.323D; HeadDiameter = 1.126D; WasherOuterDiameter = 1.063D; WasherThickness = 0.097D; NutKeySize = 0.875D; NutHeight = 0.504D; } else if (TcBoltDiameter == 0.625D) { HeadHeight = 0.403D; HeadDiameter = 1.313D; WasherOuterDiameter = 1.313D; WasherThickness = 0.122D; NutKeySize = 1.062D; NutHeight = 0.631D; } else if (TcBoltDiameter == 0.75D) { HeadHeight = 0.483D; HeadDiameter = 1.580D; WasherOuterDiameter = 1.468D; WasherThickness = 0.122D; NutKeySize = 1.250D; NutHeight = 0.758D; } else if (TcBoltDiameter == 0.875D) { HeadHeight = 0.563D; HeadDiameter = 1.880D; WasherOuterDiameter = 1.750D; WasherThickness = 0.136D; NutKeySize = 1.438D; NutHeight = 0.885D; } else if (TcBoltDiameter == 1D) { HeadHeight = 0.627D; HeadDiameter = 2.158D; WasherOuterDiameter = 2.000D; WasherThickness = 0.136D; NutKeySize = 1.625D; NutHeight = 1.012D; } else { HeadHeight = 0.718D; HeadDiameter = 2.375D; WasherOuterDiameter = 2.250D; WasherThickness = 0.177D; NutKeySize = 1.812D; NutHeight = 1.139D; } if (TcBoltType == "SHOP TC A325") { Type = "SHOP TC Bolt"; MaterialName = "ASTM A325 Gr.81"; Color = 20; } else if (TcBoltType == "FIELD TC A325") { Type = "FIELD TC Bolt"; MaterialName = "ASTM A325 Gr.81"; Color = 7; } else if (TcBoltType == "SHOP TC A490") { Type = "SHOP TC Bolt"; MaterialName = "ASTM A490"; Color = 202; } else { Type = "FIELD TC Bolt"; MaterialName = "ASTM A490"; Color = 94; } }
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); }
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(); }
public void SwitchRuler(PsUnits units) { Application.Preferences.RulerUnits = units; }
private void InsertOne(string StiffenerLabel, string StiffenerMaterial, double StiffenerThickness, int StiffenerPositionIndex) { List <int> objs = new List <int>(); PsUnits psUnits = new PsUnits(); PsShapeInfo psShapeInfo = new PsShapeInfo(); PsGeometryFunctions geometryFunctions = new PsGeometryFunctions(); PsPoint psInsertionPoint = new PsPoint(); PsPoint psStartPoint = new PsPoint(); PsPoint psEndPoint = new PsPoint(); PsPoint psMidLineInsertionPoint = new PsPoint(); PsPolygon psStiffenerPolygon = new PsPolygon(); PsCreatePlate psStiffinerPlateRight = new PsCreatePlate(); PsCreatePlate psStiffinerPlateLeft = new PsCreatePlate(); PsMatrix psMatrixRight = new PsMatrix(); PsMatrix psMatrixLeft = new PsMatrix(); PsSelection arg1 = new PsSelection(); arg1.SetSelectionFilter(SelectionFilter.kFilterShape); int num1 = arg1.PickObject("Please select W shape beam..."); //returns object id if (num1 > 0) { PsSelection arg2 = new PsSelection(); int num2 = arg2.PickPoint("Select insertion point", CoordSystem.kWcs, psInsertionPoint); if (num2 == 1) { psShapeInfo.SetObjectId(num1); int num3 = psShapeInfo.GetInfo(); //gets object property values psStartPoint = psShapeInfo.MidLineStart; psEndPoint = psShapeInfo.MidLineEnd; psMidLineInsertionPoint = geometryFunctions.OrthoProjectPointToLine( psInsertionPoint, psShapeInfo.MidLineStart, psShapeInfo.MidLineEnd); double shapeLength = geometryFunctions.GetDistanceBetween(psStartPoint, psEndPoint); if (geometryFunctions.GetDistanceBetween(psMidLineInsertionPoint, psStartPoint) <= shapeLength && geometryFunctions.GetDistanceBetween(psMidLineInsertionPoint, psEndPoint) <= shapeLength) { psShapeInfo.SetStiffenerType(0, 0.75, 0); psStiffenerPolygon = psShapeInfo.getStiffenerPolygon(psInsertionPoint); psStiffinerPlateRight.SetFromPolygon(psStiffenerPolygon); psStiffinerPlateRight.SetThickness(StiffenerThickness); psMatrixRight = psShapeInfo.MidLineUcs; psMatrixLeft = psMatrixRight.Clone(); psMatrixLeft.MirrorAtLine(psStartPoint, psEndPoint); psStiffinerPlateRight.SetInsertMatrix(psMatrixRight); psStiffinerPlateRight.Create(); objs.Add(psStiffinerPlateRight.ObjectId); CommonFunctions.MoveObject( (long)psStiffinerPlateRight.ObjectId, ref psStartPoint, ref psMidLineInsertionPoint); psStiffinerPlateLeft = psStiffinerPlateRight; psStiffinerPlateLeft.SetInsertMatrix(psMatrixLeft); psStiffinerPlateLeft.Create(); objs.Add(psStiffinerPlateLeft.ObjectId); CommonFunctions.MoveObject( (long)psStiffinerPlateLeft.ObjectId, ref psStartPoint, ref psMidLineInsertionPoint); objIds = objs.ToArray(); //test MessageBox.Show(psShapeInfo.ShapeName); } else { MessageBox.Show("Selected point is out of beam", "Oops...", MessageBoxButtons.OK); } } } }