<p>1. Writing providerID or similar:</p><p>C++(MDL): Public void scanReference() { ModelRefIteratorP iteratorP = NULL; DgnModelRefP modelP = NULL; ReferenceFile *refFileP = NULL; int status; int n = 0;</p><p> mdlModelRefIterator_create(&iteratorP, ACTIVEMODEL, MRITERATE_PrimaryChildRefs, 0); if (!iteratorP) return;</p><p>PWLib::message("------scanRef to %s", PWLib::getModelFilename(ACTIVEMODEL));</p><p> 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);</p><p>//PWLib::messageGuid(refFileP->file_id.fileName); //PWLib::messageGuid(refFileP->file_id.fullFileSpec);</p><p> if ((refFileP->file_id.providerID!=NULL) && (PWLib::LIB_Wstrlen(refFileP->file_id.providerID)>0)) { PWLib::message("Provider [%S]", refFileP->file_id.providerID);</p><p>MSWChar newValue[512] = L"test";</p><p> mdlWideChar_strcpy((MSWideCharP)refFileP->file_id.providerID, (MSWideCharCP)newValue);</p><p>ULong refNum = refFileP->file_id.referenceNum; ElementID eID = refFileP->attach.uniqueId;</p><p>PWLib::message("Provider ændret til [%S]", refFileP- >file_id.providerID); }</p><p> modelP = mdlModelRefIterator_getNext(iteratorP); }</p><p> mdlModelRefIterator_free(&iteratorP); PWLib::message("------"); }</p><p>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);</p><p>[DllImport("stdmdlbltin.dll", CallingConvention = CallingConvention.Cdecl)] public static extern int mdlRefFile_getInfo(int modelRef); public frmShowReferences() { InitializeComponent(); }</p><p> private void btnScanForReference_Click(object sender, EventArgs e) { List<string> _items = new List<string>(); 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;</p><p> int lModelRef = referencefil.MdlModelRefP(); //Model.MdlModelRefP();</p><p> int ReferencefilStructPointer = mdlRefFile_getInfo(lModelRef); string cstring = "((struct referenceFile *)" + ReferencefilStructPointer + ")"; string providerID = (string)pwReferenceAddin.comApp.GetCExpressionValue(cstring + "- >file_id.providerID");</p><p> int iTest = testAbc();</p><p> if (!string.IsNullOrEmpty(providerID)) { _items.Add("providerID er:" + providerID);</p><p> 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"); }</p><p>//referencefil.Reattach( if (referencefil.DisplayFlag) {</p><p> if (referencefil.IsMissingFile) { //bool Returværdi = false; break; } } _items.Add("FUllName er:" + strFullname); } listBox1.DataSource = _items; } //end btnScanForReference_Click</p><p> private void qwe(int ReferencefilStructPointer) {</p><p>} } //end class "frmShowReferences } //end namespace</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages4 Page
-
File Size-