WW.Cad.NetStandard Read, Change and Save
![]() 8/20/2021 12:51 PM
|
---|
I am trying to use WW.Cad.NetStandard and I want to read in a .dwg file, find all the text entries and change them. After changing the entries I want to save the file as either a new .dwg file or in any format to display to the UI. I currently have the following code: C# Code: DxfModel model = CadReader.Read("wwwroot\\images\\RS00010.dwg"); foreach (DxfEntity entity in model.Entities) { if (entity.EntityType == "TEXT") { DxfText value = entity as DxfText; } } Not sure how to change the text field and save it as a different file. Any help is appreciated. |
![]() 8/23/2021 9:14 AM
|
---|
Hi, You can set property DxfText.Text. Did you have a look at the documentation? For writing DWG file you can use the DwgWriter class. - Wout |
![]() 8/23/2021 12:08 PM
|
---|
Yes I did look at the documentation and I wasn't sure if it was that easy to change value.Text to what I want and it'd be associated with that current Entity. But it works now with the following code. C# Code: foreach (DxfEntity entity in model.Entities) { if (entity.EntityType == "TEXT") { DxfText value = entity as DxfText; //replace text with part number value.Text = "R9C605"; } } As for also trying to save to a new file, I've decided I want to save it as a .PNG which I don't think DWGWriter would be the right class to call. I am currently using the following code: C# Code: string outfile = Path.GetFullPath(Path.Combine(_hostingEnvironment.WebRootPath, "images", "RSView.png")); Stream stream; Size maxSize = new Size(250, 250); Image<Bgra32> bitmap = ImageExporter.CreateAutoSizedBitmap<Bgra32>(model, Matrix4D.Identity,GraphicsConfig.AcadLikeWithBlackBackground,maxSize); using (stream = System.IO.File.Create(outfile)) { ImageExporter.EncodeImageToPng(bitmap, stream); } but I'm not sure if this is the correct way to handle it. Also the picture I have coming out is blurry, not the right color, and not sized right, is there a way to handle all that during the creation? I do also understand the black and orange is a limit to the trial method, if I were to purchase a license, what would the default output be? |
![]() 8/23/2021 2:12 PM
|
---|
Yes that looks correct. Can you attach the exported image so I can see it? - Wout |
![]() 8/23/2021 2:15 PM
|
---|
Attached is the image, there is just a lot of extra space at the top. I would like to trim it to it's minimum limits to show the image clearer and then display it on the webpage better. |
![]() 8/23/2021 2:25 PM
|
---|
Hi, The bounding box is affected by the trial text, it will fit snug on the production version. - Wout |
![]() 8/23/2021 2:29 PM
|
---|
Okay thank you. In terms of licenses, which version would I need to purchase to perform all the actions I'm requiring; read, change, save/convert, display? Do I need Professional, or would I be okay with Standard or Basic? |
![]() 8/23/2021 2:35 PM
|
---|
Hi, For the DWG reading you need the Professional edition. - Wout |