dimensions.tcl 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Dimensions demo
  2. #
  3. # It shows capability of OCC to create different kinds
  4. # of dimensions (linear and angular) with 2D or 3D text.
  5. #Category: Visualization
  6. #Title: Dimensions in 3d viewer
  7. set aTopLoc [locate_data_file occ/Top.brep]
  8. set aBotLoc [locate_data_file occ/Bottom.brep]
  9. set aHatch [locate_data_file images/hatch_1.png]
  10. pload MODELING VISUALIZATION
  11. puts "Importing shapes..."
  12. restore $aTopLoc a
  13. restore $aBotLoc b
  14. vinit View1 w=768 h=768
  15. vclear
  16. vsetdispmode 0
  17. vbackground -color WHITE
  18. vbottom
  19. puts "Getting cut projection..."
  20. box bb -150 -250 0 150 250 100
  21. bsection bs b bb
  22. bsection as a bb
  23. vdisplay bs as
  24. vfit
  25. set anAEdges [explode as E]
  26. set aBEbges [explode bs E]
  27. set anArrAngle [expr 3.14 * 12.0 / 180.0]
  28. # Form dimension names list to set parameters with vdimparam command
  29. set aList {rd_1 rd_2 ad_1 ad_2 ad_3}
  30. for {set i 1} {$i <= 10} {incr i} { lappend aList ld_$i }
  31. puts "Creating dimensions..."
  32. vdimension ld_1 -length -shapes bs_27 -plane xoy -color black -flyout -15
  33. vdimension ld_2 -length -shapes bs_14 -plane xoy -color black -flyout 15
  34. vdimension ld_3 -length -shapes bs_28 -plane xoy -color black -label right -flyout -27
  35. vdimension ld_4 -length -shapes as_7 -plane xoy -color black -flyout -20
  36. vdimension ld_5 -length -shapes as_28 -plane xoy -color black -flyout -15
  37. vdimension ld_6 -length -shapes as_18 -plane xoy -color black -flyout 30
  38. vdimension ld_7 -length -shapes bs_20 -plane xoy -color black -flyout -20
  39. vdimension ld_8 -length -shapes as_42 -plane xoy -color black -flyout 55 -label right
  40. vdimension ld_9 -length -shapes as_12 -plane xoy -color black -flyout 35 -label right
  41. vdimension ld_10 -length -shapes as_40 -plane xoy -color black -flyout 15
  42. vdimension rd_1 -radius -shapes bs_45 -color black -label right
  43. vdimension rd_2 -radius -shapes bs_63 -color black
  44. vdimension ad_1 -angle -shapes as_38 as_49 -color black
  45. vdimension ad_2 -angle -shapes bs_24 bs_25 -color black
  46. vdimension ad_3 -angle -shapes as_48 as_42 -color black
  47. puts "Changing text and arrow parameters of dimensions..."
  48. foreach i $aList {
  49. vdimparam $i -text 3d sh 6 -arrowlength 4 -arrowangle $anArrAngle
  50. }
  51. vfit
  52. puts "Displaying exported shapes..."
  53. vdisplay -dispMode 1 a b
  54. vaspects a -setmaterial steel
  55. vaspects b -setmaterial bronze
  56. puts "Clipping shapes for better view..."
  57. vclipplane pa -set a -equation 0 0 1 0 -capping on -color GRAY90 -texName $aHatch -texScale 0.05 -0.05
  58. vclipplane pb -set b -equation 0 0 1 0 -capping on -color GOLD -texName $aHatch -texScale 0.05 -0.05
  59. vbottom
  60. vrotate -0.3 -0.3 0
  61. vfit
  62. vzoom 1.2
  63. vrenderparams -msaa 8
  64. puts "Done."