This is better. The title should reflect the contents.
beginner troubles ... issues with DXF file.
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
beginner troubles ... issues with DXF file
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: beginner troubles ... issues with DXF file.
"isn't the dimensions"
as said, they are when I import the dxf, but not in your provided fc-file... apart from that, the origin is quite far off, already in the dxf...
left marking is origin, right marker is where it is positioned in global coords as is. "dead space or borders around"
not sure where you are going with that, do you mean for example an a4 in inkscape where the geometry is only the size of an a5?
if so does not really matter so much, but as far as I know the coordinates in the export is in relation to the canvas, so in that sense the canvas influences where things end up as cad - coordinates, but it is easy enough to move things around in the cad - so does not matter much.
in a cad system like fc, there is no notion like a canvas for the geometry, just global coords, it is of course a bit different when one makes drawings in the cad which per definition has a canvas to place/fit the views on.
anyways, checked for myself how clonky it is to recreate to decent geometries in fc, and it is quite clonky.
I started with an import of everything as one block, that is enough to be able to snap on edges and points.
for the reason of being able to snap, the recreation of the geometry was made in draft (not sketcher), and later converted to sketch,
but also made a version with joining every geometry made with draft back to one single face with holes in it.
I would do the latter if I was only recreating, and I would go the sketch route if I wanted to clean up dimensions.
to get the diameters of the circles I used "send object to python console" with right-click on an edge and then using bounding box...
since the bsplines only have one vertex, I just put the centre of the circle on that vertex, and repositioned them afterwards one by one, works kind of ok when one uses the "placement property". more or less the same with the slots. to speed up the creation of the circles - draft move (with copy on) was used, and afterwards adjusting to the specific diameter.
"alignment tools"
if you are using illustrator/inkscape for the sole reason that you know how to align things there, then it is high time to read up on constraining in the sketcher, that has both symmetry and align horizontal and vertical - it does not have distribute (as far as I know), but don't really see the possible usecase for that in the sketcher, what fc has is "arrays/patterns", which is the same as distribute (make one and spread x of that on distance y).
If I would make this from scratch in fc, it would be in the sketcher, and it would be several sketches, the different (related) hole patterns would be in their own sketches, and I would for example have the symmetry lines on the plate as external geometry and do all the symmetry things from there.
the reason for splitting into more than one sketch is convenience, it is easier to spot what is constrained and not if the sketch is not too cluttered.
if anyone wants a training in constraining sketches, this example could be used, it has some 100+ after conversion, the sketch in the file is fully constrained - just to show one way of doing it.
as said, they are when I import the dxf, but not in your provided fc-file... apart from that, the origin is quite far off, already in the dxf...
left marking is origin, right marker is where it is positioned in global coords as is. "dead space or borders around"
not sure where you are going with that, do you mean for example an a4 in inkscape where the geometry is only the size of an a5?
if so does not really matter so much, but as far as I know the coordinates in the export is in relation to the canvas, so in that sense the canvas influences where things end up as cad - coordinates, but it is easy enough to move things around in the cad - so does not matter much.
in a cad system like fc, there is no notion like a canvas for the geometry, just global coords, it is of course a bit different when one makes drawings in the cad which per definition has a canvas to place/fit the views on.
anyways, checked for myself how clonky it is to recreate to decent geometries in fc, and it is quite clonky.
I started with an import of everything as one block, that is enough to be able to snap on edges and points.
for the reason of being able to snap, the recreation of the geometry was made in draft (not sketcher), and later converted to sketch,
but also made a version with joining every geometry made with draft back to one single face with holes in it.
I would do the latter if I was only recreating, and I would go the sketch route if I wanted to clean up dimensions.
to get the diameters of the circles I used "send object to python console" with right-click on an edge and then using bounding box...
Code: Select all
>>> ### Begin command Std_SendToPythonConsole
>>> obj = App.getDocument("Unnamed").getObject("Layer_1001")
>>> shp = App.getDocument("Unnamed").getObject("Layer_1001").Shape
>>> elt = App.getDocument("Unnamed").getObject("Layer_1001").Shape.Edge22
>>> ### End command Std_SendToPythonConsole
>>> elt.BoundBox.XLength
2.9944734901405354
>>>
if you are using illustrator/inkscape for the sole reason that you know how to align things there, then it is high time to read up on constraining in the sketcher, that has both symmetry and align horizontal and vertical - it does not have distribute (as far as I know), but don't really see the possible usecase for that in the sketcher, what fc has is "arrays/patterns", which is the same as distribute (make one and spread x of that on distance y).
If I would make this from scratch in fc, it would be in the sketcher, and it would be several sketches, the different (related) hole patterns would be in their own sketches, and I would for example have the symmetry lines on the plate as external geometry and do all the symmetry things from there.
the reason for splitting into more than one sketch is convenience, it is easier to spot what is constrained and not if the sketch is not too cluttered.
if anyone wants a training in constraining sketches, this example could be used, it has some 100+ after conversion, the sketch in the file is fully constrained - just to show one way of doing it.
- Attachments
-
- base_plate_remake.FCStd
- (55.88 KiB) Downloaded 13 times
- thomas-neemann
- Veteran
- Posts: 11801
- Joined: Wed Jan 22, 2020 6:03 pm
- Location: Osnabrück DE 🇩🇪
- Contact:
Re: beginner troubles ... issues with DXF file.
i like the solution very much. But before doing the work you should check whether there are other options that are faster and cause less work and whether it is necessary. e.g. for reference only, the original can possibly be used.
if there is no simpler solution, this way of working has the best result in my opinion.
Re: beginner troubles ... issues with DXF file.
well, just exploring some different possible workflows.
obviously it is best to do it all in fc from scratch, but exchange of cad data is also a fairly common use case,
including badly formed dxf-files (as in badly formed from an fc perspective).
a case like this is of course appealing to attempt to script as far as possible,
for example the macro Macro_DXF_to_Face_and_Sketch bugs out on this file.
so, just to see what could be done without too much effort,
rolled my own script, does not do everything in the file, but could of course be extended.
obviously it is best to do it all in fc from scratch, but exchange of cad data is also a fairly common use case,
including badly formed dxf-files (as in badly formed from an fc perspective).
a case like this is of course appealing to attempt to script as far as possible,
for example the macro Macro_DXF_to_Face_and_Sketch bugs out on this file.
so, just to see what could be done without too much effort,
rolled my own script, does not do everything in the file, but could of course be extended.
Code: Select all
# -*- coding: utf-8 -*-
### macro for freecad
__title__ = 'Macro dxf 2 draft'
__author__ = 'heda' # @ fc-forum
__license__ = 'MIT'
__version__ = '0.1'
__date__ = '2021-07-21'
__doc__ = """
import dxf as part/block.
intended to convert bsplines to basic draft entities
with option to make a sketch from the converted entities
for now only does lines and circles
selection is (assumed to be) a single block
"""
import FreeCAD as App
import FreeCADGui as Gui
import Draft, Part
### settings
SQUARE_TOLERANCE = 0.05 # mm, or fc units
ROUND_POSITION = 2 # nbr decimals
ROUND_RADIUS = 1 # nbr decimals
MAKE_FACE = True
MAKE_SKETCH = True
AUTOCONSTRAIN = True
DELETE_DRAFT_OBJS = False
COLOR_NOT_CONVERTED = (150/255, 0., 0., 0.)
s = Gui.Selection.getSelection()
added, miss_index = (list() for i in range(2))
doc = App.ActiveDocument
if not s:
edges = []
line_color = None
print('no selection - nothing to do')
else:
obj = s[0]
edges = obj.Shape.Edges
original_color = obj.ViewObject.LineColor
def get_xyz(v):
xyz = 'xyz' if isinstance(v, App.Vector) else 'XYZ'
return (round(getattr(v, attr), ROUND_POSITION) for attr in xyz)
orientation = App.Rotation(App.Vector(0,0,1), 0) # xy plane
for i, edge in enumerate(edges):
curve = edge.Curve
if isinstance(curve, Part.BSplineCurve):
print('found bspline in edge: {}'.format(i))
bbox = edge.BoundBox
if abs(bbox.XLength - bbox.YLength) > SQUARE_TOLERANCE:
miss_index.append(i)
print('edge does not have a square-like bounding box,'
' not a circle - skipping')
else:
center = App.Vector(*get_xyz(bbox.Center))
radius = round(bbox.XLength/2, ROUND_RADIUS)
placement = App.Placement(center, orientation)
circle = Draft.make_circle(radius, placement, MAKE_FACE)
added.append(circle)
msg = 'created circle with radius {} and center: {}'
print(msg.format(radius, tuple(get_xyz(bbox.Center))))
elif isinstance(curve, Part.Line):
line = Draft.make_line(*(tuple(get_xyz(vx)) for vx in edge.Vertexes))
added.append(line)
print('found line in edge: {}'.format(i))
else:
miss_index.append(i)
msg = 'edge nbr {} is of type {}, which is not supported'
print(msg.format(i, curve))
if added:
group = App.ActiveDocument.addObject('App::DocumentObjectGroup', 'Group')
group.Label = 'dxf2draft'
group.addObjects(added)
# obj.Visibility = False
line_colors = [original_color] * len(edges)
for i in miss_index:
line_colors[i] = COLOR_NOT_CONVERTED
obj.ViewObject.LineColorArray = line_colors
doc.recompute()
if MAKE_SKETCH:
sketch = Draft.makeSketch(added, AUTOCONSTRAIN,
delete=DELETE_DRAFT_OBJS)
if not DELETE_DRAFT_OBJS:
for dobj in added:
dobj.Visibility = False
### reset line colors
#line_colors = [original_color] * len(edges)
#obj.ViewObject.LineColorArray = line_colors
Re: beginner troubles ... issues with DXF file.
has anyone tried this conversion/export in CorelDraw, if so what was the result? more of a mess or less?
oh, and heda thank you very much for the file remake.
oh, and heda thank you very much for the file remake.