Building Information Modelling (BIM) has been widely adopted as an effective means for supporting information exchange in Architectural, Engineering and Construction (AEC) industry based on unified and platform-independent standards. Among them, the Industry Foundation Classes (IFC), an ISO standard for BIM, is the most widely used one. However, due to the complexity and flexibility of IFC, the extraction of the attributes of IFC objects is a challenging process for practitioners and software developers in AEC industry, which impedes in-depth application of BIM in many cases. To solve the problem, an approach is proposed in this paper based on graph theory and SPARQL query to automate and simplify the process. The approach consists of four operators, i.e., IFC-to-OWL Convertor, P-Path Acquirer, SPARQL Query Generator, and Ontology Reasoner. IFC-to-OWL Convertor translates IFC instance model into ifcOWL instance model, which can be queried by using SPARQL. P-Path Acquirer obtains all possible Predicate Paths (P-Paths) from an object entity to an attribute entity in the graph created based on ifcOWL schema model. Then SPARQL Query Generator generates SPARQL queries for extracting attributes based on the P-Paths. Finally, the ifcOWL instance model and the SPARQL queries are input into Ontology Reasoner to query attributes of IFC objects. The approach is validated by conducting a case study. The approach contributes to the convenient application of IFC standards in AEC industry.