[Solved]Cannot insert DraftText to TechDraw page.

Discussions about the development of the TechDraw workbench
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

[Solved]Cannot insert DraftText to TechDraw page.

Post by chakkree »

I cannot insert DraftText to TechDraw page.
I think, it maybe from Draft Annotation rename to "DraftText".

DraftText2TechDraw.png
DraftText2TechDraw.png (313.22 KiB) Viewed 943 times
DratText2TechDraw.FCStd
(115.77 KiB) Downloaded 28 times

-------------------------------------
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13870 (Git)
Build type: Release
Branch: master
Hash: f0964a9c052ee666631cd9caec1655790964ecb6
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)
Last edited by chakkree on Sat Jun 02, 2018 3:33 am, edited 1 time in total.
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Cannot insert DraftText to TechDraw page.

Post by yorik »

Indeed, thanks for reporting. This is now fixed in git commit 93eb05b1b
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Cannot insert DraftText to TechDraw page.

Post by chakkree »

yorik wrote: Fri Jun 01, 2018 2:06 pm Indeed, thanks for reporting. This is now fixed in git commit 93eb05b1b
Thank you very much.
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: [Solved]Cannot insert DraftText to TechDraw page.

Post by chakkree »

The first image use inserts draft button.
The second image uses the macro to manage each piece of Draft Object by function Draft.getSVG() to generate each SVG's element with different line type and line width of grids group.

Draft2PageBottom.png
Draft2PageBottom.png (165.96 KiB) Viewed 898 times
Draft2PageMacro.png
Draft2PageMacro.png (178.33 KiB) Viewed 898 times

Code: Select all

#-*- coding:utf8 -*-
import FreeCADGui
import Draft 


def TestGetSVG():
    import Draft
    sel = FreeCADGui.Selection.getSelection()[0]
    for obj in sel.OutList:
        Msg('%s , %s '%( obj.Label  , Draft.getType(obj)  ) )
        Msg(', %s'%(Draft.getSVG(obj , scale=0.01 ,linestyle='5,2,1,2' ) ))
        Msg('\n')

SVGHead = '''<svg
xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace">
'''
SVGTail='</svg>'

def TestGetSVG2():    
    svg = ''
    sel = FreeCADGui.Selection.getSelection()[0]
    for obj in sel.OutList:
        if Draft.getType(obj) in ['Wire' ]:
            if obj.Label[:4]=='Grid':
                svg += Draft.getSVG(obj , scale=0.01 , linestyle='5,1.5,1,1.5' ,
                        linewidth=0.18, techdraw=True)
            else:
                svg += Draft.getSVG(obj , scale=0.01 , 
                        linewidth=0.35, techdraw=True)
        elif Draft.getType(obj) in ['Dimension' ]:
            svg += Draft.getSVG(obj , scale=0.01,linewidth=0.25,techdraw=True )
        elif Draft.getType(obj) in [ 'Circle' , 'Ellipse' ,'Rectangle' , 'Polygon' ]:
            svg += Draft.getSVG(obj , scale=0.01,linewidth=0.25,techdraw=True )
        elif Draft.getType(obj) in [ 'ShapeString' ,'DraftText']:
            svg += Draft.getSVG(obj , scale=0.01, fontsize=3, linewidth=0, techdraw=True )
        
    #Msg('%s\n'%svg)
    svg = SVGHead + svg + SVGTail



    symbol = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewSymbol','Symbol')
    symbol.Symbol = svg
    symbol.Scale = 1/100.0*3.78
    FreeCAD.ActiveDocument.Page.addView(symbol)
    FreeCAD.ActiveDocument.recompute()

if __name__=='__main__':
    #TestGetSVG()
    TestGetSVG2()
    
"""
sel = FreeCADGui.Selection.getSelection()[0]
Draft.getSVG(sel,scale=0.01 , techdraw=True)
Draft.getType(sel)

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):


isinstance(sel,Part.Shape)

"""
TestGridGroup2TechDraw.py
(2.04 KiB) Downloaded 22 times
TestGridGroup2TechDraw.FCStd
(115.33 KiB) Downloaded 41 times
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [Solved]Cannot insert DraftText to TechDraw page.

Post by yorik »

Nice! It made me notice and fix a bug, draft texts were not appearing on file load...
Post Reply