AutoCAD Plant 3D Forum
Welcome to Autodesk’s AutoCAD Plant 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Plant 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

c# READDWGFILE PARA ACESSAR O BANCO DE DADOS PLANT3D

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
renan.saura
342 Views, 6 Replies

c# READDWGFILE PARA ACESSAR O BANCO DE DADOS PLANT3D

Estou criando uma rotina para busar as informações dos PIESUPPORT em varios desenhos dentro do Plant 3D. Para não precisar abrir cada arquivo e executar a rotina que seria muito demorado, estou criando atraves do READDWGFILE para acessar o banco de dados de cada DWG e buscar as informações, porém quando executo eu cheguei ate o ponto de obter o OBJECTID dos elementos de PIPESUPPORT mas quando tento obter o ROWID para fazer as consultas nas tabelas do Plant3D aparece o erro que o objeto não tem LINK.

É possivel obter informações do banco de dados do Plant3D utilizando o READDWGFILE?

 

renansaura_0-1723211961192.png

 

CODIGO:

 

Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = new Database(false, true);

 

//Contextualize Plant Db...
PipingProject project = PlantApplication.CurrentProject.ProjectParts["Piping"] as PipingProject;
DataLinksManager dlm = project.DataLinksManager;

PnPDatabase pnpDb = dlm.GetPnPDatabase();


db.ReadDwgFile(@"O:\7010\BRASKEM\Plant 3D Models\PJ-17002226\PJ-1700226-TUB.dwg", System.IO.FileShare.ReadWrite, false, "");

 

Transaction tr = db.TransactionManager.StartTransaction();

using (tr)

{
// Open the blocktable, get the modelspace
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);

 

// Iterate through it, dumping objects
foreach (ObjectId supportId in btr)

{

Entity ent = (Entity)tr.GetObject(supportId, OpenMode.ForRead);
string typeString = ent.GetType().ToString();
if (typeString.Contains("Support"))

{

int rowId = dlm.FindAcPpRowId(ent.ObjectId);
//...continue

////////////////////////////////////////////////////////


}

 

 

Tags (4)
6 REPLIES 6
Message 2 of 7
jabowabo
in reply to: renan.saura

DataLinksManager.FindAcPpRowId can only be used on objects residing in a currently opened drawing with its owning project opened in Project Manager.

Message 3 of 7
renan.saura
in reply to: jabowabo

Thank you for reply.

 

So it is not possible to use READDWGFILE to consult information from Plant 3D without having to open each file?

 

Message 4 of 7
jabowabo
in reply to: renan.saura

You can use READDWGFILE and get database info - as long as the project is open, you just can't use that function to get the row ID.

Message 5 of 7
renan.saura
in reply to: jabowabo

Could you tell me which way to query the ROWID using the OBJECTID together with the READDWGFILE?

Message 6 of 7
quan_hm
in reply to: renan.saura

Hi,

If you want datalinksmanager to read object in a drawing that was not open you need to add that drawing to datalinksmanager

dlm.AddDrawing(db, false);

 

Hoang Minh Quan - Piping design engineer
Autodesk Store for Python Catalog
Message 7 of 7
renan.saura
in reply to: quan_hm

thank you. It is work fine.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report