I am already doing this in the VCB but the users want to have a dimension so that it resembles and acts like Chief Architect when you draw a wall.
Here is what I have so far:
Not shown is the same dimension information in the VCB.
My code is:
wallvec = @pts[1] - @pts[0]
if (wallvec.length > 0)
if @Walljust == "Front"
transform = Geom::Transformation.new(@pts[0], [0, 0, 1], 90.degrees)
wallvec2 = wallvec.transform(transform)
wallvec2.length = @Stud_depth_draw
offset_start_pt = @pts[0].offset(wallvec2)
offset_end_pt = @pts[1].offset(wallvec2)
view.line_width = 2
previewcolor = "#808080"
view.drawing_color = previewcolor
view.draw(GL_LINE_STRIP, @pts[0], offset_start_pt)
view.draw(GL_LINE_STRIP, offset_start_pt, offset_end_pt)
view.draw(GL_LINE_STRIP, offset_end_pt, @pts[1])
if @Preview3d == "YES"
hgtvec = Geom::Vector3d.new(0,0,@Wallhgt_draw)
# hgtvec.length = @Wallhgt_draw
pt0b = @pts[0].offset(hgtvec)
pt1b = @pts[1].offset(hgtvec)
pt2b = offset_start_pt.offset(hgtvec)
pt3b = offset_end_pt.offset(hgtvec)
view.draw(GL_LINE_STRIP, pt0b, pt1b)
view.draw(GL_LINE_STRIP, pt0b, pt2b)
view.draw(GL_LINE_STRIP, pt2b, pt3b)
view.draw(GL_LINE_STRIP, pt3b, pt1b)
view.draw(GL_LINE_STRIP, @pts[0], pt0b)
view.draw(GL_LINE_STRIP, @pts[1], pt1b)
view.draw(GL_LINE_STRIP, offset_start_pt, pt2b)
view.draw(GL_LINE_STRIP, offset_end_pt, pt3b)
end
#################
# Temp Dimension
vector_ext = wallvec2.clone.reverse!
vector_ext.length = 18.0
vector_ext_off = wallvec2.clone.reverse!
vector_ext_off.length = 1.5
vector_dim = wallvec2.clone.reverse!
vector_dim.length = 12.0
ext_start_pt1 = @pts[0].offset(vector_ext)
ext_end_pt1 = @pts[1].offset(vector_ext)
ext_start_pt0 = @pts[0].offset(vector_ext_off)
ext_end_pt0 = @pts[1].offset(vector_ext_off)
dim_start_pt = @pts[0].offset(vector_dim)
dim_end_pt = @pts[1].offset(vector_dim)
view.drawing_color = "#0000ff"
view.line_width = 1
view.draw(GL_LINE_STRIP, ext_start_pt0, ext_start_pt1)
view.draw(GL_LINE_STRIP, ext_end_pt0, ext_end_pt1)
view.draw(GL_LINE_STRIP, dim_start_pt, dim_end_pt)
# Draw Arrow Heads (triangle)
if @width > 14
vector_xh = wallvec2.clone
vector_xh.length = 1.5
vector_yh = wallvec.clone
vector_yh.length = 7.0
ah01 = dim_start_pt.offset(vector_xh)
ah02 = dim_start_pt.offset(vector_xh.reverse)
ah01 = ah01.offset(vector_yh)
ah02 = ah02.offset(vector_yh)
view.draw(GL_POLYGON, dim_start_pt, ah01, ah02)
ah11 = dim_end_pt.offset(vector_xh)
ah12 = dim_end_pt.offset(vector_xh.reverse)
ah11 = ah11.offset(vector_yh.reverse)
ah12 = ah12.offset(vector_yh.reverse)
view.draw(GL_POLYGON, dim_end_pt, ah11, ah12)
end
textoptions = {
:font => "Arial",
:size => 14,
:bold => false,
:color => "0000ff",
:align => TextAlignCenter
}
midx = (@pts[0].x + @pts[1].x) * 0.5
midy = (@pts[0].y + @pts[1].y) * 0.5
midz = (@pts[0].z + @pts[1].z) * 0.5
midpoint = [midx, midy, midz]
vector_dim.length = 20.0
dimpt = midpoint.offset(vector_dim)
view.draw_text(view.screen_coords(dimpt), @width.to_s, textoptions)