NateLiquidGravity
Alibre Super User
Send Part Model View to DXF
A few notes though:
* The part file must be saved or the view can't be made and if the saved part file is obsolete so will be the DXF made from it.
* It worked fine when I open the part in its own session - but did not work if the part is opened from an assembly session.
* Since it is projected into the drawing any edge not parallel to the plane of view will not be true length. In this picture the overall scale is off only due to zoom, but since most of those lines are not parallel to the view they will not be true length measure in the DXF either.
Here is my AlibreScript code for that:
A few notes though:
* The part file must be saved or the view can't be made and if the saved part file is obsolete so will be the DXF made from it.
* It worked fine when I open the part in its own session - but did not work if the part is opened from an assembly session.
* Since it is projected into the drawing any edge not parallel to the plane of view will not be true length. In this picture the overall scale is off only due to zoom, but since most of those lines are not parallel to the view they will not be true length measure in the DXF either.
Here is my AlibreScript code for that:
Python:
from __future__ import division # This fixes division with integers. For example the 1 / 2 = 0.5 instead of 0
import clr
import os
import _winreg
Root = Global.Root
Win = Windows()
def getalibrepath():
try:
keystring = r'SOFTWARE\Alibre, Inc.\Alibre Design' + '\\' + str(Global.Root.Version).split(' ')[1].replace(',', '.')
# printpass(keystring)
hKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, keystring)
result = _winreg.QueryValueEx(hKey, 'HomeDirectory')
# printpass(result[0])
return result[0]
except Exception, e:
print(e)
try:
hKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Alibre, Inc.\\Alibre Design')
result = _winreg.QueryValueEx(hKey, 'HomeDirectory')
return result[0]
except Exception, e:
print(e)
return ''
return '' # technically unreachable
ADPath = os.path.join(getalibrepath(), 'Program')
sys.path.append(ADPath)
clr.AddReference('AlibreX.dll')
from AlibreX import ADUnits, ADDrawingViewType, ADDetailingOption, ADViewOrientation, IAD2DPoint, IADTransformation
prt = CurrentPart()
AD_prt = prt._Part
trans = AD_prt.ViewTransform
my_drawing = Root.CreateEmptyDrawing(str(prt.Name))
point_orgin = my_drawing.GeometryFactory.Create2DPoint(0.0,0.0)
test_sheet = my_drawing.Sheets.CreateBlankSheet('Exported From Model Space', 1.0, 1.0, ADUnits.AD_CENTIMETERS, 1.0, 1.0)
test_sheet.CreateStandardViews(str(prt.FileName), ADDrawingViewType.AD_STANDARD, ADDetailingOption.AD_TANGENT_EDGES, 1.0, 1.0, ADViewOrientation.AD_FRONT, point_orgin, trans)
savePath = Win.SaveFileDialog('Save the DXF', 'DXF Files|*.DXF', '.DXF')
if savePath:
my_drawing.ExportDXF(savePath)
print('Saved')
else:
print('Canceled')
my_drawing.Close(0)