기본 콘텐츠로 건너뛰기

2011의 게시물 표시

Dgn File(J format) Viewer

OCC로 만들어 본 Dgn File(J format) Viewer입니다. 여기서 다운 로드 하세요

OCC 버그?

같은 위치, 같은 반지름으로 타원과 원을 생성하여 회전체를 생성했을 때 그 결과가 다르게 나타났습니다. 아래는 결과를 캡쳐한 이미지입니다. 타원으로 회전체를 생성했을 때 위에서 그림이 제대로 보이지 않아 마우스를 올려놓아 highlight 시켰을 때 원으로 회전체를 생성했을 때 위 그림을 보시면 타원으로 생성했을때는 결과가 제대로 나타나지 않는 것을 알수가 있습니다. 제가 테스트에 사용한 것은 OpenCASCADE6.3.0 입니다. 이후 버젼은 위의 내용이 수정되었는지 궁금하네요...

[MDL] 더블 클릭 이벤트 받기

mdlLocate_setFunction 함수를 통하여 더블 클릭 이벤트를 받을 수 있습니다. mdlState_startModifyCommand (NULL, modifyElement_accept,NULL, NULL, NULL, 0, 0, TRUE , 0); mdlLocate_setFunction(LOCATE_ELEMENT_DOUBLECLICK , doubleclick_function); mdlInput_sendSynchronizedKeyin("CHOOSE ELEMENT ",FALSE,INPUTQ_EOQ,NULL); mdlInput_sendSynchronizedKeyin("POWERSELECTOR MODE NEW ",FALSE,INPUTQ_EOQ,NULL); 선택 모드 상태에서 Element를 더블 클릭했을 때 등록한 함수(doubleclick_function)가 호출됩니다. 아래 두 줄은 선택 모드로 바꾸기 위한 코드입니다.

mdlDim_getActualValues 오류

Dimension의 텍스트를 읽을때 텍스트가 자동으로 계산되어 표시되는 경우는 mdlText_extract 함수를 통하여 읽었을때 *로 읽힙니다. 이럴때 mdlDim_getActualValues 함수를 통하여 실제 값을 구할 수 있습니다. 하지만 이 함수가 완전하지 않은지 가끔씩 에러가 발생합니다. 원인과 해결 방법을 알고 계신 분은 좀 알려 주세요... double pdValues[256] = {0,}; f (SUCCESS == mdlDim_getActualValues(&(element->el) , pdValues)) { m_sTextString.Format (_T("%.4f") , (pdValues[0] / uor)); }

XData 쓰기 예제

xdata 쓰기 예제입니다. if (mdlElmdscr_read(&pDescr, filePosP , modelRef , FALSE , NULL) != 0) { ElementId regAppID; static MSWChar *s_applicationName = L"Rev.Pro"; if (SUCCESS == mdlRegApp_idFromName (&regAppID, s_applicationName , mdlModelRef_getDgnFile(MASTERFILE), TRUE)) { XDataValueUnion data; int dataType; int groupCode; UInt32 dataSize; UInt32 index = NULL; if(pDescr->h.isHeader && pDescr->h.firstElem) { for(MSElementDescrP ptr = pDescr->h.firstElem;NULL != ptr;ptr = ptr->h.next) { UInt32 color = 0; mdlElement_getSymbology(&color, NULL , NULL , &(ptr->el)); //기존 데이타 있는지 체크.. if (SUCCESS != mdlLinkage_getXDataGroupCode (&data, &dataType, &dataSize, &groupCode, &(ptr->el) , &index)) { const int

Hole in solid

Solid에 구멍을 만드는 예제입니다. //The cylinder gp_Pnt neckLocation ( gp_Pnt ( 30 , 30 , 0 ) ) ; gp_Dir neckNormal = gp :: DZ ( ) ; gp_Ax2 neckAx2 ( neckLocation , neckNormal ) ; TopoDS_Shape aHole = BRepPrimAPI_MakeCylinder ( neckAx2 , 10 , 60 ) ; //The cube TopoDS_Shape box = BRepPrimAPI_MakeBox ( gp_Pnt ( 0 , 0 , 0 ) , 60 , 60 , 60 ) ; //Cube - Cylinder TopoDS_Shape result = BRepAlgoAPI_Cut ( box , aHole ) ; return result ;

Surface of revolution 예제

아래는 OCC에 들어 있는 예제중의 하나 입니다. TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge ( gp_Pnt ( 0 . , 0 . , 0 . ) , gp_Pnt ( 50 . , 0 . , 0 . ) ) ; TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge ( gp_Pnt ( 50 . , 0 . , 0 . ) , gp_Pnt ( 50 . , 50 . , 0 . ) ) ; TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge ( gp_Pnt ( 50 . , 50 . , 0 . ) , gp_Pnt ( 0 . , 0 . , 0 . ) ) ; TopoDS_Wire W = BRepBuilderAPI_MakeWire ( E1 , E2 , E3 ) ; gp_Ax1 axe = gp_Ax1 ( gp_Pnt ( 0 . , 0 . , 30 . ) , gp_Dir ( 0 . , 1 . , 0 . ) ) ; ///Handle(Geom_Axis1Placement) Gax3 = new Geom_Axis1Placement(axe); /// i don't know why below code raises error ///Handle (AIS_Axis) ax3 = new AIS_Axis(Gax3); ///m_hAISContext->Display(ax3,Standard_False); TopoDS_Shape S3 = BRepPrimAPI_MakeRevol ( W , axe , 210 . * PI180 ) ; Handle ( AIS_Shape ) ais5 = new AIS_Shape ( W ) ; m_hAISContext - > Display ( ais5 , Standard_True ) ; Handle ( AIS_Shape ) ais6 = new AIS_Shape ( S3 ) ; m_hAISContext - > SetColo

BREP 데이타 출력

아래는 BREP 데이타를 출력하는 코드입니다. BRep_Builder B ; TopoDS_Shape S1 ; BRepTools :: Read ( S1 , lpszPathName , B ) ; if ( S1 . IsNull ( ) ) { AfxMessageBox ( _T ( " Shape(s) not found. " ) , MB_ICONERROR ) ; } else { Handle_AIS_Shape hAISShape = new AIS_Shape ( S1 ) ; hAISShape - > SetColor ( Quantity_NOC_GREEN ) ; hAISShape - > SetMaterial ( Graphic3d_NOM_PLASTIC ) ; m_hAISContext - > Display ( hAISShape , false ) ; }

[MDL] ProgressBar 표현

어떤 다소 시간이 걸리는 작업을 할때 사용자들을 멍~하니 기다리게 하는 것보다 ProgressBar를 표시하는 것이 효과적입니다. 예제) 열린 파일에서 현재 읽고 있는 요소대한 진행 상태를 표시하는 방법에 대해 알아보도록 하겠습니다.(즉 현재 몇번째 요소를 읽고 있는지 나타내는...) 1. 화면에 표시할 다이얼로그 리소스 준비 2. 다이얼로그를 생성할 스레드 생성 작업 스레드에서 다이얼로그를 생성하도록 합니다. 여기서 하고 싶은 말 : mdlXXX류의 함수는 작업 스레드에서 제대로 작동하지 않을수 있으니... 주 스레드에서 호출해야 한다는 것입니다. /****************************************************************************** @author humkyung @date 2011-08-22 @class @function StatusThreadEntry @return UINT @param LPVOID pVoid @brief ******************************************************************************/ UINT StatusThreadEntry(LPVOID pVoid) { CWorkStatusDlg* pDlg = (CWorkStatusDlg*)(pVoid); if(pDlg) { InterlockedExchange((LONG*)(&(pDlg->m_bThreadRunning)) , TRUE); pDlg->DoModal(); } return ERROR_SUCCESS; } extern "C" __declspec(dllexport) int __stdcall RevMISC(const CString &INI_FILE_PATH)

BsplineSurface에서 Mesh 데이타 구하기

아래와 같은 단계를 통하여 BsplineSurface의 Mesh 데이타를 구할 수 있습니다. 1. MSElementDescr을 MSBsplineSurface 타입으로 변환 MSBsplineSurface oBsplineSurf; mdlBspline_convertToSurface(&oBsplineSurf , element); 2. BsplineSurface의 Mesh 데이타를 PolyfaceArray에 넣기 PolyfaceArrays oPolyFaces; memset(&oPolyFaces , 0x00 , sizeof(oPolyFaces)); oPolyFaces.pIndex = jmdlEmbeddedIntArray_grab(); oPolyFaces.pXYZ = jmdlEmbeddedDPoint3dArray_grab(); oPolyFaces.pUV = jmdlEmbeddedDPoint2dArray_grab(); if(SUCCESS == mdlMesh_polyfaceArraysFromMSBsplineSurface(&oPolyFaces , &oBsplineSurf , 1*mdlModelRef_getUorPerMaster(ACTIVEMODEL) , FALSE , TRUE)) { const int nXYCount = jmdlEmbeddedDPoint3dArray_getCount(oPolyFaces.pXYZ ); const int indexCount = jmdlEmbeddedIntArray_getCount(oPolyFaces.pIndex) ; /// do something!!! } BsplineSurface BsplineSurface의 Mesh 데이타

cloud 마크 그리기

프로젝트에서 사용할 어떤 대상의 Cloud 마크를 그리는 로직을 구상해 보았습니다. 제약 조건) 1. Cloud 마크 대상이 분리되어서는 안됩니다. (현재 분리된 대상의 경우 각각 Cloud 마크를 그릴 수는 있습니다.) 순서) 1. Cloud 마크 대상 획득 2. 대상 확대 3. 외곽선 구하기 4. Cloud 마크 표기 테스트 결과) 개선 사항) 1. 대상 확대 시 주위의 요소 고려 2. Cloud 마크 표기 루틴 개선 실제 적용 아래와 같은 CAD요소에 위의 로직을 적용시켜 보았습니다. Cloud 마크를 그리는 부분을 조금 개선해야겠습니다. (끝부분이 연결이 되지 않네요...)

Dimension 환경 설정하기

고객사로부터 아래와 같이 Dimension을 표기해 달라는 요청이 들어왔습니다. Dimension을 Dual로 표기해 달라는 것인데, 상단에는 ft-inch로 하단에는 metric으로 표기해 달라는 것이었습니다. 이렇게 표기 가능하도록 MSTN J7의 Dimension 환경 설정을 해보도록 하겠습니다. [Dimension Settings --> Units] Format을 AEC로 선택합니다. Primary Dimension 설정: -> Units을 Feet로 설정합니다. Secondary Dimension 설정: -> Show Secondary Units를 체크합니다. 이렇게 해야만 하단에 Dimension이 표기가 됩니다. -> Units을 Millimeters로 설정합니다. -> Label : 하단에 표기될 단위를 입력합니다. 입력하지 않으면 MM로 표기됩니다. 이렇게 설정하고 나서도 상단의 Dimension 단위 표기가 우리가 원하던 것과 다를 수 있습니다. 상단의 Dimension 단위 설정은 "Setting-->Design File-->Working Units"에서 하실 수 있습니다. Unit Names의 Master Units,Sub Units에서 원하는 단위를 입력하면 됩니다. 이렇게 하면 거의 원하는 Dimension 형식대로 표기할 수 있습니다. 마지막으로 하단의 Dimension을 감싸는 []표기 입니다. 이것을 Dimension Prefix,Suffix라고 하는데 이것은 "Dimension Settings-->Custom Symbols"에서 설정할 수 있습니다. 이렇게 해서 원하는 형식대로 Dimension을 표기할 수 있습니다. 주의) 결과 이미지를 보시면 하단의 Dimension Text가 []사이의 가운데에

C# 프로젝트 오픈 문제

오늘 아침 현재 진행중인 C# 프로젝트는 수정할려고 오픈했는데... 아래와 같은 메세지를 뿌리면서 VS가 오픈을 거부하는 것이 아니겠습니까? Project 'WindowsFormsApplication1' could not be opened because the Microsoft Visual C# 2008 compiler could not be created. Please re-install Visual Studio. 어제 퇴근할 때까지 멀쩡하던 것이 말입니다. 아니 곰곰히 생각해 보니 퇴근할때 컴퓨터를 종료할때 뭔 업데이트를 한다길래 업데이트를 하긴 했습니다만... 그래서 VS2008을 제거/설치를 한 2번 가량 했는데도 여전히 같은 에러를 뱉고 거부하는 것이었습니다. 그래서 구글링을 한 결과... The solution was to run "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /ResetSkipPkgs 구글신의 도움으로 문제를 해결했습니다.^^;;

VS의 intellisense가 말썽일때...(VS2005,VS2008)

제가 사용하는 VS2005의 경우 프로젝트를 오픈하고 나면 "Updating Intellisense"라는 문구가 상태바 하단에 표시되고 나서 조금 지나면 VS가 먹통이 되는 현상이 발생했습니다. 심하면 시스템 자체 먹통이 되어 버리고요... 이런 현상이 있으신 분들은 링크 로 가셔서 hotfix를 설치하시면 문제가 해결됩니다. (SP1이 미리 설치되어 있어야 합니다.)

Element 탐색하기 - 두 번째

앞서 Element를 탐색하는 방법을 알아봤는데 이번에는 또 다른 방법을 알아 보도록 하겠습니다. 이번에 알아볼 방법은 Callback함수를 이용하는 방법입니다. Callback함수를 등록시켜 놓으면 scan시 Element를 찾을때 마다 Callback함수를 호출합니다. 아래의 코드를 참조하세요 /*---------------------------------------------------------------------------------**//** author BentleySystems 03/04 +---------------+---------------+---------------+---------------+---------------+------*/ int CNeutralDataFile::ScanCallback ( MSElementDescr* pEd, void* pInfo, ScanCriteria* pScanCriteria ) { UNUSED_ALWAYS(pScanCriteria); CNeutralDataFile* pNeutralDataFile = (CNeutralDataFile*)(pInfo); pNeutralDataFile->WriteElementDescr(pEd , 0L); return SUCCESS; } /* @brief write element to file @author @date 2011.07.04 @param CStdioFile& */ void CNeutralDataFile::WriteToFile(/*CStdioFile* pStdioFile*/) { { ScanCriteria *scP = mdlScanCriteria_create (); /

SWEEP SURFACE V7 / MSTN/MDL/VBA

중국에서 Back Drawing을 만들때 Elbow 형상이 빠져서 나오지 않는다고 메일이 왔습니다. 대부분의 Elbow 형상은 회전 Surface(Surface of revolution)이었기 때문에 회전 Surface만을 처리해 왔었는데, 모델을 받아 보니 회전 Surface가 아니라 Sweep Surface였습니다. 이런 식으로도 Elbow 모델링을 하는구나 싶었습니다. 그런데 왜 이런 식으로 하는지 자세한 이유는 모르겠습니다. Ellipse두개를 Line 4개로 연결한 형상(SWEEP SURFACE)

Sheet 정보 추출하기

아래 코드를 참조하시기 바랍니다. DgnIndexItemP indexItem = NULL; DgnIndexIteratorP pIterator = mdlModelIterator_create(mdlModelRef_getDgnFile (mdlModelRef_getActive())); while(NULL != (indexItem = mdlModelIterator_getNext (pIterator))) { ModelID modelId = mdlModelItem_getModelID (indexItem); DgnModelRefP pModel = NULL; mdlModelRef_createWorking (&pModel,mdlModelRef_getDgnFile(mdlModelRef_getActive ()),modelId,TRUE,TRUE); if(mdlModelRef_isSheet (pModel)) { CDgnSheet DgnSheet(pModel); DgnSheet.GetSheetDefInfo(); //! sheet 정보를 text 파일로 출력(테스트용) DgnSheet.WriteToFile(_T("C:\\TEST.txt")); } mdlModelRef_freeWorking (pModel); } /* @brief get sheet definition @author humkyung @date 2011.07.04 **/ int CDgnSheet::GetSheetDefInfo() { if (mdlModelRef_isSheet (m_pModelRef)) { SheetDef *pSheetDef = NULL; //! sheet definition 생성(mdlSheetDef_new 함수를 통해서만 sheet definition을 생성할 수

SmartSolid에서 Surface 추출

아래의 코드를 이용해서 SmartSolid에서 Surface를 추출할수 있습니다. if(mdlKISolid_isSmartElement(pElmDescr , MASTERFILE , filePos)) { MSElementDescrP destP = NULL; mdlKISolid_beginCurrTrans(MASTERFILE); // SmartSolid를 suface 리스트를 추출 // destP에 추출한 surface 리스트가 담겨 있습니다. mdlKISolid_getSurfaceElements(&destP , pElmDescr , MASTERFILE , NULL); mdlKISolid_endCurrTrans(); WriteElementDescr(oFile , pDgnModelRef , destP , filePos , dUOR , DGNType); mdlElmdscr_freeAll (&destP); }

Problem with COM and MsExcel (Brunain Christophe)

■ 파이썬_02 [python-win32] Re: Problem with COM and MsExcel (Brunain Christophe) Niels Steen Krogh nielssteenkrogh@hotmail.com Wed, 02 Apr 2003 19:45:31 +0200 Previous message: [python-win32] Problem with COM and MsExcel Next message: [python-win32] "Casting" COM objects Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] -------------------------------------------------------------------------------- Hi! This script might help you - use CoInitialize ..... It helped me in a situation similar to yours. Good luck Niels from win32com . client import Dispatch from pythoncom import CoInitialize , CoUninitialize CoInitialize ( ) #start com thread - kan udelades, men vil mindske stabiliteten o = Dispatch ( "Excel.Application" ) #start excel o . Visible = 0 #excel k?rer i baggrunden o . Workbooks . Open ( Filename = 'c:\\dokumenter\\mappe14.xls' ) #get the workbook o . Workbooks ( 1 ) . Sheets ( 1 ) . Cells .

[python] dictionary sorting

■ 파이썬_02 [python] dictionary sorting 딕셔너리.. 맵에 데이터를 넣고 정렬할게 생겨서... 할려다 보니... 어찌해야 하나 고민이 되었습니다. 음... c++의 stl에서는 잘 되는것인데... 그래도 찾다보니 key값으로 sorting하는것은 dickeys = dic.keys() dickeys.sort() for i in dickeys: print i, dic[i] 그러면... value로 sorting 하는 방법은... diclist = [] for i in dic.keys(): diclist.append( (i, dic[i]) ) diclist.sort( key = lambda(x,y):y ) for i in diclist: print i[0], i[1] 음... 이 방법 이외에... from operator import itemgetter dict = {} dict['a'] = 2 dict['b'] = 1 dict['c'] = 5 print sorted(dict.iteritems(), key=itemgetter(1), reverse=True) 로 하게 되면... value의 값으로 정렬을 하게 된다는거... 음... python.. 쉬우면서도 어려운... ㅎㅎ

Recipe 440498: Win32com - Batch repathing of Autocad Xrefs

■ 파이썬_01 Recipe 440498: Win32com - Batch repathing of Autocad Xrefs ________________________________________ This script asks for a base directory and then changes all xrefs in all drawings in all subdirectories so that they use relative paths. To use it just copy it somewhere in your target directory structure and run. Python # Relative-refs.pyw """A short python script for repathing xrefs in Autocad.""" import win32com . client,os, os . path, tkFileDialog from Tkinter import * from tkMessageBox import askokcancel from time import sleep # Get a COM object for Autocad acad = win32com . client . Dispatch ( "AutoCAD.Application" ) def repath ( filename ) : print 'Repathing %s...' %filename doc = acad . Documents . Open ( filename ) blocks = doc . Database . Blocks # Internally xrefs are just blocks! xrefs = [ item for item in blocks if item . IsXRef]     if xrefs: for xref in x

Autocad Automation

■ 파이썬_01 Autocad Automation This example comes from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440493. It searches the ModelSpace collection for text objects. Once found it casts them and alter one of the text specific properties. To test this code AutoCAD must be started with a blank file open add at least one dtext object with 'Spam' as its value: import win32com . client acad = win32com . client . Dispatch ( "AutoCAD.Application" ) doc = acad . ActiveDocument # Document object ms = doc . ModelSpace # Modelspace "collection" count = ms . Count # Number of items in modelspace for i in range ( count ) : item = ms . Item ( i ) if 'text' in item . ObjectName . lower ( ) : # Text objects are AcDbText # once we know what it is we can cast it text = win32com . client . CastTo ( item , "IAcadText" ) if text . TextString = = "Spam"

Python

■ 파이썬_01 Nabble.addCssRule(document.styleSheets[0],'.nabble a:link','color:'+document.linkColor); Nabble.addCssRule(document.styleSheets[0],'.nabble a:visited','color:'+document.vlinkColor); if (!Nabble.isEmbedded) { document.write('Nabble | Old Nabble1'); } else if (false) { document.write('Back to the forum'); } Nabble | Old Nabble1 | Software ≫ SourceForge ≫ SWIG ≫ swig-user Login : Register Nabble.userHeader(3366); Swig Python/Autocad binding View: Threaded Chronologically All Messages Nabble.selectOption(Nabble.get("nabble.viewSelect"),Nabble.tview); New views 9 Messages ? Rating Filter: 0 1 2 3 4 5 Alert me if( Nabble.user == 799921 || Nabble.user == 77858) { document.writeln('Move thread'); } Swig Python/Autocad binding document.write(Nabble.ratingStars(3)); by document.write(' Mick Duprez document.write(''); document.write(Nabble.formatDateLong(new Date(1219651075018))); Aug 25, 20