AutoCAD for Mac Forum
Welcome to Autodesk’s AutoCAD for Mac Forums. Share your knowledge, ask questions, and explore popular AutoCAD for Mac topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

.OBJ => MeshLab => .DXF => AutoCAD Troubles

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Myno
6036 Views, 6 Replies

.OBJ => MeshLab => .DXF => AutoCAD Troubles

(Aloha Maxim!)

 

AutoCAD could not create a mesh I need, so I wrote a program to create verticies and faces in the simple .OBJ format.  I imported the resulting file to MeshLab, which displayed the mesh perfectly, and exported it as a .DXF file.  I opened AutoCAD, then double-clicked on the .DXF file in Finder, and it opened in AutoCAD.  It looks perfectly fine.

In AutoCAD, the data is displayed as if it were a cohesive mesh, but in actuality it is comprised of individual 3D Face objects.  Apparently 3D Face is a "legacy" format.  Two AutoCAD commands ought to convert this assemblage into a mesh... CONVTOMESH and MESHMERGE.  CONVTOMESH works.  Afterwards, if I select any of the triangles, the Properties Inspector informs that they are indeed now "Mesh" objects.

Unfortunately, the MESHMERGE command fails.  Here is sample console output...

Command: MESHMERGE
Select adjacent mesh faces to merge:Specify opposite corner: 4 found
Select adjacent mesh faces to merge:
4 object(s) found.
(1) invalid object(s) removed from the selection set.
(1) invalid object(s) removed from the selection set.
(1) invalid object(s) removed from the selection set.
(1) invalid object(s) removed from the selection set.

Why AutoCAD deems my mesh objects to be "invalid" is not explained.  Better than an explanation, I require a cure.  How can I get my data to become a valid cohesive mesh?

I have attached a file that contains 2 of the 34,000+ triangles in my mesh.  They are 3D Face objects, which can be converted to mesh with CONVTOMESH, but they resist MESHMERGE.

6 REPLIES 6
Message 2 of 7
maxim_k
in reply to: Myno

Hello Mike,

 

You need to apply another technique here:

1. Convert 3d faces into surfaces with CONVTOSURFACE command.

2. Use UNION command to join resulting surfaces.

3. Create Mesh from resulting Surface with MESHSMOOTH command, in order to retain the original shape you need to set mesh smoothness to "None".

 

MESHMERGE command works only with the faces that belong to the same mesh, but you was trying to merge faces from different meshes.

After you create the Mesh with 3 steps above you can use MESHMERGE to merge individual faces of the resulting mesh that are on the same plane to remove additional divisions in the mesh object (if you need this)

 

Note from HELP:

"Merging mesh faces that wrap a corner can have unintended results when you try to edit the mesh or convert it to other types of solid objects. For example, the mesh might no longer be watertight. For best results, restrict mesh merging to faces that are on the same plane."

 

Maxim


Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
Message 3 of 7
Myno
in reply to: Myno

Maxim,

Thank you for your response.  Your instructions are generally correct, as usual.  This note will offer some details to others who may be inclined to go in these directions...

1) Since I tend to work in 3D, I have generally selected (3D) Wireframe as my rendering mode (upper left corner of the display area).  That may be fine for small models, but when the number of elements in the model increases greatly, it can dramatically sloooooooooow down interactions with AutoCAD.  For example, my model contains 36,482 facets.  It can take almost a minute just to select the whole model, and the process of swiping across the model is then interrupted by the cursor freezing and the little rainbow circle showing until the program catches up with your mouse cursor movement.  This is not a pleasant situation.

The cure is to use 2D Wireframe rendering.  In this rendering mode, selection of my whole model is nearly instantaneous.  So far, the only drawback (to someone who is used to the 3D Wireframe environment) I have encountered is that the 3D Gizmos do not display... at least not upon selection of an object.  They DO show up when you invoke a 3D command on a selection.  E.g., 3DROTATE causes the 3D Rotate Gizmo to display for the duration of that command.  So the Gizmos are still available, even though you're in a 2D rendering mode.

2) The AutoCAD for 2013 manual's help page for DELOBJ states that its default value of 3 has the result that it "Removes all defining geometry for CONVTOSOLID, CONVTOSURFACE, CONVTONURBS, and CONVTOMESH commands."  The CONVTOSURFACE help page states that it may be used to convert "Planar 3D faces" to Surface objects.  Combining those two, one naturally expects that the result of a CONVTOSURFACE command on a collection of 3DFace objects will be a Surface, and the 3DFace objects will be deleted.  In my experience, the Surface is indeed generated, but the 3DFaces remain.

For example, following your suggested sequence of actions, here is the console output from a run I made... just prior to hitting the ENTER key to perform the final UNION.  It follows the sequence in my original posting.  Notice that during the CONVTOSURFACE action, the console reports finding all 36482 facets in my model.  But when I start to perform the UNION, and I make the selection, the console reports twice as many items found: 72964.  This is because after the CONVTOSURFACE, the original 3DFaces are still there.

Opening a Release 12 DXF file.
Regenerating model.
AutoCAD menu utilities loaded.
AutoCAD menu utilities loaded.
Command:
Command:
Command:
Command:
Command: *Cancel*
Command: *Cancel*
Command: _vscurrent
Enter an option [2dwireframe/Wireframe/Hidden/Realistic/Conceptual/Shaded/shaded with Edges/shades of Gray/SKetchy/X-ray/Other] <2dwireframe>: _w
Command: _3DORBIT Press ESC or ENTER to exit, or right-click to display shortcut-menu.
Command: CONVTOSURFACE
Mesh conversion set to: Smooth and optimized.
Select objects: Specify opposite corner: 36482 found
Select objects:
Command: *Cancel*
Command: UNION
Select objects: Specify opposite corner: 72964 found

If you don't know that DELOBJ is not working as it should, that doubling is quite confusing.  

The solution is to zoom in closely on the results of the CONVTOSURFACE, select a Surface element, then right-click and Select Similar to select all of the Surface elements together.  Then right-click again to Move To Layer.  Hide that layer and thus the original 3DFace objects are displayed, and can be deleted.

3) The computational time required for performing an action such as the UNION command on a set of Surface elements is apparently proportional to the SQUARE of the number of elements.  That can have serious consequences.  It means that the final UNION of all 36,482 Surface elements can take HOURS.  And since there is no indication offered by AutoCAD of the estimated time to completion (hint, hint!), the user cannot tell the difference between a slooooooooooow but successful run and one that has irretrievably hung.

The solution is to divide the problem into smaller pieces.  Then the power law won't bite so badly, and the pieces can be joined in a later command.

4) As it ends up, the UNION command is much slower than an alternative processing route.  Granted, you answered what I asked, but I have discovered that some ways are faster than others.  Fortunately for my needs, I can use solids.  I know I asked you how to get to a mesh from my 3DFaces, but the real answer is that I should avoid doing that directly, because the UNION command in AutoCAD is so slow.

The solution is to use SURFSCULPT.  I put caps on the open ends of my mesh, use CONVTOSURFACE, then SURFSCULPT, and the whole process proceeds much more quickly.  The square law still holds, but the general rate is much faster.

5) Because I had spent so much effort in generating my own mesh, I really trust my own data.  Thus I decided to set SMOOTHMESHCONVERT to 3.  This caused the resulting Surfaces to not be watertight.  I had to reset the variable to 0, and then I got watertight results.  For those who haven't yet attempted it, converting surfaces to solids via the SURFSCULPT command requires watertight Surfaces.  At this writing, I have a leak in my generated data, and I am using SURFSCULPT and good old binary cut to try and locate it.  I will have to fix it before I can continue.

That's all so far.  I'll post again as soon as I know more.
Again, thanks for your help.

Message 4 of 7
Myno
in reply to: Myno

The watertight difficulties I am having may be due to insufficient resolution in my generated data.  This supposition led me to observe that there is a limitation in the resolution of .DXF data generated via MeshLab.  Specifically, the .DXF file contains data with 6 digits to the right of the decimal place.  That restriction is apparently NOT a function of the .OBJ data I used as input to MeshLab.  I could find no control within MeshLab to increase the exported resolution.  Sigh...

 

This is leading me to generate .DXF file data directly, without involving MeshLab.  The DXF standard accepts double precision values.

I will report as progress continues.

Message 5 of 7
Myno
in reply to: Myno

I was able to convert my data generation code to directly create a .DXF file, with increased precision (now that I'm not using MeshLab as a go-between).  The .DXF file was easily opened by AutoCAD, and I was able to convert the model to a Solid with no watertight issues at all.

 

Conclusions...

 

Maxim's initial answer was correct.

 

As my long intermediate missive shows, there are many ways to get a job done in AutoCAD, and some are faster than others.

 

If you generate 3DFACE objects, consider using CONVTOSURFACE followed by SURFSCULPT as the fastest way to a SOLID.

 

Do NOT trust MeshLab with your data.  It may reduce the precision so that your model data is no longer watertight.  By all means go ahead and use MeshLab, as I did, as a way of creating a .OBJ file, since that may be easier to debug than going straight to .DXF.  But once your model is correct, convert your data generation code to generate a .DXF file directly, without going through .OBJ and MeshLab.

Message 6 of 7
maxim_k
in reply to: Myno

Hi Mike,

 

I'm glad that you finally have found the way to accomplish your task. Smiley Happy

Wish you success in your work!

 

Maxim


Do you find the posts helpful? "LIKE" these posts!
Have your question been answered successfully? Click 'ACCEPT SOLUTION' button.


Maxim Kanaev
Architect
MARSS

MacACAD | Linkedin

Etiquette and Ground Rules of Autodesk Community
Message 7 of 7
Myno
in reply to: Myno

CORRECTION / RETRACTION

 

In the 3rd window from the top I claimed...

 

5) Because I had spent so much effort in generating my own mesh, I really trust my own data.  Thus I decided to set SMOOTHMESHCONVERT to 3.  This caused the resulting Surfaces to not be watertight.  I had to reset the variable to 0, and then I got watertight results...

 

After I increased the resolution of the model, as explained in the now-next-to-last window, I went back to re-try the CONVTOSURFACE and SURFSCULPT with SMOOTHMESHCONVERT set to 3.  It worked, no problem, no watertight issue.

 

I just wanted to set the record straight.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost