adding dimensions to a TechDraw page based on shape

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
sdementen
Posts: 7
Joined: Wed Jun 09, 2021 4:12 am

adding dimensions to a TechDraw page based on shape

Post by sdementen »

hello,

I have a set of <Part::PartFeature> created with Part.makeBox(...).
I have added to the document a TechDraw::DrawPage page and then a "TechDraw::DrawViewPart" view of my boxes.

I would like to add dimensions on this TechDraw::DrawPage page for some edges of some boxes (one of the top edges).

I can identify the right edges I like from the boxes (TechDraw::DrawPage) by iterating on the obj.Shape.Edges (ie, I have a list of such Edges).
How can I give the a dimension a reference to these edges ?
I have tried the following

Code: Select all

dim = doc.addObject("TechDraw::DrawViewDimension", "Dimension")
dim.Type = "DistanceX"
dim.References3D = [
    (doc.getObject("id_of_my_box"),"Edge10",),
]
but it complains that "Dimension has no 2D References".
If References2D is required, how can I map it from the References3D?
edi
Posts: 482
Joined: Fri Jan 17, 2020 1:32 pm

Re: adding dimensions to a TechDraw page based on shape

Post by edi »

A simple distance dimension in TechDraw is created using

Code: Select all

dim = TechDraw.makeDistanceDim(DrawViewPart,dimType,fromPoint,toPoint)
where:
DrawViewPart ... the selected View
dimType ... 'Distance','DistanceX','DistanceY'
fromPoint, toPoint ... two points

After creation you can change all properties (found in the combo-view)

Code: Select all

dim.X = ...x-position of the measure value
dim.LockPosition = 'True'
dim.UnderTolerance = ...
...
Post Reply