<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Read exact object-location in FlexSim by code? in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557531#M60789</link>
    <description>&lt;P&gt;If you're print the locations of fixed resources, the print() command is sufficient:&lt;/P&gt;&lt;PRE&gt;print(current.location.x);&lt;/PRE&gt;&lt;P&gt;Or to get the center location of the object&lt;/P&gt;&lt;PRE&gt;print(current.getLocation(0.5, 0.5, 0));&lt;/PRE&gt;&lt;P&gt;If you're trying to print the locations of flowitems or task executers that are moving around in your model, you'll need to call updatelocations() first.&lt;/P&gt;&lt;PRE&gt;updatelocations(item);
print(item.location.x);
//or
print(item.getLocation(0.5, 0.5, 0));&lt;/PRE&gt;</description>
    <pubDate>Thu, 28 Sep 2017 19:37:39 GMT</pubDate>
    <dc:creator>matt_long</dc:creator>
    <dc:date>2017-09-28T19:37:39Z</dc:date>
    <item>
      <title>Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557528#M60786</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 17.2.2 ]&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Hello Community,&lt;/P&gt;
&lt;P&gt;I'm working with a SQL Database which collects nearly all information from a FlexSim model. I want to write all spatial data from the treenode of an object to the database. The problem now is that the suggested command by the "sample-tool" in FlexSim just delivers an integer. So a x-location like 3.25 is saved as just 3. Is there any other method of reading the spatial data from FlexSim as maybe a float?&lt;/P&gt;
&lt;P&gt;The command I used is: &lt;/P&gt;
&lt;PRE&gt;pd(current.as(Object).location.x);&lt;/PRE&gt;
&lt;P&gt;Regards Robin&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 16:02:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557528#M60786</guid>
      <dc:creator>robin_brunner</dc:creator>
      <dc:date>2017-09-28T16:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557529#M60787</link>
      <description>&lt;PRE&gt;pf(current.as(Object).location.x);&lt;/PRE&gt;&lt;P&gt;pd( ) prints into the output only discrete values. That is obviously an integer value.&lt;/P&gt;&lt;P&gt;pf( ) prints floating values.&lt;/P&gt;&lt;P&gt;And if you use print( ), it is the actual command to print  values of different types into the output. &lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 16:15:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557529#M60787</guid>
      <dc:creator>joerg_vogel_HsH</dc:creator>
      <dc:date>2017-09-28T16:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557530#M60788</link>
      <description>&lt;P&gt;Oh sorry, you are right. pf(&lt;A rel="nofollow" href="http://current.as"&gt;current.as&lt;/A&gt;(Object).location.x) prints out the exact location value. My fault.&lt;/P&gt;
&lt;P&gt;Well then there is a problem with converting this number to a string.&lt;/P&gt;
&lt;P&gt;EDIT: Okay, forgot to set the numtostring precision! Now everything works. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2017 16:29:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557530#M60788</guid>
      <dc:creator>robin_brunner</dc:creator>
      <dc:date>2017-09-28T16:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557531#M60789</link>
      <description>&lt;P&gt;If you're print the locations of fixed resources, the print() command is sufficient:&lt;/P&gt;&lt;PRE&gt;print(current.location.x);&lt;/PRE&gt;&lt;P&gt;Or to get the center location of the object&lt;/P&gt;&lt;PRE&gt;print(current.getLocation(0.5, 0.5, 0));&lt;/PRE&gt;&lt;P&gt;If you're trying to print the locations of flowitems or task executers that are moving around in your model, you'll need to call updatelocations() first.&lt;/P&gt;&lt;PRE&gt;updatelocations(item);
print(item.location.x);
//or
print(item.getLocation(0.5, 0.5, 0));&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2017 19:37:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557531#M60789</guid>
      <dc:creator>matt_long</dc:creator>
      <dc:date>2017-09-28T19:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557532#M60790</link>
      <description>&lt;P&gt;Okay I got a new problem now! The exact location of the spatial treenode can be read and written into a SQL database now. I figured out that the spatial treenode gives information about the measuring point coordinates in a lower corner of the bounding box. When there is no rotation added to the object, the measuring point coordinates and the ones of the spatial treenode match. But if I add some rotation to the object, the coordinates begin to differ. I added two screenshots, so you can see what I mean.&lt;/P&gt;
&lt;P&gt;I need the corrected coordinates now (which are shown in the "Quick Properties" tab). When there is no way to get these coordinates read by code, then someone has a code snippet for a general rotation matrix to calculate the new coordinates?&lt;/P&gt;
&lt;P&gt;no rotation - no problem&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="8908-norotating-noproblem.jpg"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1496098iCD6C2F3268EAD6B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="8908-norotating-noproblem.jpg" alt="8908-norotating-noproblem.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;rotation - problem&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="8909-rotating-problem.jpg"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1496099iB2D1A1743ED1C2AB/image-size/large?v=v2&amp;amp;px=999" role="button" title="8909-rotating-problem.jpg" alt="8909-rotating-problem.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 14:27:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557532#M60790</guid>
      <dc:creator>robin_brunner</dc:creator>
      <dc:date>2017-09-29T14:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557533#M60791</link>
      <description>&lt;P&gt;Matt answered this question above. Use the Object.getLocation() command to get a location relative to any point along the object instead of its direct spatial location.&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;PRE&gt;current.getLocation(0.5, 0.5, 0)&lt;/PRE&gt;&lt;P&gt;gets the location of the bottom-center point on the object (50% along the x-axis, 50% along the y-axis, and 0% along the z-axis).&lt;/P&gt;&lt;P&gt;To get the bottom-corner position of the object, use:&lt;/P&gt;&lt;PRE&gt;current.getLocation(0, 0, 0)&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Sep 2017 14:30:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557533#M60791</guid>
      <dc:creator>philboboADSK</dc:creator>
      <dc:date>2017-09-29T14:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557534#M60792</link>
      <description>&lt;P&gt;Sorry, didn't mentioned that with this command you can get those values. So SQL can't store Vector3 data. How can I convert the Vector3 to three floats?&lt;/P&gt;
&lt;P&gt;By the way, print( ... ) doesn't work in FlexSim 2017 Update 2. "Command unknown". : /&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 14:55:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557534#M60792</guid>
      <dc:creator>robin_brunner</dc:creator>
      <dc:date>2017-09-29T14:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557535#M60793</link>
      <description>&lt;P&gt;
	Cast it to an Array and use [] syntax:&lt;/P&gt;
&lt;PRE&gt;Array loc = current.getLocation(0,0,0);
return loc[1];
&lt;/PRE&gt;&lt;P&gt;
	Or use the x, y, and z properties of the Vec3:&lt;/P&gt;
&lt;PRE&gt;var loc = current.getLocation(0,0,0);
return loc.x;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Sep 2017 14:56:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557535#M60793</guid>
      <dc:creator>philboboADSK</dc:creator>
      <dc:date>2017-09-29T14:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557536#M60794</link>
      <description>&lt;P&gt;Wonderful now everything works. Thank you so much for your instant help.&lt;/P&gt;
&lt;P&gt;Here is the code snippet to print the correct coordinates into the output console:&lt;/P&gt;
&lt;PRE&gt;Array loc = current.getLocation(0,0,0);
double x; 
double y;
double z;

x = loc[1];
y = loc[2];
z = loc[3];

pf(x);
pt("\n");
pf(y);
pt("\n");
pf(z);
pt("\n");&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Sep 2017 15:18:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557536#M60794</guid>
      <dc:creator>robin_brunner</dc:creator>
      <dc:date>2017-09-29T15:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Read exact object-location in FlexSim by code?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557537#M60795</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/1986/robin.b.html" nodeid="1986"&gt;@Robin Brunner&lt;/A&gt; The print( ... ) command does work in FlexSim 2017 Update 2.  Could you give an example where it doesn't work?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 19:28:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/read-exact-object-location-in-flexsim-by-code/m-p/13557537#M60795</guid>
      <dc:creator>Jacob_Gillespie</dc:creator>
      <dc:date>2017-09-29T19:28:27Z</dc:date>
    </item>
  </channel>
</rss>

