Hello all,
I use AutoCAD to generate NURBS surfaces and subsequently use this model in a numerical analysis program. I export the model as a .DXF file (2010 version) and a small script extracts the important data. However, I cannot find where the control point weights are saved in the .DXF file. I searched everywhere, but I cannot figure it out. Can anybody help on this?
Thanks a lot.
Camiel
Solved! Go to Solution.
Solved by leeminardi. Go to Solution.
Solved by john.vellek. Go to Solution.
Hi @Anonymous,
I see that you are visiting as a new member to the AutoCAD forum. Welcome to the Autodesk Community!
Is there a reason to go to such an old version of DXF? I believe there were some problems with NURBS and SPLINEs back in this 2010 version.
Here is a reference for 2018 DXF .
41 looks like it might be weight for SPLINES but I am not sure if this is exactly what you are looking for. Please take a look and let me know if this helps. You can also attach a sample file so I can try crating the DXF to analyze the codes too.
Please select the Accept as Solution button if my post solves your issue or answers your question.
Thank you for your reaction.
The previous people who worked on this project have chosen to use AutoCAD 2010 DXF versions. I think that some of the people involved still use (very) old versions of AutoCAD, but I am also not exactly sure why they chose this file format. Nevertheless, many scripts are written entirely around this version and adapting these would last forever.
The link in your reply doesn't work, but I already found such a reference (thanks anyway). I uploaded a file ('Half_Circle_Surface.DXF'), where I use only 5x2 control vertices to represent the surface. This means that the weights of the NURBS functions in the corners should be 0.5*sqrt(2), otherwise the half circle geometry is not exactly parametrized. However, when I open the .DXF with a file editor, it seems that this value is not even in the file. That's the reason I posted my first message here. I hope it is clear what I mean.
Any help would be great!
Thank you.
Camiel
I exploded the semi-cylindrical surface and then used SPLINEDIT to examine the weights of the semi-circular shaped NURBS spline. The 5 CVs all had a weight of 1. I then changed one of the weights to 123.4 (it almost squares the corner) and saved the file as a 2010 dxf file. Doing a search for 123.4 showed it did follow a dxf code 41.
So it appears the weight may be in the dxf file. If weight are all 1 the 41 is not recorded.
Lee
Thank you for your reaction ( and the help 🙂 ).
So I understand that AutoCAD only writes the control point weights if these differ from 1.0 (under the dxf code 41). What I don't understand is that you mention 'semi-cylindrical' surface, since I generated this surface by trimming a circle in half and subsequently lofting it to become a surface. Theory then tells us that the control point weight (when located exactly at the corner) should be (1/2)*sqrt(2). I don't get how AutoCAD can construct the cylindrical surface with a corner cv weight of 1.0.
So in a standard sense, AutoCAD always sets the weights to 1.0?
Thank you,
Camiel
The Spline, as a native AutoCAD entity type, stores the Control Vertex “Weight” values in a DXF file in accordance with the DXF reference. Regions, 3dSolids, Bodys and Surfaces are handled by the ACIS based modeler. The DXF file stores that in an encrypted format. I suspect the “Weight” info from your original DXF file is stored somewhere in here:
AcDbModelerGeometry 70 1 1 mnjoo li m mk 1 ni ^ *+0;:,4 ^ *+0\^ [ nf ^ LR mmmqoqoqnhoo QK o 1 n fqfffffffffffffffjkh:roh nqooooooooooooooooli:rno 1 >,27:>;:- {rn rn _nm mmmqoqoqnhoo | 1 =0;& {rn rn {rn {m {rn {rn | 1 3*2/ {rn rn {rn {rn {l {n | 1 ,7:33 {rn rn {rn {rn {rn {k {rn {m | 1 9><: {j rn {rn {rn {i {l {rn {h 90-(>-; ;0*=3: 0*+ | 1 /:-,*=:1+r><>;L036;W6,+0-&r>++-6= {rn rn {rn {rn {k n j n n | 1 300/ {rn rn {rn {rn {g {k | 1 ,/361:r,*-9><: {rn rn {rn -:):-,:; $ :'><+@,/3@,*- mmmoo 9*33 1*-=, n m ) 0/:1 0/:1 101: 101: m l 1 o n m n 1 o m nqjhohfilmihfkgfijjg m lqnknjfmijljgfhfmihm m 1 mj o o n 1 mj o jo n 1 mkqffffffffffffffmgf mkqffffffffffffffmgf o oqhohnoihgnngijkhiglg 1 mkqffffffffffffffmgf mkqffffffffffffffmgf jo oqhohnoihgnngijkhiglg 1 rhqoillhjofgifoimjnoj:rnh mj o n 1 rhqoillhjofgifoimjnoj:rnh mj jo n 1 rmkqffffffffffffffmgf mkqffffffffffffffmgf o oqhohnoihgnngijkhiglg 1 rmkqffffffffffffffmgf mkqffffffffffffffmgf jo oqhohnoihgnngijkhiglg 1 rmj o o n 1 rmj o jo n 1 o 1 1 o 1 o 1 o 1 o 1 o 1 o 1 Y Y n Y o Y n Y o JQZGKZQ[Z[ " V V V V | 1 <0:;8: {rn rn {rn {f {no {rn {nn 90-(>-; {i {nm | 1 <0:;8: {rn rn {rn {nl {g {rn {nk 90-(>-; {i {nj | 1 <0:;8: {rn rn {rn {g {nl {rn {ni 90-(>-; {i {nh | 1 :;8: {ng rn {rn {nf o {mo lqnknjfmijljgfhfmihm {g {mn 90-(>-; _h *1410(1 | 1 /<*-): {rn rn {rn o 90-(>-; $ :'/@/>-@<*- 1*=, n 0/:1 m 1 o n lqnknjfmijljgfhfmihm n 1 o o 1 o lqnknjfmijljgfhfmmmg 1 nqlnkhhnkggkoholgoli:rnl 1 ,/361: -:):-,:; $ -:9 o " V V V V 1 " o o | 1 <0:;8: {rn rn {rn {no {f {rn {mm 90-(>-; {i {ml | 1 :;8: {mk rn {rn {mo o {mj jo {f {mi 90-(>-; _h *1410(1 | 1 /<*-): {rn rn {rn o 90-(>-; $ :'/@/>-@<*- 1*=, n 0/:1 m 1 o n jo n 1 o lqnknjfmijljgfhfmmmg 1 nqfffffffffffffffhhg lqnknjfmijljgfhfmmmg 1 mqnhhonfoilnlgmgkjn:rnk 1 ,/361: -:):-,:; $ -:9 o " V V V V 1 " o o | 1 :;8: {mh rn {rn {mg o {nf jo {no {mf 90-(>-; _h *1410(1 | 1 /<*-): {rn rn {rn o 90-(>-; $ :'/@/>-@<*- 1*=, n 0/:1 m 1 o n jo n 1 m o 1 o o 1 lqimlhihfjmlhijnnonn:rnj 1 ,/361: -:):-,:; $ -:9 o " V V V V 1 " o o | 1 /:-,*=:1+r><>;L036;W6,+0-&r>++-6= {rn rn {rn {rn {nn n j n no | 1 ):-+:' {rn rn {rn {ni n {lo | 1 ):-+:' {rn rn {rn {nn n {ln | 1 61+<*-):r<*-): {rn rn {rn 90-(>-; $ :'><+@61+@<*- mmmoo 9*33 1*-=, m 0/:1 l 1 o m nqjhohfilmihfkgfilli m lqnknjfmijljgfhfmihm m 1 mj o o n 1 mj mkqffffffffffffffmgf o oqhohnoihgnngijkhhfkg 1 hqonnmgfghnohloignh:rnj mj o n 1 rmkqfffffffffffffgjhf mjqoooooooooooooohnn o oqhohnoihgnngijkhljoh 1 rmj nqknilgkhmkknnffkggk:rnk o n 1 o 1 1 1*33@,*-9><: 1 1*33@,*-9><: 1 1*33=, 1 1*33=, 1 V V 1 o 1 o 1 o 1 1 o Y n Y o JQZGKZQ[Z[ JQZGKZQ[Z[ " V V | 1 :;8: {lm rn {rn {mj rlqnknjfmijljgfhfmihm {mg o {nl {ll 90-(>-; _h *1410(1 | 1 /<*-): {rn rn {rn o 90-(>-; $ :'/@/>-@<*- 1*=, n 0/:1 m 1 rlqnknjfmijljgfhfmihm n ro n 1 nqfffffffffffffffllk lqnknjfmijljgfhfmmmg 1 m o 1 nqmjnigmiollmlfiikgj:rnl 1 ,/361: -:):-,:; $ -:9 o " V V V V 1 " o o | 1 /:-,*=:1+r><>;L036;W6,+0-&r>++-6= {rn rn {rn {rn {nk m j n noonn j n moomn | 1 ):-+:' {rn rn {rn {nk n {lk | 1 61+<*-):r<*-): {rn rn {rn 90-(>-; $ :'><+@61+@<*- mmmoo 9*33 1*=, n 0/:1 m 1 o n jo n 1 rmj nqknilgkhmkknnffkggk:rnk o 1 rmj nqknilgkhmkknnffkggk:rnk jo 1 o 1 1 1*33@,*-9><: 1 1*33@,*-9><: 1 1*33=, 1 1*33=, 1 V V 1 o 1 o 1 o 1 1 o Y n Y o JQZGKZQ[Z[ JQZGKZQ[Z[ " V V | 1 /:-,*=:1+r><>;L036;W6,+0-&r>++-6= {rn rn {rn {rn {ni m j n noomn j n moonn | 1 ):-+:' {rn rn {rn {ni o {lj | 1 61+<*-):r<*-): {rn rn {rn 90-(>-; $ :'><+@61+@<*- mmmoo 9*33 1*=, n 0/:1 m 1 o n jo n 1 mj o jo 1 mj o o 1 o 1 1 1*33@,*-9><: 1 1*33@,*-9><: 1 1*33=, 1 1*33=, 1 V V 1 o 1 o 1 o 1 1 o Y n Y o JQZGKZQ[Z[ JQZGKZQ[Z[ " V V | 1 /061+ {rn rn {rn mj o o | 1 /061+ {rn rn {rn rmj nqknilgkhmkknnffkggk:rnk o | 1 /:-,*=:1+r><>;L036;W6,+0-&r>++-6= {rn rn {rn {rn {mm n j n mo | 1 61+<*-):r<*-): {rn rn {rn 90-(>-; $ :'><+@61+@<*- mmmoo 9*33 1*-=, m 0/:1 l 1 rlqnknjfmijljgfhfmihm m rnqjhohfilmihfkgfilli m o m 1 rmj nqknilgkhmkknnffkggk:rnk jo n 1 rmkqfffffffffffffgjhf mjqoooooooooooooohnn jo oqhohnoihgnngijkhljoh 1 hqonnmgfghnohloignh:rnj mj jo n 1 mj mkqffffffffffffffmgf jo oqhohnoihgnngijkhhfkg 1 mj o jo n 1 o 1 1 1*33@,*-9><: 1 1*33@,*-9><: 1 1*33=, 1 1*33=, 1 V V 1 o 1 o 1 o 1 1 o Y n Y o JQZGKZQ[Z[ JQZGKZQ[Z[ " V V | 1 /061+ {rn rn {rn rmj nqknilgkhmkknnffkggk:rnk jo | 1 /061+ {rn rn {rn mj o jo |
There's more to this spline dxf data then I thought.
I created a spline by first making an arc and then lofting it with another arc. I then exploded the surface and deleted all but one spline in the perfect shape of an arc. It is the cyan spline in the image below. I examined the spline using spinedit and it indicates the the corner CVs have a weight of 0.7071 (the other weight are 1.0).
I then created a spline with 5 CVs and changed the weights of the corner CVs to 0.7071 which yields the red spline! Obviously not a match. Looking at the dxf data for the two splines a couple of things jump out. The good cyan spline is degree 2 whereas the bad fit is the default degree 3. You can see this in the dxf data as well and with splinedit, Edit vertex,Elevate ( a default 3 means the spline is now degree 2, a 4 means degree 3). Changing the degree to 2 and using the 0.7071 weight and other noted weights should yield the correct fit.
Here's a good list of the dxf attributes for splines:
https://www.autodesk.com/techpubs/autocad/acad2000/dxf/spline_dxf_06.htm
I think with this information you can extract the weights you need.
Note, I used dxf 2018 for this analysis. I do not know if older versions of dxf provide the same information. In the attached file the good spline is on layer GoodFit and the red spline on layer BadFit.
Lee
@Anonymouswrote:Okay, but it is still strange that I cannot find any weight values that I would expect in the files...
That's the problem with encryption, unfortunately.
It sounds like your workflow employs a script. If that implies AutoLisp, maybe this post contains something useful:
http://www.theswamp.org/index.php?topic=25097.msg302271#msg302271
This part is interesting:
1 mj o o n 1 mj o jo n 1 mkqffffffffffffffmgf mkqffffffffffffffmgf o oqhohnoihgnngijkhiglg 1 mkqffffffffffffffmgf mkqffffffffffffffmgf jo oqhohnoihgnngijkhiglg 1 rhqoillhjofgifoimjnoj:rnh mj o n 1 rhqoillhjofgifoimjnoj:rnh mj jo n 1 rmkqffffffffffffffmgf mkqffffffffffffffmgf o oqhohnoihgnngijkhiglg 1 rmkqffffffffffffffmgf mkqffffffffffffffmgf jo oqhohnoihgnngijkhiglg 1 rmj o o n 1 rmj o jo n
Look at this comparison (figuring the decimal point maps to "q"):
0 . 7071067811865476838
oqhohnoihgnngijkhiglg
Here's an Excel worksheet to Encrypt or Decrypt the values one character at a time.
Is it feasible for you to work with a .sat file that you export from AutoCAD instead of a dxf file? The CV data is fairly easy to read.
For example, here's your surface as a sat file.
I've highlighted the 10 CVs (x y z weight). If the surface is rotated by 45° about the z axis and displaced to 1.23,3.45,6.78 then the sat file looks like this. The CV data remains the same but a transform statement is added.
That indeed looks interesting! Do you know if it is a 'standard' format mapping? or is it a AutoCAD self made encryption?
I wonder how to be sure where the weight information starts for all NURBS drawings in general. I use 'DXFGrabber' ( https://pythonhosted.org/dxfgrabber/ ) in Python to extract information from the DXF file. I don't think it has a functionality to read something like this.
Thank you!
Thank you all for the great help. It is nice to see so many trying to solve this problem.
I also tried to explode the surface and investigated the weights of them. Indeed the famous sqrt(2)/2 value (0.707) shows up! I see that your .sat file shows exactly the results I need in my script. However, I was unclear on what my goal really is. I have a Python program which uses the 'DXFGrabber' library to read the data from the .DXF file (https://pythonhosted.org/dxfgrabber/). I don't think this library has a function to read the NURBS weights, but since these drawings are used in Numerical Analyses, it is pretty important to get the same geometry...
Thanks!!
I have been trying to get the AcDbModelerGeometry list in Python with DXF Grabber, but I cannot find it yet. Does anyone else have some experience with the 'dxfgrabber' library? 🙂
Thank you!
Camiel
@Anonymouswrote:I have been trying to get the AcDbModelerGeometry list in Python with DXF Grabber, but I cannot find it yet. Does anyone else have some experience with the 'dxfgrabber' library? 🙂
Thank you!
Camiel
If I had to guess, you’re going to be on your own with that one. As overwhelming as that may seem, it does offer an opportunity to do some true “trailblazing”.
Take the advice of @leeminardi and analyze the readable version of a SAT file, as well as stepping through some of the material I’ve posted to address the XOR encryption. I’m certain that the portions of the file unavailable through dxfgrabber could be parsed as Text/Characters with the native capabilities of Python.
Okay, I will certainly use your advise. I have AutoCAD 2017 and the latest version in DXF I can save is 2013. I wanted to look whether the control point weight are also written separately (Like the 2018 DXF version), however, the answer is no. The strange thing now is that I thought it is saved in the ModelerGeometry encryption then, but also here I cannot find anything. Could there be yet another way of saving the weights in the 2013 version?
Does anyone know if the weights of the NURBS surface are also are directly specified for an AutoCAD 2018 version (under a 41 code for instance). Then I can consider rewriting everything for the 2018 version and just extract the weights directly.
Thanks!
I don't really have much to add regarding python/DXF/dxfgrabber and Modeler entities.
I will point out, though, that there may be another, somewhat pertinent, option. It sounds like IronPython has access to all of the AutoCAD APIs available to the .NET based languages. If you have AutoCAD, then the Database, Geometry, and BREP namespaces offer a much more direct method of retrieving the data you need for analysis.
See here:
Can't find what you're looking for? Ask the community or share your knowledge.