기본 콘텐츠로 건너뛰기

라벨이 MICROSTATION인 게시물 표시

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; ...

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...

Microstation J의 텍스트 폰트 일괄 수정

아래 매크로를 사용하여 텍스트의 폰트를 일괄 수정할 수 있습니다. Font No는 특정 텍스트 파일(C:\Temp\ChgFnt.dat)에 입력하였습니다. '-------------------------------------------------------------'' main - Entry point' '-------------------------------------------------------------Sub main Dim element as New MbeElement Dim filePos as Long Dim S$,FontNo as Integer 'read fence data from file Index = 0 Open "C:\Temp\ChgFnt.dat" For Input As 1 Do While Not Eof(1) Input #1,S FontNo = Val(S) Loop Close 'up to here ' read the first element filePos = element.fromFile (0) Do While filePos >= 0 If element.type = MBE_Text Then element.font = FontNo stat = element.rewrite(filePos, 0, 0) End If filePos = element.fromFile (filePos + element.fileSize) Loop End Sub

마이크로스테이션 V8의 Batch Process를 이용한 Dwg 변환

이 매크로를 만들게 된 이유는 Batch Converter로 변환 시 Dgn에서 Off된 Level도 Dwg로 변환 시 모두 On이 되기 때문입니다. Dgn에서 Off된 Level를 찾아 저장 후, Dwg로 변환하고 나서 저장한 Level과 같은 이름의 Level를 찾아 Off시키도록 했습니다. - Macro File - Sub ConvertWithoutUnvisibleLevel ( ) RemoveLevel = False Dim oLevels As Levels Dim oLevel As Level Dim oView As View Dim oOffLevel ( 10 ) As String Dim counter ( 2 ) As Integer , iOffLevelCount Set oLevels = ActiveDesignFile . Levels Set oView = ActiveDesignFile . Views ( 1 ) counter ( 0 ) = 0 iOffLevelCount = 0 Do While counter ( 0 ) < oLevels . Count counter ( 0 ) = counter ( 0 ) + 1 Set oLevel = oLevels . Item ( counter ( 0 ) ) If True < > oLevel . IsDisplayedInView ( oView ) Then oOffLevel ( iOffLevelCount ) = oLevel . Name iOffLevelCount = iOffLevelCount + 1 End If Loop ...

마이크로스테이션 V8의 Batch Process를 이용한 PDF 출력

마이크로스테이션 V8 의 Batch Process 를 이용한 Dgn->PDF 출력 첨부한 파일 (Command File) 을 로컬에 복사하세요 . 1.      Utility à Batch Process 를 클릭 2.      PDF 로 출력할 Dgn  파일을 추가 3.      첨부한 Command File 을 선택 4.      Batch Job 실행 5.      PDF 파일은 Adobe Acrobat 에서 설정한 Output Folder 에 생성이 됩니다 . --- Command File -- #---------------------------------------------------------------------- # #  Command file for batchprocess utility # #  This command file was originally copied from $(MS_DATA)cmdfiletemplate.txt. #  Command file information: #       - Lines that start with the '#' character are treated as comments and ignored. # #---------------------------------------------------------------------- fit view extended print attributes lineweights off # 레퍼런스등이 있을 수 있으므로 place fence allfiles 1...