Draftからsvg変換の線幅が0.35固定となっている。

Japanese forum
3939yoshi
Posts: 19
Joined: Thu Mar 02, 2017 5:24 am

Re: Draftからsvg変換の線幅が0.35固定となっている。

Post by 3939yoshi » Fri Mar 24, 2017 6:41 am

寸法線や角度寸法線の数値表示に於いて、小数点以下の余分な 0 を取り除く修正です。
このみの問題ですが。

DraftGui.py内です。

Code: Select all

def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=None):
    '''return an internal value (ie mm) Length or Angle converted for display according 
    to Units Schema in use. Unit can be used to force the value to express in a certain unit'''
    from FreeCAD import Units
    if dim == 'Length':
        q = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Length)
        if not unit:
            if (decimals == None) and showUnit:
                return q.UserString
            conversion = q.getUserPreferred()[1]
            uom = q.getUserPreferred()[2]
        else:
            uom = unit
            internValue = q.getValueAs(unit)
            conversion = 1
    elif dim == 'Angle':
        return FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Angle).UserString
    else:
        conversion = 1.0
        if decimals == None:
            decimals = 2
        uom = "??"
    if not showUnit:
        uom = ""
    fmt = "{0:."+ str(decimals) + "f} "+ uom
    displayExt = fmt.format(float(internValue) / float(conversion))
    displayExt = displayExt.replace(".",QtCore.QLocale().decimalPoint())
    return displayExt

Code: Select all

def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=None):
    '''return an internal value (ie mm) Length or Angle converted for display according 
    to Units Schema in use. Unit can be used to force the value to express in a certain unit'''
    from FreeCAD import Units
    if dim == 'Length':
        q = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Length)
        if not unit:
            if (decimals == None) and showUnit:
                return q.UserString
            conversion = q.getUserPreferred()[1]
            uom = q.getUserPreferred()[2]
        else:
            uom = unit
            internValue = q.getValueAs(unit)
            conversion = 1
    elif dim == 'Angle':
        uq = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Angle)
        uom = ""
        internValue = uq.Value
        conversion = 1
    else:
        conversion = 1.0
        if decimals == None:
            decimals = 2
        uom = "??"
    if not showUnit:
        uom = ""
    fmt = "{0:."+ str(decimals) + "f} "
    displayExt = fmt.format(float(internValue) / float(conversion))
    if '.' in displayExt :
        displayExt = displayExt.rstrip("0 ")
        displayExt = displayExt.rstrip(".")
    displayExt = displayExt.replace(".",QtCore.QLocale().decimalPoint()) + uom
    return displayExt
図枠も作成したので、それらしいJIS製図ができそうです。
今回はこれで終わりの予定です。
3939yoshi
Posts: 19
Joined: Thu Mar 02, 2017 5:24 am

Re: Draftからsvg変換の線幅が0.35固定となっている。

Post by 3939yoshi » Sun Mar 26, 2017 11:44 pm

「寸法線や角度寸法線の数値表示に於いて、小数点以下の余分な 0 を取り除く修正です。」の修正です。エラーが発生していたので修正しました。

Code: Select all

def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=None):
    '''return an internal value (ie mm) Length or Angle converted for display according 
    to Units Schema in use. Unit can be used to force the value to express in a certain unit'''
    from FreeCAD import Units
    if dim == 'Length':
        q = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Length)
        if not unit:
            if (decimals == None) and showUnit:
                return q.UserString
            conversion = q.getUserPreferred()[1]
            uom = q.getUserPreferred()[2]
        else:
            uom = unit
            internValue = q.getValueAs(unit)
            conversion = 1
    elif dim == 'Angle':
        return FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Angle).UserString
    else:
        conversion = 1.0
        if decimals == None:
            decimals = 2
        uom = "??"
    if not showUnit:
        uom = ""
    fmt = "{0:."+ str(decimals) + "f} "+ uom
    displayExt = fmt.format(float(internValue) / float(conversion))
    displayExt = displayExt.replace(".",QtCore.QLocale().decimalPoint())
    return displayExt

Code: Select all

def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=None):
    '''return an internal value (ie mm) Length or Angle converted for display according 
    to Units Schema in use. Unit can be used to force the value to express in a certain unit'''
    from FreeCAD import Units
    if dim == 'Length':
        q = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Length)
        if not unit:
            if (decimals == None) and showUnit:
                return q.UserString
            conversion = q.getUserPreferred()[1]
            uom = q.getUserPreferred()[2]
        else:
            uom = unit
            internValue = q.getValueAs(unit)
            conversion = 1
    elif dim == 'Angle':
        uq = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Angle)
        uom = ""
        internValue = uq.Value
        conversion = 1
        if decimals is None:
            decimals = 2
    else:
        conversion = 1.0
        if decimals == None:
            decimals = 2
        uom = "??"
    if not showUnit:
        uom = ""
    fmt = "{0:."+ str(decimals) + "f}"
    displayExt = fmt.format(float(internValue) / float(conversion))
    if '.' in displayExt :
        displayExt = displayExt.rstrip("0 ")
        displayExt = displayExt.rstrip(".")
    displayExt = displayExt.replace(".",QtCore.QLocale().decimalPoint()) + uom
    return displayExt
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest