cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Problem facing to get Detail note details and symbol info into a log file/txt file.

AA_10315405
3-Visitor

Problem facing to get Detail note details and symbol info into a log file/txt file.

Hi Folks,

Please help me some one to achieve the Log information of Detail notes and Symbol information of a drawing, i am using the below code ,.issue :file is not saving the  data. correct the  below code if possible ...

 

 

#include"DrawingModule.h"
#include <ProDrawing.h>
#include <ProView.h>
#include <ProDwgtable.h>
#include <ProDtlnote.h>
#include <ProDtlsyminst.h>
#include <ProArray.h>
#include <ProUtil.h>
#include <stdio.h>
#include <string>
#include <ProNote.h>
#include"ProUtil.h"
#include"ProWTUtils.h"
#include <ProTKRunTime.h>
#include <ProMessage.h>
#include <xlocmon>
#include <ProToolkit.h>
#include <ProMdl.h>
#include <ProMenu.h>
#include "Log.h"

#define DTL_NOTE_FILE ".inf"
#define PROTKRUNTIME_H_DEFINED

using namespace std;

//ProError DetailnoteVisitAction(ProDtlitem* dtlNote, ProError filt_status, ProAppData data);
ProError SymboldefinitionVisitAction(ProDtlitem* symDef, ProError filt_status, ProAppData data);
ProError SymDef_Note_visit();
FILE* Outputfile = fopen("C:\\Users\\HP\\Desktop\\creotoolkitpract\\output\\DrawingData.txt", "a");
void DrawingModule::StartDrawingModule(ProMdl dwgMdl)
{
ProError status;
//FILE* Outputfile = fopen("C:------------\\output\\DrawingData.txt", "a");
ProError DetailnoteVisitAction(ProDtlitem * dtlNote, ProError filt_status, ProAppData data);
return;
}

ProError DetailnoteVisitAction(ProDtlitem* dtlNote, ProError filt_status, ProAppData data)
{
ProVector envelope[4];
int nLines;
ProError status;

ProDtlnotedata dataNote;
status = ProDtlnoteDataGet(dtlNote, (ProDtlsymdef*)data, PRODISPMODE_NUMERIC, &dataNote);

ProDtlnoteline* arrNoteLines;
status = ProDtlnotedataLinesCollect(dataNote, &arrNoteLines);

ProArraySizeGet(arrNoteLines, &nLines);
for (int iL = 0; iL < nLines; iL++)
{
ProDtlnotetext* arrText;
status = ProDtlnotelineTextsCollect(arrNoteLines[iL], &arrText);
if (status != PRO_TK_NO_ERROR) continue;

/*int nText;
ProComment noteLine = L"\0";
ProArraySizeGet(arrText, &nText);
for (int iT = 0; iT < nText; iT++)
{*/
///*ProLine lineString;
//status = ProDtlnotetextStringGet(arrText[iT], lineString);
//if (status == PRO_TK_NO_ERROR)
//{*/
//Compose each and every text string
ProDrawing drawing{};
int nText;
ProDtlnote* p_notes[100];
int n_notes = 0, i, n_leaders = 0, j, n_lines = 0, n_texts = 0, k, id;
ProDtlnotedata note_data{};
ProBoolean flag;
ProHorizontalJustification hjust;
ProVerticalJustification vjust;
ProColor color;
double param = 0.0;
ProDtlattach attach, * p_leaders;
ProDtlattachType type;
ProView view;
ProVector location;
ProSelection attach_point;
ProDtlnoteline* p_lines;
ProDtlnotetext* p_texts;
ProLine string;
FILE* Outputfile{};
ProCharLine line, fname;
ProPath path;
ProName font;
ProMdlName mdl_ref_name;
ProMdl mdl_ref;
status = ProArraySizeGet((ProArray)p_notes, &n_notes);
for (i = 0; i < n_notes; i++)
{
status = ProDtlnoteDataGet( p_notes[i], NULL, PRODISPMODE_NUMERIC, &note_data);
status = ProDtlnotedataIdGet(note_data, &id);
ProTKFprintf(Outputfile, "\nID: %d. ", id);

status = ProDtlnotedataIsMirrored(note_data, &flag);
ProTKFprintf(Outputfile, "Mirrored: %s. ", (flag == PRO_B_TRUE) ? "Yes" : "No");

status = ProDtlnotedataReadonlyGet(note_data, &flag);
ProTKFprintf(Outputfile, "Readonly: %s. \n", (flag == PRO_B_TRUE) ? "Yes" : "No");

status = ProDtlnotedataJustifGet(note_data, &hjust, &vjust);
ProTKFprintf(Outputfile, "Justification : norisontal = %d, vertical = %d. \n", hjust, vjust);

status = ProDtlnotedataColorGet(note_data, &color);
ProTKFprintf(Outputfile, "Color: ");
//ProTestColorPrint(Outputfile, color);

status = ProDtlnotedataElbowlengthGet(note_data, &flag, &param);
if (flag == PRO_B_FALSE)
ProTKFprintf(Outputfile, "Elbow leng = %6.3f.", param);
else
ProTKFprintf(Outputfile, "Elbow leng: No.");

status = ProDtlnotedataAttachmentGet(note_data, &attach);
status = ProDtlattachGet(attach, &type, &view, location, &attach_point);
ProTKFprintf(Outputfile, "Attachment type: %d. ", type);
status = ProDtlattachFree(attach);
status = ProDtlnotedataLeadersCollect(note_data, &p_leaders);
if (status == PRO_TK_NO_ERROR)
{
status = ProArraySizeGet((ProArray)p_leaders, &n_leaders);
ProTKFprintf(Outputfile, "Number of leaders: %d.\n", n_leaders);
}


status = ProDtlnotedataLinesCollect(note_data, &p_lines);
if (status != PRO_TK_NO_ERROR)
continue;

status = ProArraySizeGet((ProArray)p_lines, &n_lines);
for (j = 0; j < n_lines; j++){
status = ProDtlnotelineTextsCollect( p_lines[j], &p_texts);
if (status != PRO_TK_NO_ERROR)
continue;
status = ProArraySizeGet((ProArray)p_texts, &n_texts);
for (k = 0; k < n_texts; k++){
ProTKFprintf(Outputfile, "Note text param:\n");
status = ProDtlnotetextHeightGet(p_texts[k], &param);

ProTKFprintf(Outputfile, "Height = %6.3f. ", param);
status = ProDtlnotetextWidthGet(p_texts[k], &param);

ProTKFprintf(Outputfile, "Width = %6.3f. ", param);
status = ProDtlnotetextSlantGet(p_texts[k], &param);

ProTKFprintf(Outputfile, "Slant = %6.3f. ", param);
status = ProDtlnotetextThicknessGet(p_texts[k], &param);

ProTKFprintf(Outputfile, "Thickness = %6.3f.\n", param);
status = ProDtlnotetextFontGet(p_texts[k], font);

ProWstringToString(line, font);
ProTKFprintf(Outputfile, "Font: %s. ", line);
status = ProDtlnotetextUlineGet(p_texts[k], &flag);

ProTKFprintf(Outputfile, "Uline: %s.\n", (flag == PRO_B_TRUE) ? "Yes" : "No");
ProTKFprintf(Outputfile, "Note text:\n");
status = ProDtlnotetextStringGet(p_texts[k], string);

ProWstringToString(line, string);
ProTKFprintf(Outputfile, "%s", line);
status = ProDtlnoteModelrefGet(p_notes[i], NULL, j, k, &mdl_ref);

if (status == PRO_TK_NO_ERROR){
status = ProMdlMdlnameGet(mdl_ref, mdl_ref_name);
ProTKFprintf(Outputfile, " (Ref model: %s)\n", ProWstringToString(line, mdl_ref_name));

}
}
for (k = 0; k < n_texts; k++){
status = ProDtlnotetextFree(p_texts[k]);
}
status = ProArrayFree((ProArray*)&p_texts);
}
for (j = 0; j < n_lines; j++){
status = ProDtlnotelineFree(p_lines[j]);
}
status = ProArrayFree((ProArray*)&p_lines);
}
status = ProArrayFree((ProArray*)&p_notes);
status = ProDtlnotedataFree(note_data);
// ProWstringConcatenate(lineString, noteLine, PRO_VALUE_UNUSED);
//and handle whole note line with the function of your convenience


}

return PRO_TK_NO_ERROR;
}

ProError SymboldefinitionVisitAction(ProDtlitem* symDef, ProError filt_status, ProAppData data)
{
ProError status;

ProMdl currentMdl;
status = ProMdlCurrentGet(&currentMdl);
ProDrawing drawing = (ProDrawing)currentMdl;

int pageNr;
status = ProDrawingCurrentSheetGet(drawing, &pageNr);

ProDtlsymdefdata symDefData;
status = ProDtlsymdefDataGet(symDef, &symDefData);

ProName symName;
status = ProDtlsymdefdataNameGet(symDefData, symName);

ProComment cmt;
ProTKSwprintf(cmt, L"SymbolName: %ls", symName);
ProTrailfileCommentWrite(cmt);

status = ProDrawingDtlnoteVisit(drawing, symDef, pageNr, (ProDtlitemVisitAction)DetailnoteVisitAction, NULL, (ProAppData)symDef);

return PRO_TK_NO_ERROR;
}

ProError SymDef_Note_visit()
{
ProError status, retval = PRO_TK_NO_ERROR;

ProMdl currentMdl;
status = ProMdlCurrentGet(&currentMdl);
ProDrawing drawing = (ProDrawing)currentMdl;

status = ProDrawingDtlsymdefVisit(drawing, SymboldefinitionVisitAction, NULL, NULL);

return retval;
}

1 REPLY 1
FV
17-Peridot
17-Peridot
(To:AA_10315405)

your local variable Outputfile is overriding your global Outputfile variable with empty...

FILE* Outputfile{};

 

Top Tags