User Tools

This is an old revision of the document!


Techdraw

Update cartridge

# get time
def getTime():
	from datetime import datetime
	now = datetime.now()
	return now.strftime("%d/%m/%Y %H:%M:%S")
# get author
def getAuthor():
	doc = App.ActiveDocument
	return doc.CreatedBy.title()

#convert scale
def convertScale(scale):
	left = 1
	right = 1
	if scale > 1:
		left = scale
		right = 1
	elif scale < 1:
		left = 1
		right = 1 / scale
	return str(left)+":"+str(right)

# update values
def updateValues(author, time):
	s = FreeCADGui.Selection.getSelection()

	if len(s) < 1:
		print ("Please select 1 TechDraw Page")
		return

	for item in s:
		#print ("Object in selection is a: ", item.TypeId)
		if item.isDerivedFrom("TechDraw::DrawPage"):
			for o in item.OutList:
				if o.TypeId == "TechDraw::DrawSVGTemplate":
					texts = o.EditableTexts.copy()
					texts["DRAWING_TITLE"] = item.Label
					texts["FC-SC"] = convertScale(item.Scale)
					texts["AUTHOR_NAME"] = author
					texts["FC-DATE"] = time
					o.EditableTexts = texts
	return

updateValues(getAuthor(), getTime())

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information