looking for system variable Always convert non-primitive solids to mesh

looking for system variable Always convert non-primitive solids to mesh

yorick_dantuma
Enthusiast Enthusiast
213 Views
2 Replies
Message 1 of 3

looking for system variable Always convert non-primitive solids to mesh

yorick_dantuma
Enthusiast
Enthusiast

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,

 

yorick_dantuma_0-1743595765993.png

 

 

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)
)

 

0 Likes
Accepted solutions (1)
214 Views
2 Replies
Replies (2)
Message 2 of 3

matt.worland
Collaborator
Collaborator

Im not familiar with that setting, but it could be saved in the registry. You can use software to compare registry settings before and after a change. If its in the registry, that should help locate it.

If my reply was helpful, please give a "Thumbs Up" or "Accept as Solution"
0 Likes
Message 3 of 3

yorick_dantuma
Enthusiast
Enthusiast
Accepted solution

Thanks for the hint. Unfortunately I didn't figure out how to use other software (besides the build in SysvarMonitor) to compare registry settings. What I did was write a .net code that collects all Polyface Meshes, converts them to an optimized Mesh and converts that to a solid. That way finding the setting was not relevent anymore.

0 Likes