I'm running AutoCad Mechanical (2013) with a script to create a STEP file. This works fine but the Mesh objects are not visible in the STEP file/ To solve this I manually select all Mesh objects (with quick select) and then use the THICKEN command. I have two problems in putting this in a script:
For selecting blocks I use (ssget "X" '((0 . "INSERT")) in a lisp routine. Is there something to select meshes?
For using keyboard input I read you can use the grread function in a lisp routine, however I can't figure out how to use it.
So far my code my code be something like this:
;Mesh to solid/surface (defun c:M2S (/ sstMeshes) (setvar "cmdecho" 0) (setq sstMeshes (ssget "X" '((0 . "MESH")))) (if (= sstMeshes nil) (princ "\nNo meshes present in this drawing")) (while (and (/= sstMeshes nil) (> (sslength sstMeshes) 0)) (princ (strcat "\nNumber of meshes to thicken: " (itoa (sslength sstMeshes)))) (command "_THICKEN" sstMeshes) ;USE GRREAD FUNCTION? (setq sstMeshes nil) (setq sstMeshes (ssget "X" '((0 . "MESH")))) ) (setvar "cmdecho" 1) (princ) )
Any help woud be greatly aprecciated!
Solved! Go to Solution.
Solved by gsktry. Go to Solution.
Solved by gsktry. Go to Solution.
Solved by gsktry. Go to Solution.
Hi Amito,
For the first question what you are doing is correct.
(setq sstMeshes (ssget "X" '((0 . "MESH")))) - it selects all mesh objects in the dwg.
For the second question, I think grread function will not help and I don't find any function to control the options in the pop-up menu.
So, my suggestion is, use ' CONVTOSURFACE ' command to convert the selected mesh objects to faceted 3D surfaces and then call ' Thicken ' command.
Now the pop-up menu will not be displayed.
Regards,
gsktry
Thanks for the quick reply gsktry.
Sometimes life is easier then one can think.
(setq sstMeshes (ssget "X" '((0 . "MESH")))) indeed selects all mesh objects in the dwg.
However, I tried the 'CONVTOSURFACE' command as you suggested, but the result is not satisfying (my rectangular ducts are converted to ovals for example). The result is pretty much the same as the second option of my screenshot in the earlier post. So maybe there is also a command to call the third option directly.
I've read a post (link) where they use the GRREAD function to use the keyboard input. I just don't know how to aplly it in my case.
Hi,
For the both options, the commands are same. I think ' SMOOTHMESHCONVERT ' setvar controls the operation. Change this variable value (0 or 2) and try the command. As far as I know, GRREAD function will be used for reading the user inputs and we can not pass our inputs through this function.
Regards,
gsktry
Thank you again for the effort.
That did the trick for me. I tried it with 'SMOOTHMESHCONVERT' 0 and 1 and in booth cases the result wasn't ok, but 2 and 3 are acceptable.
But I still have a minor issue to get this done automatically, because my script doesn't continue after.
(command "_.convtosurface" sstMeshes)
The selection is done but not confirmed. If I use "_.explode" instead of "_.convtosurface" then it's not a problem for the script to continue so I think I have to call/execute the command on another way.
I also get an error in the command line:
Number of meshes to convert: 17
*Invalid selection*
Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle
; error: Function cancelled
Select objects:
The full code is know:
;Mesh to solid/surface (defun c:M2S (/ sstMeshes) (setvar "cmdecho" 0) (setvar "smoothmeshconvert" 2) (setq sstMeshes (ssget "X" '((0 . "MESH")))) (if (= sstMeshes nil) (princ "\nNo meshes present in this drawing")) (while (and (/= sstMeshes nil) (> (sslength sstMeshes) 0)) (princ (strcat "\nNumber of meshes to convert: " (itoa (sslength sstMeshes)))) (command "_.convtosurface" sstMeshes)
; something is not ok in the previous line (setq sstMeshes nil) (setq sstMeshes (ssget "X" '((0 . "MESH")))) ) (setvar "cmdecho" 1) (princ) )
Hi,
I'm at home now. So, I could not check it. But, I guess you missed an enter ("") at the end.
(command "_.convtosurface" sstMeshes "")
Regards,
gsktry