Writing Providerid Or Similar

Total Page:16

File Type:pdf, Size:1020Kb

Writing Providerid Or Similar

1. Writing providerID or similar:

C++(MDL): Public void scanReference() { ModelRefIteratorP iteratorP = NULL; DgnModelRefP modelP = NULL; ReferenceFile *refFileP = NULL; int status; int n = 0;

mdlModelRefIterator_create(&iteratorP, ACTIVEMODEL, MRITERATE_PrimaryChildRefs, 0); if (!iteratorP) return;

PWLib::message("------scanRef to %s", PWLib::getModelFilename(ACTIVEMODEL));

modelP = mdlModelRefIterator_getFirst(iteratorP) ; while (modelP) { refFileP = mdlRefFile_getInfo(modelP); if (!refFileP) { PWLib::message("No ref to model %s", PWLib::getModelFilename(modelP)); modelP = mdlModelRefIterator_getNext(iteratorP); continue; } n++; //desc=%S logical=%S //refFileP->attach.description, //refFileP->attach.logicalName, PWLib::message("Reference %d) missing=%d filename=%s fullname= %s", n, refFileP->display.fb_opts.missing_file, refFileP->file_id.fileName, refFileP->file_id.fullFileSpec);

//PWLib::messageGuid(refFileP->file_id.fileName); //PWLib::messageGuid(refFileP->file_id.fullFileSpec);

if ((refFileP->file_id.providerID!=NULL) && (PWLib::LIB_Wstrlen(refFileP->file_id.providerID)>0)) { PWLib::message("Provider [%S]", refFileP->file_id.providerID);

MSWChar newValue[512] = L"test";

mdlWideChar_strcpy((MSWideCharP)refFileP->file_id.providerID, (MSWideCharCP)newValue);

ULong refNum = refFileP->file_id.referenceNum; ElementID eID = refFileP->attach.uniqueId;

PWLib::message("Provider ændret til [%S]", refFileP- >file_id.providerID); }

modelP = mdlModelRefIterator_getNext(iteratorP); }

mdlModelRefIterator_free(&iteratorP); PWLib::message("------"); }

C#: [DllImport("stdmdlbltin.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int mdlRefFile_getInfo(int modelRef); namespace pwReferenceAddin { public partial class frmShowReferences : Form { //Declare Function mdlRefFile_getInfo Lib "stdmdlbltin.dll" ( ByVal modelRef As Long ) As Long ' Returns a pointer to a structure //[DllImport("stdmdlbltin.dll", CharSet = CharSet.Unicode)] //public static extern System.IntPtr mdlRefFile_getInfo(System.IntPtr modelRef);

[DllImport("stdmdlbltin.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int mdlRefFile_getInfo(int modelRef); public frmShowReferences() { InitializeComponent(); }

private void btnScanForReference_Click(object sender, EventArgs e) { List _items = new List(); foreach (BCOM.Attachment referencefil in pwReferenceAddin.comApp.ActiveModelReference.Attachments) { string strFullname = string.Empty; if ((referencefil.DesignFile!=null) && ! string.IsNullOrEmpty(referencefil.DesignFile.FullName)) strFullname = referencefil.DesignFile.FullName;

int lModelRef = referencefil.MdlModelRefP(); //Model.MdlModelRefP();

int ReferencefilStructPointer = mdlRefFile_getInfo(lModelRef); string cstring = "((struct referenceFile *)" + ReferencefilStructPointer + ")"; string providerID = (string)pwReferenceAddin.comApp.GetCExpressionValue(cstring + "- >file_id.providerID");

int iTest = testAbc();

if (!string.IsNullOrEmpty(providerID)) { _items.Add("providerID er:" + providerID);

string newValue = "test"+iTest.ToString(); try { //pwReferenceAddin.comApp.SetCExpressionValue(cstring + "->file_id.providerID", newValue); } catch { _items.Add("providerID er: øv"); } providerID = (string)pwReferenceAddin.comApp.GetCExpressionValue(cstring + "- >file_id.providerID"); _items.Add("providerID er ændret til:" + providerID); } else { _items.Add("providerID er: tom"); }

//referencefil.Reattach( if (referencefil.DisplayFlag) {

if (referencefil.IsMissingFile) { //bool Returværdi = false; break; } } _items.Add("FUllName er:" + strFullname); } listBox1.DataSource = _items; } //end btnScanForReference_Click

private void qwe(int ReferencefilStructPointer) {

} } //end class "frmShowReferences } //end namespace

Recommended publications