Hi. how can i get from the block such properties as hight, slope, length?
изображение.png (79.0 KB)
@Aleks85,
unfortunately, this seems to be not easy, because these values are stored deeply in the file. I have created CADNET-8844 to investigate this further.
if i convert dwg to dxf. Can I get properties from dxf?
@Aleks85,
yes, it will be easier to see where these values are stored and now we are doing the same - inspecting DXF version of this file. Unfortunately, there are reasons that do not allow to get these values now: we don’t have parsing of some required objects, that are helpful here, and we need to understand better how these values are stored in the file.
@Aleks85,
Hi, here is the example how to get these properties for the DXF format:
using (CadImage cadImage = (CadImage)Aspose.CAD.Image.Load(fileName))
{
foreach (CadBaseEntity entity in cadImage.Entities)
{
if (entity is CadInsertObject)
{
CadInsertObject insert = (CadInsertObject)entity;
CadBlockEntity block = cadImage.BlockEntities[insert.Name];
CadBlockTableObject blockTable = block.CadBlockTableObject;
var ref1 = SearchObjectByOwner(cadImage, blockTable.ObjectHandle);
var ref2 = SearchObjectByOwner(cadImage, ((CadDictionary)ref1).ObjectHandle) as CadDictionary;
if (ref2 != null)
{
CadAcDbAssocNetwork network = SearchObjectByOwner(cadImage, ref2.ObjectHandle) as CadAcDbAssocNetwork;
List<string> vars = new List<string>();
foreach (CadParameter param in network.AccosNetworkList)
{
if (param.Type == CadEntityAttribute.Cad360)
{
CadBaseObject bo = SearchCustomObject(cadImage, ((CadStringParameter)param).Value);
CadAcDbAssocVariable var = bo as CadAcDbAssocVariable;
if (bo != null)
{
vars.Add(var.VariableName + " ->> " + var.VariableValue);
}
}
}
}
}
}
}
private static object SearchObjectByOwner(CadImage cadImage, string reference)
{
foreach (CadBaseObject baseObject in cadImage.Objects)
{
if (baseObject.SoftOwner == reference)
{
return baseObject;
}
}
return null;
}
private static CadBaseObject SearchCustomObject(CadImage cadImage, string reference)
{
foreach (CadBaseObject baseObject in cadImage.Objects)
{
if (baseObject.ObjectHandle == reference)
{
return baseObject;
}
}
return null;
}