Free Support Forum - aspose.com

Entity resizing in a dxf file

Hello, I was wondering if is possible to change the dimensions of any entity in a dxf file (lines for example) by updating the value of attributes using Aspose.CAD. I mean, not just change the text of
a dimension between two points, but also resize the entities visually.

Thanks!

1 Like

@jaiv1978

Plese visit this API refernece guide link where you will find the properties for setting the line weights, scales and other properties for your convenince.

Thanks for the answer, but I still having problems updating the values

I tried with a simple dxf file that has a square of 40x40 (you can see in the uploaded file)

image.png (3.5 KB)

Then I executed this code (based on the ASPOSE-examples project)

		try
		{
			//ExStart:AddAttribute
			// The path to the documents directory.
			string MyDir = RunExamples.GetDataDir_DXFDrawings();
			string sourceFilePath = MyDir + "Drawing1.dxf";
			FileStream fileStream = new FileStream(MyDir + "Drawing1_v2.dxf", FileMode.OpenOrCreate, FileAccess.Write);
			
			using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath))
			{
				foreach (var entity in cadImage.Entities)
				{
					if (entity.TypeName == CadEntityTypeName.DIMENSION)
					{
						var dimension = (CadDimensionBase)entity;
						dimension.Text = "50";
					}
				}
				cadImage.Save(fileStream);
				fileStream.Close();
			}		
		}
		catch (Exception ex)
		{
			Console.WriteLine(ex.Message);
		}

When I open Drawing1_v2.dxf I don’t see the Text dimensions changed, but when I see their properties, I can see that the new text value is changed. What do I need to do to display the new values?.

PD. If I double click on the dimensions, the new texts are displayed

Drawing1_v2.PNG (13.6 KB)

@jaiv1978

Can you please possibly share the desired output file that you want to achieve so that we may try to help you further in this regard.

Sure, What I want is the following:

I have a dxf file with a square of 40x40

image.png (3.5 KB)

I process it using ASPOSE.Cad and change the values of the dimensiones like this (using CadDimensionBase object)

ActualMeasurement = 50
Text = “50”

Then, I get a new dxf file with a square of 50x50 (the dimension text has changed and the real dimensions of the square too)

Drawing1_changed.PNG (3.6 KB)

@jaiv1978

I can observe the snapshots shared by you. However, as requested earlier please share the desired output DXF along with source DXF that I may use to log the issue for investigation and resolution.

Hello,

This is the zip file with both dxf files.

Drawing1_v2.zip (18.9 KB)

“Drawing1.dxf” is the input file
“Drawing1_v2.dxf” is the output required

thanks

@jaiv1978

We need to further evaluate your requirements and for this I have added a ticket with ID CADNET-1263 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.