How to convert a set of connected lines to a solid in CAD applications? Tool is being used can be AutoCAD, SketchUp, Solidworks, FreeCAD, or any other software you may know that can do this simple task painlessly. Note that the following graphics is only for demonstration. The desired resulting should be a valid CAD solid to be able apply all related operations such as boolean ones etc.

enter image description here

Just remember the job needs to be done thousands times so manual approaches are not suitable. Even some help to write a piece of code for this job is much appreciated (in any language), so you may explain how to code a simple DXF writer for just Solid, for example. Our play with some DXF exporters in Python was not successful.

Upadate: a simple Ruby code for SketchUp or VBA code for AutoCAD or Python for FreeCAD could be of most help.

有帮助吗?

解决方案

Here are some Google SketchUp Ruby API snippets. It's very simple, using the Edge#find_faces method that will make SketchUp try and find possible faces for the given edge. https://developers.google.com/sketchup/docs/ourdoc/edge#find_faces

Find faces for current selection:

# Find faces for selected edges:
model = Sketchup.active_model
model.start_operation( 'Find Faces in Selection', true )
for entity in model.selection.to_a
  next unless entity.is_a?( Sketchup::Edge )
  entity.find_faces
end
model.commit_operation

Find faces for current context:

# Find faces for current context:
model = Sketchup.active_model
model.start_operation( 'Find Faces in Current Context', true )
for entity in model.active_entities.to_a
  next unless entity.is_a?( Sketchup::Edge )
  entity.find_faces
end
model.commit_operation

Find faces for all edges in model:

# Find faces for all edges in model:
model = Sketchup.active_model
model.start_operation( 'Find Faces in Whole Model', true )
for entity in model.entities.to_a
  next unless entity.is_a?( Sketchup::Edge )
  entity.find_faces
end
for definition in model.definitions
  next if definition.image?
  for entity in definition.entities.to_a
    next unless entity.is_a?( Sketchup::Edge )
    entity.find_faces
  end
end
model.commit_operation

If you need to process a batch of DWG file for this you can automate that as well using Model#import to import the DWG files. https://developers.google.com/sketchup/docs/ourdoc/model#import

This assumes that the edges are bounding coplanar surfaces. You will only get a solid if the wiregrid you import can represent one.

其他提示

If you can build a mesh from your collection of lines, and if that mesh is closed (water tight), you could use the AutoCAD convtosolid command in a script:

http://docs.autodesk.com/ACAD_E/2012/ENU/filesACR/WS1a9193826455f5ffa23ce210c4a30acaf-4cf2.htm

I think the command is new in AutoCAD 2012, but it might have been in 2011 too?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top