Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
This LISP selects all Polyface Mesh objects, converts it to mesh. Also, two system variables are set; Mesh type 'Mostly Quads' and convert 'Faceted, optimized'.
But,
To bypass above dialog the code has two send commands 'Enter'. How to set 'Always convert non-primitive..' default to TRUE so this dialog is not showing at all? Then regardless of the user setting, the code can run.
(defun c:NEMconvToSolid ()
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Set system variables
(command "_FACETERMESHTYPE" "1")
(command "_SMOOTHMESHCONVERT" "2")
; Select all Polyface Mesh objects
(setq ss (ssadd))
(vlax-for obj (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (eq (vla-get-ObjectName obj) "AcDbPolyFaceMesh")
(setq ss (ssadd (vlax-vla-object->ename obj) ss))
)
)
; del all not converted (hierna en na to solid)
(if (> (sslength ss) 0)
(progn
;; Convert all objects to mesh
(command "_MESHSMOOTH" ss)
(SendKeys "{ENTER}")
(vla-SendCommand doc " ")
)
)
; Select all Mesh objects
(setq ss nil) ; Remove all elements from list
(setq ss (ssadd))
(vlax-for obj (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (eq (vla-get-ObjectName obj) "AcDbSubDMesh")
(setq ss (ssadd (vlax-vla-object->ename obj) ss))
)
)
(if (> (sslength ss) 0)
(progn
;; Convert all objects to solid
(command "_CONVTOSOLID" ss "")
)
)
(princ)
)
(defun SendKeys (keys / ws) ; irneb
(setq ws (vlax-get-or-create-object "WScript.Shell"))
(vlax-invoke-method ws 'SendKeys keys)
(vlax-release-object ws)
)
Solved! Go to Solution.