Hi
There is a requirement which needs to retrieve the slope property of block. I can see any direct api in Aspose cad to get it. Is there any other way to retrieve it?
Thanks
Hi
There is a requirement which needs to retrieve the slope property of block. I can see any direct api in Aspose cad to get it. Is there any other way to retrieve it?
Thanks
Based on limited evidence (treat as hypothesis), here is a cautious take:
Summary
Aspose.CAD does not provide a dedicated “slope” property for a block. To obtain a slope‑like value you have to derive it from the block’s geometry or from the transformation information that the SDK exposes (if any).
Why
A block reference is stored with a transformation matrix that defines its position, rotation and scaling. The library does not interpret that matrix as a “slope”, because “slope” can refer to different geometric concepts (2‑D line inclination, 3‑D plane inclination, etc.). Hence no ready‑made API exists.
How to retrieve a slope‑like value
using Aspose.CAD;
using Aspose.CAD.ImageOptions;
CadImage cadImage = (CadImage)Image.Load("drawing.dwg");
cadImage.Blocks or the collection that holds block definitions). For each block:If the SDK exposes a transformation matrix (often named TransformationMatrix or similar), you can read its rotation components and compute an angle:
// Example – matrix components (replace with actual property names)
var matrix = blockReference.TransformationMatrix;
// Rotation around Z‑axis (2‑D case)
double angle = Math.Atan2(matrix.M21, matrix.M11); // radians
double slope2D = Math.Tan(angle); // ΔY/ΔX
For 3‑D blocks you can use the direction of the Z‑axis (the third column of the matrix) to calculate the inclination of the block’s plane relative to the XY‑plane.
If the matrix is not available, examine the entities that belong to the block (lines, polylines, arcs, etc.) and compute their individual slopes from start/end coordinates:
foreach (var entity in block.Entities)
{
if (entity is CadLine line)
{
double dx = line.EndPoint.X - line.StartPoint.X;
double dy = line.EndPoint.Y - line.StartPoint.Y;
double lineSlope = dy / dx; // 2‑D slope
// use lineSlope as needed
}
}
When this works
Next steps
Please validate this behaviour with your exact SDK version and a minimal repro, as support can vary by release.
Assumptions / confirmations needed: SDK + version, file types, minimal sample, and exact error/output.
@jim_zhu,
Hi,
block usually relates to INSERT or BLOCK entity, there is no slope value for them. Could you please share the test file with such block, the value you need to obtain and your code sample?
if you use BricsCad to open an dwg and select a block reference, you will see the slope property at properties bar. I want to retrieve it. how can I do it
@jim_zhu,
we can see slope value in BricsCAD. But this is a part of this software itself, we have verified that the slope value is not stored in the DXF/DWG file. So it seems the only way to obtain it is to calculate the slope for each block yourself.