Author Topic: Calling MESHSMOOTH in LSP  (Read 3224 times)

0 Members and 1 Guest are viewing this topic.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Calling MESHSMOOTH in LSP
« on: October 18, 2016, 02:25:32 PM »
Anyone have any tricks for calling the MESHSMOOTH within a LSP program? After doing a little Googling it appears it's a common issue.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

danallen

  • Guest
Re: Calling MESHSMOOTH in LSP
« Reply #1 on: October 18, 2016, 09:05:49 PM »
me... smooooooooth

some words just look funny

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Calling MESHSMOOTH in LSP
« Reply #2 on: October 19, 2016, 06:56:44 AM »
me... smooooooooth

some words just look funny
:-D :-D
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Calling MESHSMOOTH in LSP
« Reply #3 on: October 19, 2016, 10:01:07 AM »
Run MESHSMOOTH command on selection set that consist of 3DFACES and POINTS - you may use triangulation for quick setup...
Then first warning dialog box will appear - choose to create MESH and check box to always apply this option when converting non-primitive solids to meshes...
Then second dialog box will appear stating that some entities can't be converted (your selected POINTS)... Also check box that skip this warning and click OK...

Finally gather new selection set :
Code: [Select]
(setq ss (ssget "_:L"))

And according to my investigations - this won't work with "ss" : (command "_.MESHSMOOTH" ss ""); instead you must use :
Code: [Select]
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "_.MESHSMOOTH\n!ss\n\n")

Warning!!! : Do not try this if you don't want to perform actions automatically without showing warning dialog boxes... I don't know how to turn them on back after I applied check button to always apply action and skip pop ups...

[EDIT] Found and answer to warning message here : https://www.theswamp.org/index.php?topic=52592.msg575026#msg575026 [/EDIT]
« Last Edit: January 29, 2017, 12:24:12 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Calling MESHSMOOTH in LSP
« Reply #4 on: October 19, 2016, 10:23:41 AM »
I posted some code in a somewhat (un)related post over here. I think I need to stay away from vla-sendcommand for the fact that it runs last regardless of where it is within the program.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Calling MESHSMOOTH in LSP
« Reply #5 on: October 19, 2016, 10:29:12 AM »
I posted some code in a somewhat (un)related post over here. I think I need to stay away from vla-sendcommand for the fact that it runs last regardless of where it is within the program.

I think the best you can do with MESHSMOOTH is to separate processes - create 2 defuns - first for conversion to MESHES and second one is actually your main routine that operates with created MESHES from previous step...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Calling MESHSMOOTH in LSP
« Reply #6 on: October 19, 2016, 11:42:32 AM »
Look, I don't know what do you want to do with created MESH(es) after MESHSMOOTH... All I can guess is to UNION them and get single MESH... Then you can try to wrap all this things into single (vla-sendcommand) process :

Code: [Select]
(defun c:xxx nil
  (vl-load-com)
  (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "(setq entss (ssget \"_:L\"))\nall\n\n_.MESHSMOOTH\n!entss\n\n(setq mshss (ssget \"_:L\" '((0 . \"MESH\"))))\nall\n\nUNION\n!mshss\n\n(setq entss nil mshss nil)\n(princ)\n")
)
« Last Edit: October 19, 2016, 09:27:18 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Calling MESHSMOOTH in LSP
« Reply #7 on: October 19, 2016, 12:33:33 PM »
OK, I just saw topic here : http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/convert-3d-solid-to-3d-faces-with-lsp-program/td-p/6630098

If you want to convert 3D SOLIDS to 3D FACES, try something like this :

Code: [Select]
(defun preprocess nil
  (prompt "\nSelect 3DSOLIDS to convert to 3DFACES...")
  (setq e (ssget "_:L" '((0 . "3DSOLID"))))
  (while (not e)
    (prompt "\nMissed... Select 3DSOLIDS to convert to 3DFACES again...")
    (setq e (ssget "_:L" '((0 . "3DSOLID"))))
  )
)

(defun postprocess nil
  (vl-load-com)
  (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "(setq e (entlast))\n_.MESHSMOOTH\n_Previous\n\n(setq mshss (ssadd))\n(while (setq e (entnext e)) (ssadd e mshss))\nEXPLODE\n!mshss\n\n(setq mshss nil preprocess nil postprocess nil e nil)\n(princ)\n")
)

(defun c:xxx nil
  (preprocess)
  (postprocess)
)
« Last Edit: October 19, 2016, 09:25:45 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Calling MESHSMOOTH in LSP
« Reply #8 on: October 19, 2016, 01:32:36 PM »
 :-D
I'm actually helping Tony at the moment with this. I posted here just to make sure I wasn't missing something with regards to the MESHSMOOTH command.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io