how to add dimensions in TechDraw?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
drawman01
Posts: 1
Joined: Thu Aug 11, 2022 5:40 am

how to add dimensions in TechDraw?

Post by drawman01 »

(possibly a very basic question, but neither the documentation nor previous posts on the forum cleared it up for me at all)

So I've been making a Macro which takes dimensions and outputs a drawing svg. I managed to code it to create the object and project it to the page, but I for the life of mine am unable to figure out how to add atleast the basic dimensions like length and height of the object through python console.

this is the projection code if it matters:

Code: Select all

App.activeDocument().addObject('TechDraw::DrawProjGroup', 'testProj')
App.activeDocument().testPage.addView(App.activeDocument().testProj)
App.ActiveDocument.testProj.Source = App.ActiveDocument.Body
App.activeDocument().testProj.addProjection('Front')
App.activeDocument().testProj.Anchor.Direction = FreeCAD.Vector(0.000,0.000,1.000)
App.activeDocument().testProj.Anchor.RotationVector = FreeCAD.Vector(1.000,0.000,0.000)
App.activeDocument().testProj.Anchor.XDirection = FreeCAD.Vector(1.000,0.000,0.000)
App.activeDocument().testProj.addProjection('Bottom')
App.activeDocument().testProj.addProjection('Right')
App.activeDocument().testProj.Y = '150.00 mm'
App.activeDocument().testProj.X = '200.00 mm'
FreeCAD.getDocument('Unnamed').getObject('ProjItem002').HardHidden = True
FreeCAD.getDocument('Unnamed').getObject('ProjItem001').HardHidden = True
App.activeDocument().recompute()
TIA
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: how to add dimensions in TechDraw?

Post by wandererfan »

drawman01 wrote: Thu Aug 11, 2022 5:48 am So I've been making a Macro which takes dimensions and outputs a drawing svg. I managed to code it to create the object and project it to the page, but I for the life of mine am unable to figure out how to add atleast the basic dimensions like length and height of the object through python console.
The dimension test script here: src/Mod/TechDraw/TDTest/DrawViewDimensionTest.py should get you started.
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: how to add dimensions in TechDraw?

Post by edi »

Maybe an additional help, you find the file in: https://github.com/FreeCAD/FreeCAD/tree ... raw/TDTest
Post Reply