Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

Scan elements in an active model and get information from all elements in C#?

$
0
0

I have to access elements in an active model, using C#. Now as elements are part of model, I found some method with DGN model like 

Adding, Updating, and Deleting Elements

Collections and Iterators

  1. #GetElementsCollection
  2. #GetControlElementsP
  3. #GetGraphicElementsP
  4. #GetDgnAttachmentsP returns an iterable collection of directly attached DgnAttachment objects.

But unable to find it with DgnModel object.

How to scan through elements of an active model, using C#?

Have code in MDL like below

//--- Scan elements ------------------------------ 	
	eofPos  = mdlElement_getFilePos (FILEPOS_EOF, NULL);

	while (filePos<eofPos) {
		nextPos=mdlElmdscr_read(&edP,filePos,pModelRef,FALSE,&readPos);
		if(nextPos==0) break;
		elemType = mdlElement_getType (&edP->el);
		if(elemType==2) {
			mdlElement_getProperties(&level, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &edP->el);
			elemID = (long)mdlElement_getID (&edP->el);
			index=0;
			weld = GetElementType(edP);

			if(weld && index==10) {
				strcpy(diameter,GetWeldDiameter(elemID));
				if(!strcmpi(diameter,"1.25") || !strcmpi(diameter,"1.5") || !strcmpi(diameter,"2") || !strcmpi(diameter,"3") || !strcmpi(diameter,"4") || 
				!strcmpi(diameter,"6") || !strcmpi(diameter,"8") || !strcmpi(diameter,"10") || !strcmpi(diameter,"12") ) {
				fprintf(fp,"INSERT INTO WELDS (ELEMID, DIAMETER) VALUES ('%ld','%s');\n",elemID,diameter);	
				}	
			}	
			n++;
		}
		mdlElmdscr_freeAll (&edP);
		filePos=nextPos;
	}

Need to take this to C#. 

Thanks for the help in advance.


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>