기본 콘텐츠로 건너뛰기

2017의 게시물 표시

Microstation V8i .NET Programming

링크 참조 : http://theactoflearning.blogspot.kr/2014/06/microstation-add-in-creating-add-in.html public static void ItemAttachCommand(string unparsed) { ElementScanCriteria sc = new ElementScanCriteriaClass(); { sc.ExcludeAllTypes(); sc.IncludeType(MsdElementType.CellHeader); sc.IncludeType(MsdElementType.Surface); } int i = Bentley.MicroStation.InteropServices.Utilities.ComApp.ActiveModelReference.MdlModelRefP(); XmlInstanceSchemaManager oSchemaManager = new XmlInstanceSchemaManager(new IntPtr(i)); IList<string> oSchemas = oSchemaManager.ReadSchemas(); XmlInstanceApi oXmlInstanceApi = XmlInstanceApi.CreateApi(oSchemaManager); ElementEnumerator ee = Bentley.MicroStation.InteropServices.Utilities.ComApp.ActiveModelReference.Scan(sc); while (ee.MoveNext()) { CellElement oCell = ee.Current.AsCellElement(); //if (("Component_0001388c-0000-0000-7409-f9ad8c553b82" != oCell.Name)) continue;

SITE 리스트 구하기

PDMS의 SITE 리스트를 순서대로 구하는 로직입니다. PdmsStandalone . Open ( " Sample " , " SYSTEM " , " XXXXXX " , " SAMPLE " ); DbElement oWorld = MDB . CurrentMDB . GetFirstWorld ( DbType . Design ); DbElement oSite = oWorld . FirstMember ( DbElementTypeInstance . SITE ); while ( ! oSite . IsNull ) { string sName = oSite . GetString ( DbAttributeInstance . NAME ); Console . WriteLine ( " Name = {0} " , sName ); DbElement oZone = oSite . FirstMember ( DbElementTypeInstance . ZONE ); while ( ! oZone . IsNull ) { sName = oZone . GetString ( DbAttributeInstance . NAME ); Console . WriteLine ( " Name = {0} " , sName ); DbElement oEle = oZone . FirstMember (); while ( ! oEle . IsNull ) { sName = oEle . GetString ( DbAttributeInstance . NAME ); string sType = oEle . GetStri

Element의 Symbology 구하기

V8로 넘어오면서 Symbology에서 ByLevel, ByCell 값이 생겼습니다. Element에서 Symbology 값을 가져와서 ByLevel인 경우에는 Level에 설정된 Symbology 값을 읽어와야 합니다. mdlElement_getSymbology (& m_uiColor , & m_uiLineWeight , & m_iLineStyle , &( element - > el )); if ( COLOR_BYLEVEL == m_uiColor ) { mdlLevel_getElementColor (& m_uiColor , pDgnModel - > GetDgnModelRef (), m_uiLevelId ); } if ( STYLE_BYLEVEL == m_iLineStyle ) { mdlLevel_getElementStyle (& m_iLineStyle , NULL , pDgnModel - > GetDgnModelRef (), m_uiLevelId ); } if ( WEIGHT_BYLEVEL == m_uiLineWeight ) { mdlLevel_getElementWeight (& m_uiLineWeight , pDgnModel - > GetDgnModelRef (), m_uiLevelId ); }

MDL에서 VBA 매크로 실행

프로젝트를 로딩후 , (프로젝트 이름,모듈 이름,매크로 이름)를 인자로 주어 매크로를 실행합니다. mdlVBA_unloadProject ("DropIt"); if (SUCCESS == mdlVBA_loadProject( "DropIt" )) { if(SUCCESS != mdlVBA_runMacro ("DropIt","Module1","Start")) { mdlVBA_reportCurrentError (); } }

shared cell의 속성 변경

shared cell의 속성(Level,Color,Style)을 변경하려면 shared cell 자체의 속성을 변경하는 것 뿐만 아니라 shared cell이 가리키는 원본의 속성도 같이 변경해야 원하는 결과를 얻을 수 있습니다. if (SUCCESS == mdlSharedCell_getDefinitionId(&m_uniqueId,&(element->el))) { return ERROR_SUCCESS; } 원본의 ID를 구한 뒤 원본의 속성을 변경하면 됩니다. UInt32 filePosP = 0 ; if (SUCCESS == mdlAssoc_getElement( NULL , &filePosP , m_uniqueId , MASTERFILE)) { MSElementDescr *pDescr = NULL; DgnModelRefP modelRef=NULL; if ( mdlElmdscr_read (&pDescr, filePosP , modelRef , FALSE , NULL) != 0) { UInt32 *pColor = NULL,*pWeight = NULL; Int32* pStyle = NULL; if(-1 != (Int32)oSymbology .color ) pColor = &oSymbology .color ; if(-1 != (Int32)oSymbology .style ) pStyle = &oSymbology .style ; if(-1 != (Int32)oSymbology .weight ) pWeight = &oSymbology .weight ; mdlElmdscr_setSymbology(pDescr ,pColor,pStyle,pWeight,NULL); mdlElmdscr_rewrite(pDescr,pDescr,filePosP); mdl