Author Topic: question about MESHSMOOTH command  (Read 2969 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3264
  • Marko Ribar, architect
question about MESHSMOOTH command
« on: January 26, 2017, 03:17:58 PM »
Hi all...
I have a question regarding MESHSMOOTH command...

If I have selection set of boxes 3DSOLID primitives, when I enter or run through lisp (command "_.MESHSMOOTH" ss "") everything is fine - all primitives are converted to appropriate MESHES according to settings of MESH sysvars...
Now that's fine and good, but the problem arises in just slightly different situation :
If boxes aren't primitives - already had some kind of modeling operation performed UNION, SUBTRACT, INTERSECT, or similar when typed from command line (command "_.MESHSMOOTH" ss ""), CAD doesn't do anything... What's weird, when typed MESHSMOOTH directly from command line and 3DSOLIDS are selected, CAD do what should... So can anyone unlock this odd behaviour if 3DSOLIDS are complex and (command "_.MESHSMOOTH" ss "") function is used through LISP...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: question about MESHSMOOTH command
« Reply #1 on: January 26, 2017, 03:43:57 PM »
There are several commands that have a different behavior when called from a (Lisp) script. The _Explode command is a well known example. Have you checked the prompts when you copy-paste (command "_.MESHSMOOTH")?

ribarm

  • Gator
  • Posts: 3264
  • Marko Ribar, architect
Re: question about MESHSMOOTH command
« Reply #2 on: January 26, 2017, 04:10:01 PM »
Yes, prompts are fine... Should be supplied just sel. set and ENTER... or ename and ENTER... But like I explained, it works on first situation and on problematic modified 3DSOLIDS, it doesn't work and it should... Tested with various QAFLAGS settings and with both A2014 and A2016 CADs on Windows 7...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ChrisCarlson

  • Guest
Re: question about MESHSMOOTH command
« Reply #3 on: January 26, 2017, 04:22:52 PM »
Can you use vlisp?
 
Code - Auto/Visual Lisp: [Select]
  1.     (strcat "MESHSMOOTH" " " "(ssget \"X\" '((0 . \"3dsolid\")))" " " " ")
  2. )

http://www.cadtutor.net/forum/showthread.php?89467-Solids-to-Mesh-LISP&p=612595&viewfull=1#post612595
« Last Edit: January 26, 2017, 04:28:22 PM by Master_Shake »

ribarm

  • Gator
  • Posts: 3264
  • Marko Ribar, architect
Re: question about MESHSMOOTH command
« Reply #4 on: January 26, 2017, 04:44:05 PM »
Can you use vlisp?
 
Code - Auto/Visual Lisp: [Select]
  1.     (strcat "MESHSMOOTH" " " "(ssget \"X\" '((0 . \"3dsolid\")))" " " " ")
  2. )

http://www.cadtutor.net/forum/showthread.php?89467-Solids-to-Mesh-LISP&p=612595&viewfull=1#post612595

That's not what I was looking for... Of course I use VLISP often, but (vla-sendcommand adoc "...") works in separate namespace than LISP and my defined function... I want to use MESHSMOOTH at the beginning of LISP and then proceed with other things... With (vla-sendcommand) this is impossible... And yes, I haven't even checked if it would do as should, I'll check it and inform you...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3264
  • Marko Ribar, architect
Re: question about MESHSMOOTH command
« Reply #5 on: January 26, 2017, 06:23:12 PM »
Thanks to Master_Shake... I solved it by using (vla-sendcommand)... Only thing that's little cumbersome is that I had to divide code in 2 parts calling separately...
So here it is - the purpose is that that when you are modeling simple models containing from cubic (not curved) surfaced 3DSOLIDS, you can now 2d scale your entire model, meaning that transformations are applied to 3DSOLIDS... So lets say, you projected house with minimal spacing measures, and you modeled house in 3D and you did find out that it's too small to put all the necessary things, you can now 2d scale it by specifying X scale factor and Y scale factors that should be little larger than 1.0 and Z scale factor remains 1.0... And that's it, complete model from 3DSOLIDS (cubic) is possible to transform - so no need for remodeling all from the beginning...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:cubic3dsolidmodel2dscale ( / sel )
  2.  
  3.  
  4.   (defun continue ( / sel i sol msh )
  5.     (while (entnext el)
  6.       (setq el (entnext el))
  7.       (ssadd el s)
  8.     )
  9.     (setq sel (ssadd))
  10.     (command "_.-BLOCK" "{_MODEL_}" "_non" bp s "")
  11.     (command "_.-INSERT" "{_MODEL_}" "_non" bp xscf yscf 0.0)
  12.     (vla-put-zscalefactor (vlax-ename->vla-object (entlast)) zscf)
  13.     (setq el (entlast) s (ssadd))
  14.     (command "_.EXPLODE" "_L")
  15.     (while (setq el (entnext el))
  16.       (ssadd el s)
  17.     )
  18.     (repeat (setq i (sslength s))
  19.       (setq msh (ssname s (setq i (1- i))))
  20.       (command "_.CONVTOSOLID" msh "")
  21.       (ssadd (entlast) sel)
  22.     )
  23.     (repeat (setq i (sslength sel))
  24.       (setq sol (ssname sel (setq i (1- i))))
  25.       (command "_.SOLIDEDIT" "_B" "_L" sol "")
  26.       (while (< 0 (getvar 'cmdactive))
  27.         (command "")
  28.       )
  29.       (if (= (getvar 'solidhist) 1)
  30.         (vla-put-history (vlax-ename->vla-object sol) :vlax-true)
  31.         (vla-put-history (vlax-ename->vla-object sol) :vlax-false)
  32.       )
  33.     )
  34.     (setq s (ssget "_X" '((0 . "INSERT") (2 . "{_MODEL_}"))))
  35.     (if s
  36.       (repeat (setq i (sslength s))
  37.         (if (not (vlax-erased-p (ssname s (setq i (1- i)))))
  38.           (entdel (ssname s i))
  39.         )
  40.       )
  41.     )
  42.     (command "_.-PURGE" "_B" "{_MODEL_}" "_N")
  43.     (setq s nil i nil bp nil xscf nil yscf nil zscf nil)
  44.     (setvar 'faceterprimitivemode fpm)
  45.     (setvar 'facetermeshtype fmt)
  46.     (setvar 'smoothmeshconvert smc)
  47.     (vla-endundomark adoc)
  48.     (princ)
  49.   )
  50.  
  51.   (defun message nil
  52.     (prompt "\nType \"UNDO\" \"B\" to undo...")
  53.     (setq fpm nil fmt nil smc nil continue nil message nil adoc nil)
  54.     (textscr)
  55.     (princ)
  56.   )
  57.  
  58.   (setq fpm (getvar 'faceterprimitivemode))
  59.   (setvar 'faceterprimitivemode 0)
  60.   (setq fmt (getvar 'facetermeshtype))
  61.   (setvar 'facetermeshtype 2)
  62.   (setq smc (getvar 'smoothmeshconvert))
  63.   (setvar 'smoothmeshconvert 3)
  64.   (if
  65.     (and
  66.       (not (prompt "\nSelect cubic 3DSOLID entities of model that you want to 2d scale..."))
  67.       (setq sel (ssget "_:L" '((0 . "3DSOLID"))))
  68.       (setq bp (getpoint "\nPick or specify base point : "))
  69.       (not (initget 2))
  70.       (setq xscf
  71.         (cond
  72.           ( (getreal "\nSpecify X scale factor <1.0> : ") )
  73.           ( t 1.0 )
  74.         )
  75.       )
  76.       (not (initget 2))
  77.       (setq yscf
  78.         (cond
  79.           ( (getreal "\nSpecify Y scale factor <1.0> : ") )
  80.           ( t 1.0 )
  81.         )
  82.       )
  83.       (not (initget 2))
  84.       (setq zscf
  85.         (cond
  86.           ( (getreal "\nSpecify Z scale factor <1.0> : ") )
  87.           ( t 1.0 )
  88.         )
  89.       )
  90.     )
  91.     (progn
  92.       (setq s (ssadd))
  93.       (setq el (entlast))
  94.       (while (entnext el)
  95.         (setq el (entnext el))
  96.       )
  97.       (command "_.SELECT" sel "")
  98.       (vla-sendcommand adoc "_.MESHSMOOTH\nP\n\n(continue)\n(message)\n")
  99.     )
  100.   )
  101. )
  102.  

HTH., M.R.
« Last Edit: May 12, 2017, 01:14:12 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ChrisCarlson

  • Guest
Re: question about MESHSMOOTH command
« Reply #6 on: January 27, 2017, 08:21:22 AM »
That was from GP many years ago. I got frustrated that passing
Code - Auto/Visual Lisp: [Select]
  1. (command "MESHSMOOTH" ss "")
returned "nil" but
Code - Auto/Visual Lisp: [Select]
  1. (vl-cmdf "MESHSMOOTH" ss "")
returns "t"
« Last Edit: January 27, 2017, 08:29:23 AM by Master_Shake »

mailmaverick

  • Bull Frog
  • Posts: 493
Re: question about MESHSMOOTH command
« Reply #7 on: January 27, 2017, 11:10:30 AM »
That was from GP many years ago. I got frustrated that passing
Code - Auto/Visual Lisp: [Select]
  1. (command "MESHSMOOTH" ss "")
returned "nil" but
Code - Auto/Visual Lisp: [Select]
  1. (vl-cmdf "MESHSMOOTH" ss "")
returns "t"

Can anyone explain why the behavior is different in above two commands ?

Also, Marko, in that case, instead of using (vla-sendcommand...) you can use (vl-cmdf "MESHSMOOTH" ss "").
Please try and let us know. Or otherwise, if you can share your drawing for us to try it.

ribarm

  • Gator
  • Posts: 3264
  • Marko Ribar, architect
Re: question about MESHSMOOTH command
« Reply #8 on: January 27, 2017, 12:12:22 PM »
That was from GP many years ago. I got frustrated that passing
Code - Auto/Visual Lisp: [Select]
  1. (command "MESHSMOOTH" ss "")
returned "nil" but
Code - Auto/Visual Lisp: [Select]
  1. (vl-cmdf "MESHSMOOTH" ss "")
returns "t"

Can anyone explain why the behavior is different in above two commands ?

Also, Marko, in that case, instead of using (vla-sendcommand...) you can use (vl-cmdf "MESHSMOOTH" ss "").
Please try and let us know. Or otherwise, if you can share your drawing for us to try it.

The behaviour of these 2 examples isn't different - it's the same; the only difference is return value - read more ab command and vl-cmdf... And in my case neither (command), nor (vl-cmdf), nor (command-s) don't give desired results... Read carefully whole topic - I've explained several times what I want to achieve and only way is - it turned that way, (vla-sendcommand) way... For DWG, you have to experiment on your own to see what i was speaking of - GP had the same problem (look in link Master_Shake provided)... Like routine name explains it should be applied only in special case situations (flat or 2 sloped roofs - hip roof (sloped on more sides) won't be correct and geometry of model house should be only cubic for meshsmooth to operate adequate)...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3264
  • Marko Ribar, architect
Re: question about MESHSMOOTH command
« Reply #9 on: January 28, 2017, 11:00:32 AM »
I have to ask...

Have someone found solution to warning message I posted here :
https://www.theswamp.org/index.php?PHPSESSID=uu45uen7nmavbj6cq5442oh2t7&topic=52160.msg571590#msg571590
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3264
  • Marko Ribar, architect
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube