• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

3d points of coplanar polygons - SketchUp Ruby API

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 3 Posters 865 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    vhiguita
    last edited by 7 Apr 2012, 17:26

    Hi,

    I have a question, how could I draw a coplanar polygon with the next
    3d points?
    [27.096141893, 67.088581299, 10.979694884][13.548070946,
    62.423606365, 20.5321749][27.258347158, 22.606073055, 20.5321749]
    [40.806418104, 27.271047989, 10.979694884]
    that are the points of
    a polygon of a roof.

    I have the next polygon with the points [27.096141893,67.088581299,10.979694884]
    [13.548070946,62.423606365,20.532174900]
    [13.548070946,62.423606365,20.532174900]
    [27.258347158,22.606073055,20.532174900]
    [27.258347158,22.606073055,20.532174900]
    [40.806418104,27.271047989,10.979694884]
    [40.806418104,27.271047989,10.979694884]
    [27.096141893,67.088581299,10.979694884]
    and orientation of
    71.0 how could I draw the polygon according the orientation.

    Thank you very much.

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 7 Apr 2012, 18:47

      If you have three points they will always be 'coplanar'.
      Let's call them p1/p2/p3;
      To add the face use:
      Sketchup.active_model.active_entities.add_face(p1,p2,p3)
      You can use more points BUT you must be sure that they are coplanar.

      What do you mean by the orientation of 71 ?

      PS: Don't double post - be patient - I moved the post here too...

      TIG

      1 Reply Last reply Reply Quote 0
      • V Offline
        vhiguita
        last edited by 7 Apr 2012, 20:32

        Hi,

        In this instruction Sketchup.active_model.active_entities.add_face(p1,p2,p3).
        Must the p1, p2, p3 points be different (not repeated)?
        With respect to the orientation, it´s a xml file with some data of a house roof I need to draw with SketchUP ruby API, what could it mean?.

        Thanks.

        <?xml version="1.0" encoding="UTF-8"?>
        -<EAGLEVIEW_EXPORT xsi:noNamespaceSchemaLocationreportName="file:///c:/temp/eagleview-export.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <VERSION triangulation="" targetVersion="0" sourceVersion="1028" precisionUnits="" precision="0" dormers="" coplanarity=""/> <LOCATION state="CA" postal="" long="-122.0241000" lat="36.9821000" city="Santa Cruz" address="141 Kennan St"/> -<STRUCTURES northorientation="0.0"> -<ROOF id="ROOF1"> -<FACES> -<FACE id="F1" designator="I"> <POLYGON id="P1" unroundedsize="725.207196199" size="725" pitch="8" path="L1,L2,L3,L4" orientation="71.0"/> </FACE>
        -<FACE id="F2" designator="H"> <POLYGON id="P2" unroundedsize="725.207196199" size="725" pitch="8" path="L2,L5,L6,L7" orientation="251.0"/> </FACE> -<FACE id="F3" designator="A"> <POLYGON id="P3" unroundedsize="14.215955537" size="14" pitch="6" path="L8,L9,L10,L11" orientation="341.0"/> </FACE> -<FACE id="F4" designator="B"> <POLYGON id="P4" unroundedsize="18.105641666" size="18" pitch="8" path="L11,L12,L13" orientation="23.5"/> </FACE>
        ....
        </FACES>
        -<LINES> <LINE id="L1" path="C1,C2" type="RAKE"/> <LINE id="L2" path="C2,C3" type="RIDGE"/> <LINE id="L3" path="C3,C4" type="RAKE"/> <LINE id="L4" path="C4,C1" type="EAVE"/> <LINE id="L5" path="C2,C5" type="RAKE"/> <LINE id="L6" path="C5,C6" type="EAVE"/> <LINE id="L7" path="C6,C3" type="RAKE"/> <LINE id="L8" path="C7,C8" type="EAVE"/>
        ...
        </LINES>
        -<POINTS> <POINT id="C1" data="27.096141893,67.088581299,10.979694884"/> <POINT id="C2" data="13.548070946,62.423606365,20.532174900"/> <POINT id="C3" data="27.258347158,22.606073055,20.532174900"/> <POINT id="C4" data="40.806418104,27.271047989,10.979694884"/> <POINT id="C5" data="0.000000000,57.758631431,10.979694884"/> <POINT id="C6" data="13.710276212,17.941098122,10.979694884"/> <POINT id="C7" data="9.278743999,64.672471378,3.493539281"/> <POINT id="C8" data="6.784562011,63.813655647,3.493539281"/> <POINT id="C9" data="8.502105093,59.116949751,5.993539281"/>
        ...
        </POINTS> </ROOF> </STRUCTURES> </EAGLEVIEW_EXPORT>
        L1

        @tig said:

        If you have three points they will always be 'coplanar'.
        Let's call them p1/p2/p3;
        To add the face use:
        Sketchup.active_model.active_entities.add_face(p1,p2,p3)
        You can use more points BUT you must be sure that they are coplanar.

        What do you mean by the orientation of 71 ?

        PS: Don't double post - be patient - I moved the post here too...

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 8 Apr 2012, 09:39

          The three points [p1/p2/p3] must all be different points in space, note that also they cannot be colinear - because three points in a straight line can't form a face! Otherwise any other three different points must be coplanar and will always 'face'... These points form the vertices of the face and Sketchup forms edges between them to suit.
          You can have more than three points passed to .add_face()... BUT they must all be properly coplanar, which is not guaranteed, unless of course you are sure that they are from prior knowledge, or perhaps all of these new points share a common coordinate, in say the Z, which will ensure they're coplanar...

          Looking at the XML code you supplied it is possible to see it defining several XYZ points [C2/C3 etc], these points are used to form lines [edges] {L1/L2 etc} describing different roof planes.
          It will need very intense parsing of the text to extract the points and the lines etc.
          Beyond you, I suspect - experienced scripters would be wary...

          TIG

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdmitch
            last edited by 11 Apr 2012, 21:54

            vhiguita, Are you still working on this problem or do you have a solution? I was interested in your problem and thought I would give it a try. Using the data from you post, I created a "html" file and created a plugin to read it and place the data. My html file contains the faces, lines and points but the lines and points are really the only data you need. I assummed the units were feet. It would help if I had an actual file to work with so post one if possible.

            Nothing is worthless, it can always be used as a bad example.

            http://sdmitch.blogspot.com/

            1 Reply Last reply Reply Quote 0
            • V Offline
              vhiguita
              last edited by 20 Apr 2012, 16:35

              @sdmitch said:

              vhiguita, Are you still working on this problem or do you have a solution? I was interested in your problem and thought I would give it a try. Using the data from you post, I created a "html" file and created a plugin to read it and place the data. My html file contains the faces, lines and points but the lines and points are really the only data you need. I assummed the units were feet. It would help if I had an actual file to work with so post one if possible.

              Hi, I found the solution, there are many ways to get this, for example with PHP you could load all the html to a string, you could apply regular expressions to get the values (<div>,<span>, etc) from the tags review curl library.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement