For explanation with pictures of the aligned dimension: https://documentation.help/AutoCAD-DXF/WS1a9193826455f5ff18cb41610ec0a2e719-7a26.htm for radial and diameter dimension: https://documentation.help/AutoCAD-DXF/WS1a9193826455f5ff18cb41610ec0a2e719-7a21.htm possible values for Code 70 Dimension type: Values 0-6 are integer values that represent the dimension type. Values 32, 64, and 128 are bit values, which are added to the integer values (value 32 is always set in R13 and later releases) 0 = Rotated, horizontal, or vertical; 1 = Aligned; 2 = Angular; 3 = Diameter; 4 = Radius; 5 = Angular 3 point; 6 = Ordinate 32 = Indicates that the block reference (group code 2) is referenced by this dimension only 64 = Ordinate type. This is a bit value (bit 7) used only with integer value 6. If set, ordinate is X-type; if not set, ordinate is Y-type 128 = This is a bit value (bit 8) added to the other group 70 values if the dimension text has been positioned at a user-defined location rather than at the default location possible values for Code 71 Attachment point: 1 = Top left; 2 = Top center; 3 = Top right 4 = Middle left; 5 = Middle center; 6 = Middle right 7 = Bottom left; 8 = Bottom center; 9 = Bottom right Example values are taken from the file "dxf issues with special chars.dxf" Example of a vertical (90° rotated) dimension 17.5cm: 0 DIMENSION ... 8 0_WP_BEMASSUNG_1_50 100 AcDbDimension ... 2 *D19 10 -- point where dimension line starts -5.066473011211921 20 18.65497213215147 30 0.0 11 -- center point of dimension text -5.066473011211921 21 18.0571371290556 31 0.0 70 -- dim type 160 1 -- dim user text <> 71 -- dimension text attachment point 5 42 -- actual measured value , read only 0.1750000000000007 ... 100 AcDbAlignedDimension 13 -- defines the start point of reference line -4.299999375712105 23 18.47997213215147 33 0.0 14 -- defines the end point of reference line -4.549999375711014 24 18.65497213215147 34 0.0 50 -- Angle of rotated, horizontal, or vertical dimensions. rotation angle in ° measured from North Up, present, if dim. type is 0, ignore otherwise. 90.0 -- example: dimension line is 90° , which means the extension line points to the left from the ref end point (14,24,34). -- it describes the rotation from (0,1,0) to the extension vector (10,20,30)-(14,24,34). In fact we do not need this as the vector should be enough 100 AcDbRotatedDimension -- this only is present, if it is rotated dimension, meaning code dim type is 0 and above code 50 is also there ... #Transform for SketchUp: # DXF codes indicated in variables starting with p (point) or v(vector) or c(any code): # dimension line start point p10 = "-5.066473011211921m".to_l p20 = "18.65497213215147m".to_l p30 = "0.0m".to_l # Text center point p11 = "-5.066473011211921m".to_l p21 = "18.0571371290556m".to_l p31 = "0.0m".to_l # reference start point p13 = "-4.299999375712105m".to_l p23 = "18.47997213215147m".to_l p33 = "0.0m".to_l # reference end point p14 = "-4.549999375711014m".to_l p24 = "18.65497213215147m".to_l p34 = "0.0m".to_l # dimension type c70 = 160 # user text c1 = "<>" # attachment point c71 = 5 # actual measurement c42 = "0.1750000000000007m".to_l # roatation angle, present if dimension type is 0. 90 means the extensionline is pointing horizontally to the left c50 = 90.0 Example of a 150° rotated dimension 0.1045m: (this is not in the test file, but explains the rotation) 0 DIMENSION ... 100 AcDbDimension ... 2 *D19 10 -- dimension line start point -8.899926547821183 20 17.72716123057153 30 0.0 11 -- text center position -7.739084203853859 21 16.90682894883902 31 0.0 70 -- the dim type, se above. here it means 0 = rotated dim 32 1 -- user text. between angle brackets is the measured value Uwe <> 71 -- attachment point place 5 42 -- actual measurement, read only 0.1045286148822958 ... 100 AcDbAlignedDimension 13 -8.864999375716582 23 18.01577671607208 33 0.0 14 -8.715987007018034 24 18.07349931765649 34 0.0 50 -- Angle of rotated, horizontal, or vertical dimensions. rotation angle in ° measured from North Up, present, if dim. type is 0, ignore otherwise. 152.0273083652495 -- example: dimension line is 152° , which means the extension line points to the left downwards from the ref end point (14,24,34). -- it describes the rotation from (0,1,0) to the extension vector (10,20,30)-(14,24,34). In fact we should not need this as the vector should be enough 100 AcDbRotatedDimension -- this only is present, if it is rotated dimension, meaning code dim type is 0 and above code 50 is also there ... #Transform for SketchUp: # DXF codes indicated in variables staring with p (point) or v(vector) or c(any code): # dimension line start point p10 = "-8.899926547821183m".to_l p20 = "17.72716123057153m".to_l p30 = "0.0m".to_l # Text center point p11 = "-7.739084203853859m".to_l p21 = "16.90682894883902m".to_l p31 = "0.0m".to_l # reference start point p13 = "-8.864999375716582m".to_l p23 = "18.01577671607208m".to_l p33 = "0.0m".to_l # reference end point p14 = "-8.715987007018034m".to_l p24 = "18.07349931765649m".to_l p34 = "0.0m".to_l # dimension type c70 = 160 # user text c1 = "Uwe <>" # attachment point c71 = 5 # actual measurement c42 = "0.1045286148822958m".to_l # roatation angle, present if dimension type is 0 c50 = 152.0273083652495 Example of aligned dimension that is vertical with measure 1.245 0 DIMENSION ... 8 0_WP_BEMASSUNG_1_50 100 AcDbDimension -- this defines the dimension line 8 -- layer where the dimension is attached 0_WP_BEMASSUNG_1_50 ... 2 -- Name of the block that contains the entities that make up the dimension picture like MText, arrow heads, etc, *D21 10 -- point where dimension line starts -14.58656601344108 20 20.01997210955141 30 0.0 11 -- center point of dimension text -14.58656601344108 21 19.52440523079339 31 0.0 70 -- dim type values 0,1,2,3,4,5,6, 32, 64, 128 added up, e.g. 161 = 128 + 32 + 1 = dim text is user defined and it is an aligned dim 161 -- 1 is an aligned dim, i.e. dimension line is parallel to reference (measure) line 1 -- dimension text, if missing or empty or <>, then use measured value from 42 <> 71 -- attachement point , in case we have to rotate the dimension line. values 1-9 5 -- middle center 42 -- Actual measurement (optional; read-only value). probably always there, if no text in code 1 1.24499997739936 ... 100 AcDbAlignedDimension ... 13 -- defines the start point of reference line: from where we measure. it is also the start point for the first extension line -14.194999375716 23 18.77497213215205 33 0.0 14 -- defines the end point of reference line: to where we measure. it is also the start point for the second extension line -14.194999375716 24 20.01997210955141 34 0.0 ... #Transform for SketchUp: # DXF codes indicated in variables staring with p (point) or v(vector) or c(any code): # variable assignment for later sketchup commands # dimension line start point p10 = "-14.58656601344108m".to_l p20 = "20.01997210955141m".to_l p30 = "0.0m".to_l # Text center point p11 = "-14.58656601344108m".to_l p21 = "19.52440523079339m".to_l p31 = "0.0m".to_l # reference start point p13 = "-14.194999375716m".to_l p23 = "18.77497213215205m".to_l p33 = "0.0m".to_l # reference end point p14 = "-14.194999375716m".to_l p24 = "20.01997210955141m".to_l p34 = "0.0m".to_l # dimension type c70 = 161 # user text c1 = "<>" # attachment point c71 = 5 # actual measurement c42 = "1.24499997739936m".to_l # roatation angle, present if dimension type is 0 c50 = 0 # not present here Example of aligned dimension that is horizontal with measure 2.885m 0 DIMENSION ... 8 -- the layer/tag 0_WP_BEMASSUNG_1_50 100 AcDbDimension -- this defines the dimension line 8 -- layer where the dimension is attached 0_WP_BEMASSUNG_1_50 ... 2 -- Name of the block that contains the entities that make up the dimension picture like MText, arrow heads, etc, *D21 10 -- point where dimension line starts -5.829999375710795 20 19.10976678735829 30 0.0 11 -- center point of dimension text -6.101444903469229 21 19.18676678843117 31 0.0 70 -- dim type values 0,1,2,3,4,5,6, 32, 64, 128 added up, e.g. 161 = 128 + 32 + 1 = dim text is user defined and it is an aligned dim 161 -- 1 is an aligned dim, i.e. dimension line is parallel to reference (measure) line 1 -- dimension text, if missing or empty or <>, then use measured value from 42 <> 71 -- attachement point , in case we have to rotate the dimension line. values 1-9 5 -- middle center 42 -- Actual measurement (optional; read-only value). probably always there, if no text in code 1 2.885000000006151 ... 100 AcDbAlignedDimension ... 13 -- defines the start point of reference line: from where we measure. it is also the start point for the first extension line -8.714999375716946 23 18.65497213215147 33 0.0 14 -- defines the end point of reference line: to where we measure. it is also the start point for the second extension line -5.829999375710795 24 18.65497213215147 34 0.0 ... #Transform for SketchUp: # DXF codes indicated in variables staring with p (point) or v(vector) or c(any code): # variable assignment for later sketchup commands # dimension line start point p10 = "-5.829999375710795m".to_l p20 = "19.10976678735829m".to_l p30 = "0.0m".to_l # Text center point p11 = "-6.101444903469229m".to_l p21 = "19.18676678843117m".to_l p31 = "0.0m".to_l # reference start point p13 = "-8.714999375716946m".to_l p23 = "18.65497213215147m".to_l p33 = "0.0m".to_l # reference end point p14 = "-5.829999375710795m".to_l p24 = "18.65497213215147m".to_l p34 = "0.0m".to_l # dimension type c70 = 161 # user text c1 = "<>" # attachment point c71 = 5 # actual measurement c42 = "2.885000000006151m".to_l # roatation angle, present if dimension type is 0 c50 = 0 # not present here # create sketchup dimensions based on the above done variable assignment: # dimension type: dt = c70 - 128 if c70 >= 128 dt = dt - 64 if dt >= 64 dt = dt - 32 if dt >= 32 # we support only rotated/horizontal/vertical and aligned dimensions if dt == 0 or dt == 1 then p0 = Geom::Point3d.new(p10, p20, p30) p1 = Geom::Point3d.new(p11, p21, p31) p3 = Geom::Point3d.new(p13, p23, p33) p4 = Geom::Point3d.new(p14, p24, p34) v0 = Geom::Vector3d.new(p0.to_a) v1 = Geom::Vector3d.new(p1.to_a) v3 = Geom::Vector3d.new(p3.to_a) v4 = Geom::Vector3d.new(p4.to_a) entities = Sketchup.active_model.entities # draw aligned linear dimension dim = entities.add_dimension_linear p4, p3, v0 - v4 dim.has_aligned_text = true # set text aligned to dimension line, not screen orientation # Text =begin As the user text is stored as MTEXT under a dbBlock reference (code 2), it is difficult to get the text. Therefor either put a space or let Sketchup calculate. I would display the user text as defined in Code 1 and if empty or <> in dxf, put a space. But still let the MTEXT dimension value be imported. Alternative is to search the MTEXT value linked to the dimension via the block reference (code 2) and put that text into the sketchup dim text. But as the sketchup text formatting is lmited, I would not do it. =end case when c1 == "<>" then t = c42.to_s when c1.empty? then t = " " else t = c1 end dim.text = t #Text position: =begin Figure out the Sketchup text position is either Sketchup::DimensionLinear::TEXT_OUTSIDE_START Sketchup::DimensionLinear::TEXT_CENTERED Sketchup::DimensionLinear::TEXT_OUTSIDE_END Checking where the text center Code (11, 21, 31) is in relation to the reference line. use a vector v40pn perpendicuar to the extension line (v0 - v4) x ((v0 - v4) x (v4 - v3)), normalize it, then scale it to length |v4 - v3| along this direction Calculate the scalar (dot) prodcut of tsp = v40pn.normalized * (v1 - v0) if the scalar vector product of (sp > |v3 - v4| then TEXT_OUTSIDE_START else if sp < 0 then TEXT_OUTSIDE_END else TEXT_CENTERED =end v40pn = ((v0 - v4).cross((v4 - v3).cross(v0 - v4))).normalize v40p_len34 = v40pn.dot(v4 - v3) # make sure the vector points into positive x direction (writing direction is from left to right). If not, then swap the result tsp = v40pn.dot(v1 - v0) if # when t == " " then tpos = Sketchup::DimensionLinear::TEXT_OUTSIDE_START # if no text, then put space at the beginning, so there is no gap in the dimension line tsp > 0 and v40pn.x >= 0 then tpos = Sketchup::DimensionLinear::TEXT_OUTSIDE_START elsif tsp > 0 and v40pn.x < 0 then tpos = Sketchup::DimensionLinear::TEXT_OUTSIDE_END elsif tsp < -v40p_len34 and v40pn.x >= 0 then tpos = Sketchup::DimensionLinear::TEXT_OUTSIDE_END elsif tsp < -v40p_len34 and v40pn.x < 0 then tpos = Sketchup::DimensionLinear::TEXT_OUTSIDE_START else tpos = Sketchup::DimensionLinear::TEXT_CENTERED end dim.text_position = tpos # Aligned position, if centerd text =begin If center, then decide if in Sketchup above, on line or outside (not between reference and dimension line): Sketchup::DimensionLinear::ALIGNED_TEXT_ABOVE Sketchup::DimensionLinear::ALIGNED_TEXT_CENTER Sketchup::DimensionLinear::ALIGNED_TEXT_OUTSIDE Check if the scalar (dot) vector product of ([10,20,30]-[14,24,34] ) * ( [11, 21, 31]-[10,20,30] ) is positive (then outside), if 0 (then centered), otherwise above. set the value even if the text is not centered, as the user might change to centered and then the aligned position is already as in dxf. =end asp = (v0 - v4).dot(v1 - v0) case when asp > 0 then tapos = Sketchup::DimensionLinear::ALIGNED_TEXT_OUTSIDE when asp == 0 then tapos = Sketchup::DimensionLinear::ALIGNED_TEXT_CENTER else tapos = Sketchup::DimensionLinear::ALIGNED_TEXT_ABOVE end dim.aligned_text_position = tapos # Text font: =begin if TIG does not read the dimension text font already, use sketchup dimension default font. Ideal would be, that the font is changed from Pixels to height, so that the dimension zooms lke the 3Dtext =end # Arrow heads: =begin As the arrow heads are also defined via the block ref (in code 2) and this might be difficult to interpret, Just use Sketchup default arrow head style. User can still easily change the style later for all dimensions at once. =end end