Monday, December 4, 2023
Home3D ModelingSketchup take away strains that aren't edges - Ruby API

Sketchup take away strains that aren’t edges – Ruby API


can anybody know how one can take away strains that aren’t edges ??


Sketchup::ConstructionLine are the one ‘strains’ that aren’t a Sketchup::Edge

do you imply these or are you desirous to take away/disguise co-planer edges that cut up faces…

add a picture or skp file to elucidate higher…

john

i need some plugin or script to take away all further (push pull information) strains to be eliminated at one click on

As @john_drivenupthewall says they’re all ‘edges’ [actually a ‘line’ is a special thing defined by a point and a vector used in Geom::]
Iterate the related ‘edges’ and take a look at every ‘edge’ in flip…
To verify if an ‘edge’ is ‘faceless’ use edge.faces[0]==false
To verify if an ‘edge’ helps a couple of face use edge.faces[1]==true
To verify if an ‘edge’ is NOT wanted – e.g. to maintain its faces, and its faces don’t have totally different supplies and many others – i.e. it’s ‘coplanar’ – then you should do some exams maybe like this…

### iterate the 'edges' as 'edge'...

if edge.faces.size==2 && edge.faces[0].regular.dot(edge.faces[1].regular)>0.9999999 && edge.faces[0].materials==edge.faces[1].materials && edge.faces[0].back_material==edge.faces[1].back_material
   ### EITHER acquire edge into an array, 
   ### for erasing in a single step later, OR use this
   e.erase!
finish

Your posted pictures crossed with my earlier posted code snippet…

In case your seemingly ‘coplanar’ edges throughout the partitions assist faces as partitions inside the wall itself, then it’s extra sophisticated that deleting true ‘coplanar’ which merely cut up a face into two components.
It’s essential acquire edge.faces.size==3
Then verify if any two of the sting’s faces share a typical ‘airplane’ [or ‘normal’] and in the event that they do then the sting will be erased, taking its inside partition face with it.

After one cross to erase such edges you should repeat utilizing my earlier ‘coplanar’ code, to take away some now really ‘coplanar’ edges that are left from step one of processing.

PS: to gather all edges use edges=group.entities.grep(Sketchup::Edge)

You should utilize CleanUp3 tp merge coplanar faces (take away “flat” edges).

Thanks TIG it didn’t labored

What didn’t work ?
With out the code you tried who can say what’s improper ?

Did you acquire the entire edges from their entities context ?
Did you then iterate these edges by edge ?
Did you then verify every of these for 3 faces ?
Did you then verify these faces to make sure two have the identical ‘regular’ ?
Did you then erase the sting if that’s the case ?
Did you then repeat the gathering and iteration course of to take away any ‘coplanar’ edges with simply two faces ?

Perhaps one thing like:

# Delete 'further' edges
# run with EraseEdges.run

module EraseEdges
  def self.run
    am = Sketchup.active_model

    edges_erase = am.entities.grep(Sketchup::Edge).choose do |e|
      e.faces.empty? or (e.faces.size == 2       and
        face0 = e.faces[0] and face1 = e.faces[1]  and
        face0.regular.dot(face1.regular) > 0.9999999 and
        face0.layer         == face1.layer         and
        face0.materials      == face1.materials      and
        face0.back_material == face1.back_material
      )
    finish

    until edges_erase.empty?
      am.start_operation 'Erase Additional Edges'
      am.entities.erase_entities edges_erase
      am.commit_operation
    finish
  finish
finish

This solely erases coplanar edges supporting two faces.
However I strongly suspect [NOT confirmed] that the OP’s mannequin has inner partition faces on the numerous factors within the partitions the place they appear ‘coplanar’ – so then

e.faces.size == 3

so in your instance these edges are skipped, that’s why I prompt firstly amassing edges with 3 faces after which checking that two of these faces share a traditional vector, and in the event that they do erasing that edge, and as a by-product its inner partition face goes too.: nonetheless, a few of the edges that supported that face are actually 2-face coplanar edges and wish eradicating with a second cross of one thing lie your code – though I query needing a verify of the 2 faces for sharing a layer – as uncooked geometry [edges and faces] ought to after all at all times be assigned to Layer0 !

I wasn’t positive about that (faces.size == 3) , or whether or not ‘active_entities’ or ‘entities’, or layers, or is the face seen, and many others, and many others…

Simply a place to begin…

I perceive.

I’d use am.active_entities as a result of then the consumer can activate the device while inside a gaggle/part edit. and thereby course of simply these edges.
In any other case utilizing am.entities at all times processes simply these entities within the mannequin.

script take a look at.skp (554.8 KB)

are you able to please assist me how one can correctly use the above script to scrub this fashion

thanks :slight_smile:

sorry as I’m not very used to all this coding I got here right here to search out some answer for my drawback

I believe the best answer is to scrap the coding answer…

Erasing coplanar edges supporting two faces is straightforward, however doing related edits when a mannequin such has yours has a number of inner partition faces inside partitions and many others is tough to attain in a easy snippet.

Nonetheless, all just isn’t misplaced.

I attempted working my ‘SolidSolver’ device on the component-instance and it labored fantastic.
Simply chosen the issue ‘container’ [compo/group] and selected it off the right-click context-menu…
It routinely reversed some wayward faces round openings, then deleted the interior partition faces after which supplied the prospect to delete the entire now pointless coplanar edges throughout the wall faces.
On completion [after only a few seconds] it nonetheless experiences as not being a stable [and in Entity Info], BUT the entire mess you need fixing is resolved.
I additionally examined it with thomthom’s ‘SolidInspector²’ which experiences the reversed faces and partitions and allows you to select the repair them, nonetheless, it nonetheless leaves the coplanar edges in place, and oddly then considers it a stable regardless of Entity Information saying that it’s not !

So I like to recommend you obtain, then set up my extension from right here:

Word that in case you are not already a member at SCF you’ll be able to simply register, and the free-membership means that you can use the PluginStore and many others…

@sunitha.bdesignstudios

Hooked up is a file, obtain it. then open the Ruby console from the window menu, and kind

load '<path to file>'

Once you wish to ‘clear’ a mannequin, sort the next within the Ruby console:

CleanInner.run

I examined it with the mannequin you connected above, and it really works. There could also be instances the place it doesn’t work, all of the operations it performs will be reversed from the ‘Edit/Undo’ menu.

Lastly, your mannequin was two elements. If you should ‘clear’ a part, choose it, the right-click on ‘Edit Part’…

clean_inner.rb (2.2 KB)

NOTE: The code connected appears to repair the difficulty you’ve, which is a ‘stable sort’ mannequin with inside partitions. However, it’s going to delete faces/edges if the mannequin has different points. As an illustration, a window opening. If one provides a face to 1 aspect of an open window, then run the code, it’s going to make a large number of issues.

The issue is that creating an inventory/assortment of all of the ‘inside partitions’ is a tough factor to do. There are at all times edge instances that journey up the algorithms…

3 face drawback is quite common.

simply add some object to a different object.
and hidden face is made.

and gettting hidden face programmatically is tough.

fs = []
for f in e.faces
    # A hidden face has edges, all edges has faces 3 (face edge rely - 1)
    inner_face = true
    for eg in f.edges
        if eg.faces.size < f.edges.size - 1
            inner_face = false
            break
        finish
    finish
    if not inner_face
        fs << f
    finish
finish

face0 = fs[0]
face1 = fs[1]
face2 = fs[2]

it isn’t good. however works.

Why are you utilizing common strains to structure your home windows and doorways. That’s what pointers are for and they’re simply deleted. Click on on Edit/delete guides within the menu.

That is one other instance of the significance to be taught fundamentals at first.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments