$$345678901234567890123456789012345678901234567890123456789012345678901234567890 $$ 1 2 3 4 5 6 7 8 $$ $$ ut_extr_edges.grs Extract max. 99 edges, section 'edges' or general curves $$ to the drawing. $$ Use in drawing application only. Usable to set align geo- $$ metry onto the drafting area or for creating developed $$ views. $$ $$ V1.00 / PyraSol / 17.11.97 First public release. $$ V1.01 / PyraSol / 23.12.97 Fixed a positioning problem that sometimes $$ occured. Added a 'fit' operation before $$ moving the edges to the final position. $$ V1.02 / PyraSol / 11.09.98 Added on top of main part a check, if exe- $$ cution is on drawing or not. $$ V1.03 / PyraSol / 15.02.00 Extended the max. amount of entities from $$ 10 to 99. $$ V2.00 / PyraSol / 16.02.00 Changed selection of the destination view $$ from the menu to an interactive screen $$ selection. $$ V3.00 / PyraSol / 17.02.00 Added extraction of section 'edges' and $$ general curves (and redesigned the whole $$ program code). $$ V3.01 / PyraSol / 25.05.00 Added a note to the info window to inform $$ the user about a position problem using $$ the 'automatic view border' setting. $$ V3.02 / PyraSol / 28.06.00 Added a note to the info window to inform $$ the user about the restriction for plane $$ sections only. $$ V3.10 / PyraSol / 16.09.03 Changed the code to bi- lang (en/de) and $$ removed the mode 'section edge' (because $$ this mode was difficult for the user). $$ $$ $$ $$ $$ ***************************** $$ * Declaration of variables: * $$ ***************************** $$ $$ Index: o = object variable $$ n = numerical variable $$ s = string variable $$ GRIPSW/DECLRV $$ ENTITY/oObjects(100),oCrvs(100) NUMBER/nLength,nI,nChar,nLang,nDstate NUMBER/nNum1,nNum2,nCrsMd,nResp,nMode,nA,nB,nC,nMVSel,nI_crvs NUMBER/nRefPts(50,2),nOMatView(9),nVX,nVY,nVZ,nVScale NUMBER/nMatRot(12),nOMatDelta(9),nMatDelta(9),nDX,nDY NUMBER/nMatTl(12),nMatScale(12),nMatTf(12),nJump STRING/sLang(16),sLoCase(1),sUpCase(1),sDrwName(30) STRING/sMVNames(50,30),sMenuTxt(4,40),sMVSel(30) STRING/sTxt01(60),sTxt02(60) $$ $$ $$ $$ ************ $$ * Program: * $$ ************ $$ $$ Prepare $$ ======= $$ Check the language setting for the user interaction $$ (Supportet in this program: ENGLISH, GERMAN) $$ --------------------------------------------------- sLang=&LANG $$ Change the whole string to upper case characters nLength=LENF(sLang) DO/EDo01P:,nI,1,nLength,1 nChar=ASCII(sLang,nI) IFTHEN/nChar>=97 AND nChar<=122 sLoCase=CHRSTR(nChar) nChar=nChar-32 sUpCase=CHRSTR(nChar) sLang=REPSTR(sLang,sLoCase,sUpCase,nI) ENDIF EDo01P: $$ $$ Set a control value to switch to the current language IFTHEN/sLang=='GERMAN' nLang=1 ELSE nLang=0 ENDIF $$ $$ $$ Check, if drafting application module is active with drafting mode $$ ------------------------------------------------------------------ $$ First, check if drafting application is active and drawing display is on nDstate=&DSTATE IFTHEN/nDstate<>2 IFTHEN/nLang==1 sTxt01='Funktioniert nur im Zeichnungs- Modus' ELSE sTxt01='Works in DRAFTING MODE only' ENDIF MESSG/sTxt01 JUMP/End: ENDIF $$ $$ Second, check for existing drawing name(s) sDrwName=&CURDRW IFTHEN/sDrwName=='' IFTHEN/nLang==1 sTxt01='Keine Zeichnung gefunden' ELSE sTxt01='No drawing found' ENDIF MESSG/sTxt01 JUMP/End: ENDIF $$ $$ Third, check if in EXPAND mode (if yes, switch to UNEXPAND and perform a $$ display fit) IFTHEN/&EXPAND<>'OFF' &EXPAND='OFF' ENDIF VIEWE/AUTO $$ $$ $$ $$ Main $$ ==== $$ Get drawing informations (member view names, number of views) and check $$ if there are not too many views on drawing (max. 50) $$ ----------------------------------------------------------------------- DRAWV/sMVNames,,nNum1,IFERR,Err01M: IF/nNum1>50,JUMP/Err02M: $$ $$ Save current cursor mode and set the cursor to select in any view nCrsMd=&VWCURS &VWCURS=&ANY $$ $$ $$ Create a menu to select the extraction mode or a help text $$ ---------------------------------------------------------- Ret01M: IFTHEN/nLang==1 sTxt01='Extrahieren...' sMenuTxt(1)='Kanten' sMenuTxt(2)='Allgemeine Kurven' sMenuTxt(4)='Programm- Info' ELSE sTxt01='Extract...' sMenuTxt(1)='Edges' sMenuTxt(2)='General Curves' sMenuTxt(4)='Program Info' ENDIF sMenuTxt(3)='-' CHOOSE/sTxt01,sMenuTxt,nResp $$ 1=Back / 2=Cancel / 3= / 4= / 5=Option 1 / 6=Option 2 etc. JUMP/Cln03S:,Cln03S:,,,Nxt02M:,Nxt02M:,,Nxt01M:,nResp $$ $$ Nxt01M: $$ $$ Display help text $$ ----------------- IFTHEN/nLang==1 PRINT/'Extract Edges V3.10 / 16.09.03 / PyraSol' PRINT/'----------------------------------------' PRINT/'' PRINT/'Mit diesem Programm lassen sich Kanten oder allgemeine Kurven' PRINT/'aus einer beliebigen Ansicht auf die Zeichnung selber extrahieren.' PRINT/'' PRINT/'Kanten: Auswahl von beliebigen Kanten eines Körpers einer' PRINT/' beliebigen Ansicht.' PRINT/'Allgemeine Kurven: Auswahl von beliebigen zuvor erzeugten Kurven.' PRINT/'' PRINT/'' PRINT/'Hinweis: Manchmal erscheinen die extrahierten Kanten oder Kurven' PRINT/' nicht auf der korrekten Position. Dies ist ein Fehler in' PRINT/' der automatischen Ansichtenbegrenzungs- Funktion von UG.' PRINT/' Um dieses Problem zu umgehen, kann man manuell definierte' PRINT/' Ansichtenbegrenzungen verwenden.' PRINT/'' PRINT/'' ELSE PRINT/'Extract Edges V3.10 / 16.09.03 / PyraSol' PRINT/'----------------------------------------' PRINT/'' PRINT/'This tool allows to extract edges or general curves from any view on' PRINT/'a drawing to the drawing itself.' PRINT/'' PRINT/'Edges: Select any edges of a body in any view.' PRINT/'General Curves: Select any pre created curves.' PRINT/'' PRINT/'' PRINT/'Note: Sometimes the extracted edges or curves does not appear on the' PRINT/' correct position. This is a bug in the automatic view border' PRINT/' function of UG. To avoid this problem, use manually defined' PRINT/' view borders.' PRINT/'' PRINT/'' ENDIF JUMP/Ret01M: $$ $$ Nxt02M: $$ $$ Interactive selection of the destination view $$ --------------------------------------------- $$ Mode: Edges = 1; Curves = 2 nMode=nResp-4 $$ $$ View selection Ret02M: IFTHEN/nLang==1 sTxt01='Ansicht auswählen' ELSE sTxt01='Select a view' ENDIF POS/sTxt01,nA,nB,nC,nResp $$ 1=Back / 2=Cancel / 3= / 4= / 5=Done JUMP/Ret01M:,Cln03S:,nResp sMVSel=&VWSEL $$ $$ Check if an existing view is selected nMVSel=0 DO/EDo01M:,nI,1,nNum1,1 IFTHEN/sMVSel==sMVNames(nI) nMVSel=nI nI=nNum1 ENDIF EDo01M: IFTHEN/nMVSel==0 IFTHEN/nLang==1 sTxt01='Keine Ansicht gefunden, nochmals probieren' ELSE sTxt01='No view found, try again' ENDIF MESSG/TEMP,sTxt01 JUMP/Ret02M: ENDIF $$ $$ $$ Change selected view to EXPAND and jump to selected mode of extraction $$ ---------------------------------------------------------------------- &EXPAND=sMVSel $$ JUMP/Edges:,Curves:,nMode $$ $$ Edges: $$ $$ Extraction of edges $$ ------------------- $$ Mask for edges only MASK/72 $$ $$ Prompt the user to select max. 99 edges Ret03M: IFTHEN/nLang==1 sTxt01='Max. 99 Kanten auswählen' ELSE sTxt01='Select max. 99 edges' ENDIF IDENT/sTxt01,oObjects,CNT,nNum2,nResp IFTHEN/nNum2>99 IFTHEN/nLang==1 sTxt01='Zu viele Kanten ausgewählt' ELSE sTxt01='Too many edges selected' ENDIF MESSG/sTxt01 JUMP/Ret03M: ENDIF $$ 1=Back / 2=Cancel / 3=OK JUMP/Ret03M:,Cln02S:,nResp $$ $$ Extract the edges DO/EDo02M:,nI_crvs,1,nNum2,1 oCrvs(nI_crvs)=SOLEDG/oObjects(nI_crvs),IFERR,Err03M: EDo02M: JUMP/Nxt03M: $$ $$ Curves: $$ $$ Extraction of curves $$ -------------------- $$ Mask for curves (and points) only MASK/2,3,5,6,9 $$ $$ Prompt the user to select max. 99 curves Ret04M: IFTHEN/nLang==1 sTxt01='Max. 99 Kurven auswählen' ELSE sTxt01='Select max. 99 curves' ENDIF IDENT/sTxt01,oObjects,CNT,nNum2,nResp IFTHEN/nNum2>99 IFTHEN/nLang==1 sTxt01='Zu viele Kurven ausgewählt' ELSE sTxt01='Too many curves selected' ENDIF MESSG/sTxt01 JUMP/Ret04M: ENDIF $$ 1=Back / 2=Cancel / 3=OK JUMP/Ret04M:,Cln02S:,nResp $$ $$ Extract the curves DO/EDo03M:,nI_crvs,1,nNum2,1 oCrvs(nI_crvs)=oObjects(nI_crvs) EDo03M: JUMP/Nxt03M: $$ $$ Nxt03M: $$ $$ Convert the curves to model dependent VDEDIT/oCrvs,MODEL $$ $$ $$ Change view to UNEXPAND $$ ----------------------- &EXPAND='OFF' $$ $$ Perform a 'fit' operation to the working view (to avoid positioning problems $$ moving the curves to the final position) IFTHEN/nLang==1 sTxt01='Die Bildschirmanzeige darf nicht verändert' sTxt02='werden bis diese Extraktion fertig ist!' ELSE sTxt01='Do not change the screen display until completion' sTxt02='of this extraction!' ENDIF MESSG/sTxt01,sTxt02 VIEWE/AUTO $$ $$ Convert the curves to view dependent (means to drawing) VDEDIT/oCrvs,VIEW $$ $$ $$ Calculate the translation matrix and move the curves to the drawing position $$ ---------------------------------------------------------------------------- $$ Get drawing informations (view reference points) DRAWV/,nRefPts,IFERR,Err04M: $$ $$ Get the view informations (orientation matrix, coordinates of the view cen- $$ ter, projection type, drawing scale) VIEWV/sMVSel,nOMatView,,,nVX,nVY,nVZ,,,,,,,,,,nVScale,IFERR,Err05M: $$ $$ Transform the curves to the choosen view position $$ 1st: Specify the rotation matrix with the 12 elements nMatRot(1)=nOMatView(1) nMatRot(2)=nOMatView(2) nMatRot(3)=nOMatView(3) nMatRot(4)=0.0 nMatRot(5)=nOMatView(4) nMatRot(6)=nOMatView(5) nMatRot(7)=nOMatView(6) nMatRot(8)=0.0 nMatRot(9)=nOMatView(7) nMatRot(10)=nOMatView(8) nMatRot(11)=nOMatView(9) nMatRot(12)=0.0 $$ $$ 2nd: Specify the translation matrix $$ -> Specify the delta orientation matrix nOMatDelta(1)=nVX*(-1) nOMatDelta(2)=0.0 nOMatDelta(3)=0.0 nOMatDelta(4)=0.0 nOMatDelta(5)=nVY*(-1) nOMatDelta(6)=0.0 nOMatDelta(7)=0.0 nOMatDelta(8)=0.0 nOMatDelta(9)=nVZ*(-1) $$ -> Multiplication of 'nOMatDelta' with 'nOMatView' nMatDelta(1)=nOMatDelta(1)*nOMatView(1)+nOMatDelta(4)*nOMatView(2)+$ nOMatDelta(7)*nOMatView(3) nMatDelta(2)=nOMatDelta(2)*nOMatView(1)+nOMatDelta(5)*nOMatView(2)+$ nOMatDelta(8)*nOMatView(3) nMatDelta(3)=nOMatDelta(3)*nOMatView(1)+nOMatDelta(6)*nOMatView(2)+$ nOMatDelta(9)*nOMatView(3) nMatDelta(4)=nOMatDelta(1)*nOMatView(4)+nOMatDelta(4)*nOMatView(5)+$ nOMatDelta(7)*nOMatView(6) nMatDelta(5)=nOMatDelta(2)*nOMatView(4)+nOMatDelta(5)*nOMatView(5)+$ nOMatDelta(8)*nOMatView(6) nMatDelta(6)=nOMatDelta(3)*nOMatView(4)+nOMatDelta(6)*nOMatView(5)+$ nOMatDelta(9)*nOMatView(6) nMatDelta(7)=nOMatDelta(1)*nOMatView(7)+nOMatDelta(4)*nOMatView(8)+$ nOMatDelta(7)*nOMatView(9) nMatDelta(8)=nOMatDelta(2)*nOMatView(7)+nOMatDelta(5)*nOMatView(8)+$ nOMatDelta(8)*nOMatView(9) nMatDelta(9)=nOMatDelta(3)*nOMatView(7)+nOMatDelta(6)*nOMatView(8)+$ nOMatDelta(9)*nOMatView(9) $$ -> Addition of the columns 1 and 2 of the resulting multiplication matrix nDX=nMatDelta(1)+nMatDelta(2)+nMatDelta(3) nDY=nMatDelta(4)+nMatDelta(5)+nMatDelta(6) $$ -> Specify the translation matrix nMatTl=MATRIX/TRANSL,(nRefPts(nMVSel,1)+nVScale*nDX),(nRefPts(nMVSel,2)+$ nVScale*nDY),0.0 $$ $$ 3rd: Specify the scaling matrix nMatScale=MATRIX/SCALE,nVScale $$ $$ 4th: Calculate the transforming matrix nMatTf=MATRIX/nMatRot,nMatScale nMatTf=MATRIX/nMatTf,nMatTl $$ $$ 5th: Perform the transformation to the choosen view DO/EDo04M:,nI,1,nI_crvs,1 oCrvs(nI)=TRANSF/nMatTF,oCrvs(nI),MOVE EDo04M: $$ $$ JUMP/Cln03S: $$ $$ $$ $$ *************** $$ * Submodules: * $$ *************** $$ $$ Error messages $$ ============== Err01M: IFTHEN/nLang==1 sTxt01='Fehler beim Auslesen der Zeichnungsparameter' ELSE sTxt01='Error getting the drawing parameters' ENDIF MESSG/sTxt01 JUMP/End: $$ $$ Err02M: IFTHEN/nLang==1 sTxt01='Zu viele Ansichten auf der Zeichnung, max. 50 unterstützt' ELSE sTxt01='Too many views on the drawing, max. 50 views supported' ENDIF MESSG/sTxt01 JUMP/End: $$ $$ Err03M: IFTHEN/nLang==1 sTxt01='Fehler beim Extrahieren der Kante '+ISTR(nI_crvs) ELSE sTxt01='Error extracting the edge '+ISTR(nI_crvs) ENDIF MESSG/sTxt01 nJump=3 JUMP/Cln01S: $$ $$ Err04M: IFTHEN/nLang==1 sTxt01='Fehler beim Auslesen der Ansichtsreferenzpunkte' ELSE sTxt01='Error getting the view reference points' ENDIF MESSG/sTxt01 nJump=6 JUMP/Cln01S: $$ $$ Err05M: IFTHEN/nLang==1 sTxt01='Fehler beim Auslesen der Ansichtsparameter' ELSE sTxt01='Error getting the view parameters' ENDIF MESSG/sTxt01 nJump=6 JUMP/Cln01S: $$ $$ $$ $$ Clean up $$ ======== Cln01S: $$ Delete the created curves DO/EDo02S:,nI,1,nI_crvs,1 DELETE/oCrvs(nI) EDo02S: JUMP/Ret01M:,Ret02M:,Ret03M:,Ret04M:,Cln03S:,nJump $$ $$ Cln02S: $$ Change to UNEXPAND &EXPAND='OFF' $$ $$ Cln03S: $$ Reset the cursor mode &VWCURS=nCrsMd JUMP/End: $$ $$ $$ $$ ******** $$ * End: * $$ ******** $$ End: HALT