Units in exported STEP files

60 views
Skip to first unread message

0E9B061F

unread,
Jan 22, 2024, 5:47:14 AM1/22/24
to CadQuery
Is there any way to control the units used in STEP files exported from CadQuery? They seem to use millimeters by default which is making my parts much smaller than I had intended - I designed them so that 1 unit is 1 inch, not 1 millimeter.

Liam Nordvall

unread,
Jan 22, 2024, 12:17:30 PM1/22/24
to CadQuery
Nothing that I've tried but reading the documentation you should be able to use the doc_units parameter in the export function. Read the table at the end of the link to see what number cooresponds to 1 inch, in your case doc_units = 1.
So I assume without testing that you could write exporters.exportStep(result, doc_units=1). Try that out and let me know it it worked! 
Alternativly you can write a function like toInch were you use that in every meassurment.

Jeremy Wright

unread,
Jan 22, 2024, 1:00:21 PM1/22/24
to Liam Nordvall, CadQuery

--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/7b8e223a-9e91-4790-a40f-251e0f4ee8b1n%40googlegroups.com.

0E9B061F

unread,
Jan 22, 2024, 4:39:14 PM1/22/24
to CadQuery
It seems like `doc_units` must only work with the DXF exporter. `cq.exporters.export(wp, 'path.step', doc_units=1)` produces an error,  `cq.exporters.export(wp, 'path.step', opt={'doc_units': 1})` seem to do nothing (the exported STEP files are still in millimeters). I could use a function like `toInch` but my code is already pretty complex (I should have tested exporting a lot sooner, now I have a headache). I think I might try just editing the step files after exporting.

Adam Urbanczyk

unread,
Jan 23, 2024, 3:52:53 AM1/23/24
to CadQuery
Not currently implemented in CQ, but you can always use the OCCT API directly. E.g. setting units to um:

import OCP

w = OCP.STEPControl.STEPControl_Writer()
OCP.Interface.Interface_Static.SetCVal_s("write.step.unit","UM")

NB: This seems to be a global operation in OCCT
Reply all
Reply to author
Forward
0 new messages