2005-11-24 20:34:00 +05:00
|
|
|
<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
|
|
|
|
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>Measurement Tools</title>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
|
|
|
|
<meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com">
|
|
|
|
<link rel="stylesheet" href="default_ns.css"><script type="text/javascript" language="JavaScript" title="WebHelpSplitCss">
|
|
|
|
<!--
|
|
|
|
if (navigator.appName !="Netscape")
|
|
|
|
{ document.write("<link rel='stylesheet' href='default.css'>");}
|
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
|
|
<!--
|
|
|
|
p.whs1 { font-family:'Lucida Console' , monospace; }
|
|
|
|
p.whs2 { font-family:'Times New Roman' , serif; }
|
|
|
|
-->
|
|
|
|
</style><script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
|
|
|
|
<!--
|
|
|
|
function reDo() {
|
|
|
|
if (innerWidth != origWidth || innerHeight != origHeight)
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
|
|
|
|
origWidth = innerWidth;
|
|
|
|
origHeight = innerHeight;
|
|
|
|
onresize = reDo;
|
|
|
|
}
|
|
|
|
onerror = null;
|
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
|
|
<!--
|
|
|
|
div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
|
|
|
|
-->
|
|
|
|
</style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
|
|
|
|
<script type="text/javascript" language="javascript" src="whver.js"></script>
|
|
|
|
<script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
|
|
|
|
<script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
|
|
|
|
<script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
|
|
|
|
</head>
|
|
|
|
<body><script type="text/javascript" language="javascript1.2">
|
|
|
|
<!--
|
|
|
|
if (window.gbWhTopic)
|
|
|
|
{
|
|
|
|
if (window.addTocInfo)
|
|
|
|
{
|
|
|
|
addTocInfo("GEOM module\nTUI Scripts\nMeasurement Tools");
|
|
|
|
addButton("show",BTN_TEXT,"Show","","","","",0,0,"","","");
|
|
|
|
|
|
|
|
}
|
|
|
|
if (window.writeBtnStyle)
|
|
|
|
writeBtnStyle();
|
|
|
|
|
|
|
|
if (window.writeIntopicBar)
|
|
|
|
writeIntopicBar(1);
|
|
|
|
|
|
|
|
if (window.setRelStartPage)
|
|
|
|
{
|
|
|
|
setRelStartPage("geom.htm");
|
|
|
|
|
|
|
|
autoSync(1);
|
|
|
|
sendSyncInfo();
|
|
|
|
sendAveInfoOut();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (window.gbIE4)
|
|
|
|
document.location.reload();
|
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
<h1>Measurement Tools</h1>
|
|
|
|
|
|
|
|
<h3>Point Coordinates</h3>
|
|
|
|
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
<p># create a point</p>
|
|
|
|
|
|
|
|
<p class="whs1">point = geompy.MakeVertex(15,
|
|
|
|
23, 80)</p>
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
2006-02-07 20:58:35 +05:00
|
|
|
<p># get the coordinates of the point and check its values</p>
|
2005-11-24 20:34:00 +05:00
|
|
|
|
|
|
|
<p class="whs1">coords = geompy.PointCoordinates(point)</p>
|
|
|
|
|
|
|
|
<p class="whs1">if coords[0] != 15
|
|
|
|
or coords[1] != 23 or coords[2] != 80 :</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
"Coordinates of point must be (15, 23, 80), but returned (",
|
|
|
|
coords[0], ", ", coords[1], ", ", coords[2], ")"</p>
|
|
|
|
|
|
|
|
<p class="whs1">else :</p>
|
|
|
|
|
|
|
|
<p><span style="font-family: 'Lucida Console', monospace;"> print
|
|
|
|
"All values are OK."</span> </p>
|
|
|
|
|
|
|
|
<h3>Basic Properties</h3>
|
|
|
|
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
<p># create a box</p>
|
|
|
|
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">props = geompy.BasicProperties(box)</p>
|
|
|
|
|
|
|
|
<p class="whs1">print "\nBox
|
|
|
|
100x30x100 Basic Properties:"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Wires
|
|
|
|
length: ", props[0]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Surface
|
|
|
|
area: ", props[1]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Volume
|
|
|
|
:
|
|
|
|
", props[2]</p>
|
|
|
|
|
|
|
|
<p class="whs1">length = math.sqrt((props[0]
|
|
|
|
- 1840)*(props[0] - 1840))</p>
|
|
|
|
|
|
|
|
<p class="whs1">area = math.sqrt((props[1]
|
|
|
|
- 32000)*(props[1] - 32000))</p>
|
|
|
|
|
|
|
|
<p class="whs1">volume = math.sqrt((props[2]
|
|
|
|
- 300000)*(props[2] - 300000))</p>
|
|
|
|
|
|
|
|
<p class="whs1">if length > 1e-7
|
|
|
|
or area > 1e-7 or volume > 1e-7:</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
"While must be:"</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
" Wires length: ", 1840</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
" Surface area: ", 32000</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
" Volume :
|
|
|
|
", 300000.</p>
|
|
|
|
|
|
|
|
<h3>Center of masses</h3>
|
|
|
|
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">cm = geompy.MakeCDG(box)</p>
|
|
|
|
|
|
|
|
<p class="whs1">if cm is None:</p>
|
|
|
|
|
|
|
|
<p class="whs1"> raise
|
|
|
|
RuntimeError, "MakeCDG(box) failed"</p>
|
|
|
|
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
"\nCentre of gravity of box has been successfully obtained:"</p>
|
|
|
|
|
|
|
|
<p class="whs1"> coords
|
|
|
|
= geompy.PointCoordinates(cm)</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
"(", coords[0], ", ", coords[1], ", ", coords[2],
|
|
|
|
")"</p>
|
|
|
|
|
|
|
|
<p class="whs1"> dx
|
|
|
|
= math.sqrt((coords[0] - 50)*(coords[0] - 50))</p>
|
|
|
|
|
|
|
|
<p class="whs1"> dy
|
|
|
|
= math.sqrt((coords[1] - 15)*(coords[1] - 15))</p>
|
|
|
|
|
|
|
|
<p class="whs1"> dz
|
|
|
|
= math.sqrt((coords[2] - 50)*(coords[2] - 50))</p>
|
|
|
|
|
|
|
|
<p class="whs1"> if
|
|
|
|
dx > 1e-7 or dy > 1e-7 or dz > 1e-7:</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
"But must be (50, 15, 50)" </p>
|
|
|
|
|
|
|
|
<h3>Inertia</h3>
|
|
|
|
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
|
|
|
|
<p class="whs1">import math</p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">In = geompy.Inertia(box)</p>
|
|
|
|
|
|
|
|
<p class="whs1">print "\nInertia
|
|
|
|
matrix of box 100x30x100:"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " (",
|
|
|
|
In[0], ", ", In[1], ", ", In[2], ")"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " (",
|
|
|
|
In[3], ", ", In[4], ", ", In[5], ")"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " (",
|
|
|
|
In[6], ", ", In[7], ", ", In[8], ")"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print "Main moments
|
|
|
|
of inertia of box 100x30x100:"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Ix =
|
|
|
|
", In[9], ", Iy = ", In[10], ", Iz = ", In[11]
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<h3>Bounding Box</h3>
|
|
|
|
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">bb = geompy.BoundingBox(box)</p>
|
|
|
|
|
|
|
|
<p class="whs1">print "\nBounding
|
|
|
|
Box of box 100x30x100:"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Xmin
|
|
|
|
= ", bb[0], ", Xmax = ", bb[1]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Ymin
|
|
|
|
= ", bb[2], ", Ymax = ", bb[3]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Zmin
|
|
|
|
= ", bb[4], ", Zmax = ", bb[5] </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<h3>Minimal Distance </h3>
|
|
|
|
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
|
|
geompy</span></p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs2"># create boxes</p>
|
|
|
|
|
|
|
|
<p class="whs1">box1 = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">box2 = geompy.MakeBox(105,0,0,200,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">min_dist = geompy.MinDistance(box1,box2)</p>
|
|
|
|
|
|
|
|
<p class="whs1">print "\nMinimal
|
|
|
|
distance between box1 and box2 = ", min_dist </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<h3>Tolerance</h3>
|
|
|
|
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
|
|
geompy</span></p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">Toler = geompy.Tolerance(box)</p>
|
|
|
|
|
|
|
|
<p class="whs1">print "\nBox
|
|
|
|
100x30x100 tolerance:"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Face
|
|
|
|
min. tolerance: ", Toler[0]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Face
|
|
|
|
max. tolerance: ", Toler[1]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Edge
|
|
|
|
min. tolerance: ", Toler[2]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Edge
|
|
|
|
max. tolerance: ", Toler[3]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Vertex
|
|
|
|
min. tolerance: ", Toler[4]</p>
|
|
|
|
|
|
|
|
<p class="whs1">print " Vertex
|
|
|
|
max. tolerance: ", Toler[5] </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<h3>What Is</h3>
|
|
|
|
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
|
|
geompy</span></p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">Descr = geompy.WhatIs(box)</p>
|
|
|
|
|
|
|
|
<p class="whs1">print "\nBox
|
|
|
|
100x30x100 description:"</p>
|
|
|
|
|
|
|
|
<p class="whs1">print Descr </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<h3>Check Shape</h3>
|
|
|
|
|
|
|
|
<p class="whs1">import geompy</p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs2"># create a box</p>
|
|
|
|
|
|
|
|
<p class="whs1">box = geompy.MakeBoxDXDYDZ(100,30,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">IsValid = geompy.CheckShape(box)</p>
|
|
|
|
|
|
|
|
<p class="whs1">if IsValid == 0:</p>
|
|
|
|
|
|
|
|
<p class="whs1"> raise
|
|
|
|
RuntimeError, "Invalid box created"</p>
|
|
|
|
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
"\nBox is valid" </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<h3>Check Compound of Blocks</h3>
|
|
|
|
|
|
|
|
<p class="whs1"><span style="font-family: 'Lucida Console', monospace;">import
|
|
|
|
geompy</span></p>
|
|
|
|
|
|
|
|
<p class="whs1">import salome</p>
|
|
|
|
|
|
|
|
<p class="whs1">gg = salome.ImportComponentGUI("GEOM")</p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs2"># create boxes</p>
|
|
|
|
|
|
|
|
<p class="whs1">box1 = geompy.MakeBox(0,0,0,100,50,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1">box2 = geompy.MakeBox(100,0,0,250,50,100)</p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
2006-02-07 20:58:35 +05:00
|
|
|
<p class="whs2"># make a compound</p>
|
2005-11-24 20:34:00 +05:00
|
|
|
|
|
|
|
<p class="whs1">compound = geompy.MakeCompound([box1,
|
|
|
|
box2])</p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
2006-02-07 20:58:35 +05:00
|
|
|
<p class="whs2"># glue the faces of the
|
|
|
|
compound</p>
|
2005-11-24 20:34:00 +05:00
|
|
|
|
|
|
|
<p class="whs1">tolerance = 1e-5</p>
|
|
|
|
|
|
|
|
<p class="whs1">glue = geompy.MakeGlueFaces(compound,
|
|
|
|
tolerance)</p>
|
|
|
|
|
|
|
|
<p class="whs1">IsValid = geompy.CheckCompoundOfBlocks(glue)</p>
|
|
|
|
|
|
|
|
<p class="whs1">if IsValid == 0:</p>
|
|
|
|
|
|
|
|
<p class="whs1"> raise
|
|
|
|
RuntimeError, "Invalid compound created"</p>
|
|
|
|
|
|
|
|
<p class="whs1">else:</p>
|
|
|
|
|
|
|
|
<p class="whs1"> print
|
|
|
|
"\nCompound is valid" </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<p class="whs1"> </p>
|
|
|
|
|
|
|
|
<script type="text/javascript" language="javascript1.2">
|
|
|
|
<!--
|
|
|
|
if (window.writeIntopicBar)
|
|
|
|
writeIntopicBar(0);
|
|
|
|
//-->
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|