[bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
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!
[bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
Hello.
I may be mistaken, but I wasn't able to force ArchView to show arch. dLabel.
dLabel is included in my arch. section, the section is configured to show everything (only_solids=False), The arch. view is based on that section, and it has All On=True. The original section has dLabel with an area of a panel (I've made a minimal example with one object and dLabel), but ArchView shows only the panel, but not the dLabel.
I plan to report this as a bug. Any ideas/suggestions? Thanks!
I may be mistaken, but I wasn't able to force ArchView to show arch. dLabel.
dLabel is included in my arch. section, the section is configured to show everything (only_solids=False), The arch. view is based on that section, and it has All On=True. The original section has dLabel with an area of a panel (I've made a minimal example with one object and dLabel), but ArchView shows only the panel, but not the dLabel.
I plan to report this as a bug. Any ideas/suggestions? Thanks!
- Attachments
-
- no_dLabel.fcstd
- (9.77 KiB) Downloaded 31 times
- wandererfan
- Veteran
- Posts: 6324
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
Wow, ArchSection is in Python. I'll try to send a pull request with a fix, if this can be done with a small blood.
Re: [bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
I almost done.
I found where it's been rendered and was able to write a value on resulting ArchView.
Now I need to draw lines.
A Label consists of Text, StraightLine, and Arrow (pointing to Target). StraightLine have two directions: Vertical and Horizontal.
I can steal Arrow code from Dimension implementation, but math with lines is too hard for me.
I have following data:
Placement.Base (x,y,z)
TargetPoint (x,y,z)
StrightDistance (one number)
StrightDirection (horizontal or vertical)
My current research on Label behavior (in 3D) is:
Text is aligned on left of the Placement.
StraightLine is drawn from Placement in a given StraighDirection (H/V),
from there an arrow is drawn toward TargetPoint.
My math (please, please check and fix this):
Horizontal:
Middle_point[x,y,z] = Placement[x+StrightDirection, y, z]
Vertical:
Middle_point[x,y,z]=Placement[x, y+StrightDirection, z]
Then I need to do getProj to each point to get it position on 2D plane.
Do I do it right?
I found where it's been rendered and was able to write a value on resulting ArchView.
Now I need to draw lines.
A Label consists of Text, StraightLine, and Arrow (pointing to Target). StraightLine have two directions: Vertical and Horizontal.
I can steal Arrow code from Dimension implementation, but math with lines is too hard for me.
I have following data:
Placement.Base (x,y,z)
TargetPoint (x,y,z)
StrightDistance (one number)
StrightDirection (horizontal or vertical)
My current research on Label behavior (in 3D) is:
Text is aligned on left of the Placement.
StraightLine is drawn from Placement in a given StraighDirection (H/V),
from there an arrow is drawn toward TargetPoint.
My math (please, please check and fix this):
Horizontal:
Middle_point[x,y,z] = Placement[x+StrightDirection, y, z]
Vertical:
Middle_point[x,y,z]=Placement[x, y+StrightDirection, z]
Then I need to do getProj to each point to get it position on 2D plane.
Do I do it right?
- wandererfan
- Veteran
- Posts: 6324
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
This is mostly correct. Change only X to move horizontally, change only Y to move vertically. But you can't add vectors and scalars.amarao wrote: ↑Mon Oct 22, 2018 9:25 pm Placement.Base (x,y,z)
TargetPoint (x,y,z)
StrightDistance (one number)
StrightDirection (horizontal or vertical)
<snip>
My math (please, please check and fix this):
Horizontal:
Middle_point[x,y,z] = Placement[x+StrightDirection, y, z]
Vertical:
Middle_point[x,y,z]=Placement[x, y+StrightDirection, z]
Try this instead:
x+StrightDistance
y+StrightDistance
Re: [bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
I replied more on https://forum.freecadweb.org/viewtopic. ... 86#p264086
But basically the way this works ATM, you must produce an SVG which is a projected (and scaled) representation of the 3D view. Indeed you can reuse many of the existing pieces in Draft.getSVG. To draw the lines, you basically need the 3 points of the line in the 3D view, then you can simply create an SVG path with them. The Draft Label has a Points property which holds those 3 points, that are updated automatically. Then you use getProj() with each of these points to get their projected position. The scaling is done automatically later on by putting everything inside a transform element, so you normally don't need to worry about that
But basically the way this works ATM, you must produce an SVG which is a projected (and scaled) representation of the 3D view. Indeed you can reuse many of the existing pieces in Draft.getSVG. To draw the lines, you basically need the 3 points of the line in the 3D view, then you can simply create an SVG path with them. The Draft Label has a Points property which holds those 3 points, that are updated automatically. Then you use getProj() with each of these points to get their projected position. The scaling is done automatically later on by putting everything inside a transform element, so you normally don't need to worry about that
Re: [bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
Oh, thanks a lot! You are really helping me!
My current work is here (I got a little time yesterday, so it still at 'label only' state, I plan to continue this evening):
https://github.com/amarao/FreeCAD/tree/addSVGtoLabel
I have two more questions:
1. My line is too thin (I tried to make it as '<path d="Mx1,y1 Lx2,y2">'). It is, but it almost invisible. How can I make it the same thickness as dimensions lines (I suppose label lines should look similar to dimension lines).
2. I found that resulting SVG contains two my <path>es after I make a single svg+= operation. One in <g> section and it is visible in inspection in Inkscape, and second one is invisible, but present.
I don't know if #2 is an issue or it's supposed to be this way.
My current work is here (I got a little time yesterday, so it still at 'label only' state, I plan to continue this evening):
https://github.com/amarao/FreeCAD/tree/addSVGtoLabel
I have two more questions:
1. My line is too thin (I tried to make it as '<path d="Mx1,y1 Lx2,y2">'). It is, but it almost invisible. How can I make it the same thickness as dimensions lines (I suppose label lines should look similar to dimension lines).
2. I found that resulting SVG contains two my <path>es after I make a single svg+= operation. One in <g> section and it is visible in inspection in Inkscape, and second one is invisible, but present.
I don't know if #2 is an issue or it's supposed to be this way.
- wandererfan
- Veteran
- Posts: 6324
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
There is a line thickness parameter. Does it not work?
From ArchSection.py
def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale=1, rotation=0, linewidth=1, lineColor=(0.0,0.0,0.0), fontsize=1, showFill=False, fillColor=(0.8,0.8,0.8), techdraw=False):
From Draft.py
def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False,rotation=0):
Re: [bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
It worked, thank you.wandererfan wrote: ↑Wed Oct 24, 2018 12:12 pmThere is a line thickness parameter. Does it not work?
From ArchSection.py
def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale=1, rotation=0, linewidth=1, lineColor=(0.0,0.0,0.0), fontsize=1, showFill=False, fillColor=(0.8,0.8,0.8), techdraw=False):
I made a second part (line). It looks like this (this example have Dimension and Label, Label is on the left): Here is my code: https://github.com/amarao/FreeCAD/commi ... 1fa4578291
I'll work on the arrow in a few days.
Few things which are bother me now:
1) ArchView section border is smaller than resulting picture - my label is cut by the view border. How can I extend that border?
2) There are tons of properties in the dLabel: 2D/3D view, Text Align, Line Width, etc. I not really understand how they should translate into rendering (f.e. should I take in account line width?). I have no idea how to do text align (top/middle/bottom), and what to do with 2D/3D thing?
The last one I just do not understand. What 3D or 2D view for label means?
Re: [bug] no dLabel from Arch. Section in Arch. view (TechDrawing)
Very good! Pretty elegant code.. I wouldn't worry too much about supporting each and every feature of the Drat label to start with... Better first have a basic code working, then you or anyone else can refine things later on.
The 2D/3D thing is only used in the 3D view (it defines if the text stays perpendicular to the view direction or not), so it's of no use when projecting in 2D.
The 2D/3D thing is only used in the 3D view (it defines if the text stays perpendicular to the view direction or not), so it's of no use when projecting in 2D.