sketchucation logo sketchucation
    • Login
    1. Home
    2. Mcdull
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    M
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 10
    • Posts 28
    • Groups 1

    Mcdull

    @Mcdull

    10
    Reputation
    1
    Profile views
    28
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Mcdull Unfollow Follow
    registered-users

    Latest posts made by Mcdull

    • How to set length units in code

      I want to pull a face from 0 to 4.5m, and my entities is imported from other software,how to set length units in code?
      for example

      
      pts = []
       pts[0] = [edge.start.position.x, edge.start.position.y, 0]
       pts[1] = [edge.end.position.x, edge.end.position.y, 0]
       pts[2] = [edge.end.position.x, edge.end.position.y, 4.5]
       pts[3] = [edge.start.position.x, edge.start.position.y, 4.5]
      
      

      here,i want to set z value as 4.5m,how to set? thank u

      posted in Developers' Forum
      M
      Mcdull
    • RE: How to move a group?

      thank u,i have got it...

      posted in Developers' Forum
      M
      Mcdull
    • RE: How to move a group?

      @jessejames said:

      @mcdull said:

      i want to move a selected group,and select the group with the code

       model = Sketchup.active_model
      > >       entities = model.entities
      > >    selectgroup = model.selection
      > >    select_entity = selectgroup[0]
      

      how to move it to other location?

      You are really creating more alias than you need. Actually you could do this script with just one line. If your never going to call an alias more than once why waste the CPU cycles?

      
      > Sketchup.active_model.selection[0].transform!(Geom;;Transformation.translation([0,0,50]))
      

      ...but you may want to popup a dialog if the user forgot to select something or the selected "something" is not a group or component, or you may want the user to input an amount to move etc..! The script rolling is left as an exercise for the reader 😉

      i have tried this method

      Sketchup.active_model.selection[0].move!
      

      before,i want to the group move from the boundingbox center the other point,and then this point turn to be the boundingbox center of the group's bounding box.according the above method,the group move form one corner edge to the point,and that target point turn to be the corner,not the center...

      posted in Developers' Forum
      M
      Mcdull
    • How to move a group?

      i want to move a selected group,and select the group with the code

       model = Sketchup.active_model
            entities = model.entities
         selectgroup = model.selection
         select_entity = selectgroup[0]
      

      how to move it to other location?

      posted in Developers' Forum
      M
      Mcdull
    • RE: How to get a intersection btween a line and a face

      ok, i got it,but there are many intersection points .the line have intersect with every face's plane,if i wanto to get the intersection point in the face,not the other faces' planes,do i have to judge with the method Face.classify_point
      or other methods?
      thank u ,TIG

      posted in Developers' Forum
      M
      Mcdull
    • How to get a intersection btween a line and a face

      there are many triangls in the bottom,but they are not in one plane, i generate a line with two points,and the line is vertical to the XYplane ,i want to get the intersection btween the line and a face.
      i read the api that

       # This is really the normal which follows the x axis. The plane is
       # perpendicular
       plane1 = [Geom;;Point3d.new(-10, 0 ,0), Geom;;Vector3d.new(1,0,0)]
      
       # This line follows the x axis
       line1 = [Geom;;Point3d.new(-10,0,0), Geom;;Vector3d.new(1,0,0)]
      
       # returns -10, 0, 0
       pt = Geom.intersect_line_plane(line1, plane1)
      

      but this method turn every face to be a plane,so,the intersection may be outside of the face,i want to get the intersection in the face...
      would u give me some help?thank u

      posted in Developers' Forum
      M
      Mcdull
    • RE: How to get a selected object center?

      @chris fullmer said:

      because you are finding the bounding box for the first entitiy in the list of entities. What you want is to find the bounding box of the first entitiy in the selection set I would bet.

      model = Sketchup.active_model sel = model.selection first_entity = sel[0]

      try that

      i got it ,thank u
      ~

      posted in Developers' Forum
      M
      Mcdull
    • How to get a selected object center?

      I Want to get a object center point, the object may be a mesh,face,or group.my method is

        UI.add_context_menu_handler do |context_menu|
         context_menu.add_separator
         context_menu.add_item("center point") {
      
          model = Sketchup.active_model
          entities = model.active_entities
          first_entity = entities[0]
          bbx=first_entity.bounds
      #    selection = model.selection
      #
      #          selection.each { |entity|
      #              $boundbox = entity.model.bounds
      #              UI.messagebox($boundbox.corner 0)
      #               UI.messagebox($boundbox.corner 1)
      #
      #              }
      #  puts selection.count
      #  puts $boundbox.center
      puts bbx.center.to_s
      

      but the result is always the same,would tell me why? thank u

      posted in Developers' Forum
      M
      Mcdull
    • RE: How to inspect all faces?

      @chris fullmer said:

      So you want the vertices of each SU face because SU allows non-triangulated faces. And you want to use that data to convert the triangulated faces in XNA into faces more like in SU? Is that more or less the idea? Do you know how to use this data in xna? Can you create a script in xna that takes a series of vertices, finds all faces in xna bounded by those vertices, then turns them all into a single xna face? That seems to be about what your looking for, maybe?

      yes,i am trying to realize the idea.we can just draw point,line,triangle in XNA,so we have to draw a series of triangles to represent a polygon or a face.i know how to draw a series of triangle meshes with a series of vertices. any other method to trace the face from each triangle mesh in .x model or .fbx model?

      posted in Developers' Forum
      M
      Mcdull
    • RE: How to inspect all faces?

      @chris fullmer said:

      Sure, have you coded anything before? Anything in Ruby? Its pretty simple to get the base of what you want, but I'm concerned about what you want to do with it. Just a list of xyz values for every vertex in the model seems rather useless, but perhaps its useful to you? This will get you started.

      ` model = Sketchup.active_model
      ents = model.entities
      faces = []
      vert_array = []

      ents.each { |e| faces << e if e.is_a? Sketchup::Face }
      faces.each { |e| vert_array << e.vertices.collect { |ff| ff.position } }

      puts vert_array`

      That will not drill down into components or groups, it just skips them I think. But its a start. Do have any better clues what you wouild like to use this for?

      yes ,i have coded before,but the peogramme is very simple. thanks for your relpy.the reason why i want to do it is that i want to load SKP model in XNA.yes,it can load directly only if transforming the model type into .fbx.however,the model in XNA is triangular mesh,i want to organize the model with face,which can contains triangular meshes. then i can trace the face from eachtriangular mesh. so i can select each face like doing it in sketchup,rather than a triangular mesh in XNA.
      i don't whether my representation is clear,and i am very happy to discuss with u.thank u!

      posted in Developers' Forum
      M
      Mcdull