cart: empty [ Login ]

Convert to PDF with reading CTB and assign properties

< previous  1 2 
Wout
1/25/2024 9:03 AM
When assigning delegates in vb.net you need to use AddressOf. This is very basic VB.NET knowledge to be honest. - Wout
ABS
1/25/2024 9:21 AM
Hi Woutware, I don't get what you mean. Can you provide use for an example in VB.net? see my coding in VB.net Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click Dim m_CADModel As WW.Cad.Model.DxfModel = New WW.Cad.Model.DxfModel() m_CADModel = DwgReader.Read(TextBox1.Text) Dim boundsCalculator As BoundsCalculator = New BoundsCalculator() boundsCalculator.GetBounds(m_CADModel) Dim bounds As Bounds3D = boundsCalculator.Bounds Dim paperSize As PaperSize = PaperSizes.GetPaperSize(PaperKind.A3Rotated) Dim pageWidth As Single = paperSize.Width / 100.0F Dim pageHeight As Single = paperSize.Height / 100.0F Dim margin As Single = 0F Dim to2DTransform As Matrix4D = DxfUtil.GetScaleTransform(bounds.Corner1, bounds.Corner2, New WW.Math.Point3D(bounds.Center.X, bounds.Corner2.Y, 0.0), New WW.Math.Point3D(New Vector3D(margin, margin, 0.0) * PdfExporter.InchToPixel), New WW.Math.Point3D(New Vector3D(pageWidth - margin, pageHeight - margin, 0.0) * PdfExporter.InchToPixel), New WW.Math.Point3D(New Vector3D(pageWidth / 2.0, pageHeight - margin, 0.0) * PdfExporter.InchToPixel), 1) Dim ms As Stream = File.Create(TextBox2.Text) Dim pdf As PdfExporter = New PdfExporter(ms) Dim GraphicsConf As GraphicsConfig = CType(GraphicsConfig.WhiteBackgroundCorrectForBackColor.Clone(), GraphicsConfig) GraphicsConf.ApplyLineType = True GraphicsConf.ShowHatchBoundaries = True GraphicsConf.TryDrawingTextAsText = True GraphicsConf.DisplayLineTypeElementShapes = True GraphicsConf.DotsPerInch = 1 Dim ctbFile As CtbFile = New CtbFile("D:\support\abs\1\CTB\P&ID COLOR - A1.ctb") GraphicsConf.PlotStyleManager = ctbFile.GetPlotStyle() <==what are the parameters? pdf.DrawPage(m_CADModel, GraphicsConf, to2DTransform, paperSize) pdf.EndDocument() ms.Close() End Sub
ABS
1/25/2024 9:26 AM
It works well as C# version private void button2_Click(object sender, EventArgs e) { WW.Cad.Model.DxfModel m_CADModel = new WW.Cad.Model.DxfModel(); m_CADModel = DwgReader.Read(textBox1.Text); BoundsCalculator boundsCalculator = new BoundsCalculator(); boundsCalculator.GetBounds(m_CADModel); Bounds3D bounds = boundsCalculator.Bounds; PaperSize paperSize = PaperSizes.GetPaperSize(PaperKind.A3Rotated); float pageWidth = paperSize.Width / 100.0F; float pageHeight = paperSize.Height / 100.0F; float margin = 0F; Matrix4D to2DTransform = DxfUtil.GetScaleTransform(bounds.Corner1, bounds.Corner2, new WW.Math.Point3D(bounds.Center.X, bounds.Corner2.Y, 0.0), new WW.Math.Point3D(new Vector3D(margin, margin, 0.0) * PdfExporter.InchToPixel), new WW.Math.Point3D(new Vector3D(pageWidth - margin, pageHeight - margin, 0.0) * PdfExporter.InchToPixel), new WW.Math.Point3D(new Vector3D(pageWidth / 2.0, pageHeight - margin, 0.0) * PdfExporter.InchToPixel)); Stream ms = File.Create(textBox2.Text); PdfExporter pdf = new PdfExporter(ms); GraphicsConfig GraphicsConf = (GraphicsConfig)GraphicsConfig.WhiteBackgroundCorrectForBackColor.Clone(); GraphicsConf.ApplyLineType = true; GraphicsConf.ShowHatchBoundaries = true; GraphicsConf.TryDrawingTextAsText = true; GraphicsConf.DisplayLineTypeElementShapes = true; // Already scaled to PDF pixels, so can directly use the scaling variable. GraphicsConf.DotsPerInch = 1; CtbFile ctbFile = new CtbFile(@"D:\support\abs\1\CTB\P&ID COLOR - A1.ctb"); GraphicsConf.PlotStyleManager = ctbFile.GetPlotStyle; pdf.DrawPage(m_CADModel, GraphicsConf, to2DTransform, paperSize); // create the pdf pdf.EndDocument(); ms.Close(); }
Wout
1/25/2024 9:44 AM
I suggest you google how to use AddressOf. I'm not a VB.NET teacher. This has been part of .NET for over 20 years. - Wout
Wout
2/2/2024 3:15 PM
Anyways, this should be how you do it in VB.NET:
Visual Basic Code:
Dim graphicsConfig As GraphicsConfig = CType(GraphicsConfig.AcadLikeWithWhiteBackground.Clone(), GraphicsConfig) Dim ctbFile As CtbFile = New CtbFile("C:\support\some ctb file.ctb") graphicsConfig.PlotStyleManager = AddressOf ctbFile.GetPlotStyle
- Wout
Wout
2/14/2024 1:57 PM
There was a bug in the new plot style code, it didn't apply the plot style to mtext/text in some cases. Please download the latest CadLib 4.0 version for a fix. - Wout
< previous  1 2