importing dwg/dxf files generated by revit

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
cmOdeon
Posts: 11
Joined: 08 Apr 2019, 11:23

importing dwg/dxf files generated by revit

Post by cmOdeon » 07 Feb 2022, 16:35

Hi!

I am using a Delphi CADVCL importer similar to the one in use in the _3D Demo for creating a surface model from a dxf file made in revit.

I can see the dxf contains the word REVIT and also a list with all the revit names of BIM elements contained in the model (i.e. category + subcategory under revit's Families menu). I wonder weather this information is stored or not inside the code? and if so where to find it? it would be really great being able to detect programmatically that the input dxf is made with revit and if that is the case group the surfaces contained inside a single BIM element.

For reading the file I am using an object

Code: Select all

Img : TsgCADImage
as follows:

Code: Select all

Img.LoadFromFile(DxfFileName);
Then I iterate through the stack of entities in the model using:

Code: Select all

Img.Converter.Iterate(ReadCADEntities, FinishEntity, FCADParams);
at every iteration Inside my ReadCADEntities function the current entity is of type TsgDXFEntity.

is it possible to get the information I am looking for from any of this objects?

regards, Carlos.

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: importing dwg/dxf files generated by revit

Post by support » 07 Feb 2022, 17:35

Hi Carlos,
Could you please send us an example file by email?

Kind regards,
Maria
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: importing dwg/dxf files generated by revit

Post by support » 30 Sep 2022, 10:15

You can find this data in the Objects section:

Code: Select all

[function GetRevitTypeMapping(ARevitDictionary: TsgDXFDictionary): TsgDXFXRecord;
begin
  if Assigned(ARevitDictionary) then
    Result := TsgDXFXRecord(ARevitDictionary.FindEntByName('REVIT_TYPE_MAPPING'))
  else
    Result := nil;
  ;
end;

function GetRevitDictionary(AImg: TsgCADImage): TsgDXFDictionary;
begin
  if Assigned(AImg.Converter.Sections[csObjects][0]) then
    Result := TsgDXFDictionary(AImg.Converter.Sections[csObjects][0].FindEntByName('REVIT_DICTIONARY'))
  else
    Result := nil;
end;

procedure TForm1.enumrevitmappingdata;
var
  vData: TsgDXFXRecord;
  I: Integer;
begin
  vData := GetRevitTypeMapping(GetRevitDictionary(FImg));
  if Assigned(vData) then
    for I := 0 to vData.Data.DataCount - 1 do
      if vData.Data.DataType[I] = edtString then
      ...
end;
Regards,
Maria.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply