Author Topic: Marko, How Rotating 3D SOLID quickly ?  (Read 9561 times)

0 Members and 1 Guest are viewing this topic.

andy_lee

  • Newt
  • Posts: 147
Marko, How Rotating 3D SOLID quickly ?
« on: May 26, 2015, 02:26:00 AM »
Hi marko .

Sometimes , need import 3D solid from  solidworks. (solidworks export "*.STEP" format , autocad import )

But , when import it……

This is "Front" view ,is not I need.


This is I need.


This is "SW ISOMETRIC" view ,is not I need.


This is I need



So, when I import it  ,How quick rotate  3D SOLID  to what I need  ?

1. choose all 3D object ,2. Choose a face  align X axis , 3. Choose a face align Y axis ?

Test DWG at #2



======================================================================













=======================================================================

« Last Edit: May 26, 2015, 02:54:34 AM by emk2012 »
andy.
Best regards.

andy_lee

  • Newt
  • Posts: 147
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #1 on: May 26, 2015, 03:00:21 AM »
command "_3drotate" is not I need.

Specify base point:
Pick a rotation axis: difficile to pick
Specify angle start point or type an angle:  I don't know the angle

This is Test.dwg
andy.
Best regards.

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #2 on: May 26, 2015, 06:07:38 AM »
Emk, I don't have my comp. at the moment and I am typing this from my phone... I am away from where I live and cant answer you until I came back home... Hope youll find solution and without my help... Sorry, but I cant analyze your request the way I would like to... Have a nice day and my regards to you and all swampers... M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

andy_lee

  • Newt
  • Posts: 147
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #3 on: May 26, 2015, 06:26:12 AM »
Emk, I don't have my comp. at the moment and I am typing this from my phone... I am away from where I live and cant answer you until I came back home... Hope youll find solution and without my help... Sorry, but I cant analyze your request the way I would like to... Have a nice day and my regards to you and all swampers... M.R.

Hi Marko. I can't find any solution from THESWAMP and CADTUTOR , but I can wait for you.
Thank you very much .

Best regards!
andy.
Best regards.

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #4 on: May 26, 2015, 07:46:49 AM »
Emk, Ill be absent for ab 2 weeks... I am sure someone will reply till then... My kind regards, Marko...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #5 on: May 26, 2015, 10:01:26 AM »
Here is a solution using the TransformBy method.
The function c:test uses InverseMatrix by Gile.
The final result will vary depending on the selected face but also on the point that was picked in the selection process.
Code - Auto/Visual Lisp: [Select]
  1. ;; http://www.theswamp.org/index.php?topic=22638.msg334208#msg334208
  2. ;; InverseMatrix (gile) 2009/03/17
  3. ;; Uses the Gauss-Jordan elimination method to calculate the inverse
  4. ;; matrix of any dimension square matrix
  5. ;;
  6. ;; Argument : a square matrix
  7. ;; Return : the inverse matrix (or nil if singular)
  8. (defun InverseMatrix (mat / col piv row res)
  9.   (setq mat (mapcar '(lambda (x1 x2) (append x1 x2)) mat (Imat (length mat))))
  10.   (while mat
  11.     (setq col (mapcar '(lambda (x) (abs (car x))) mat))
  12.     (repeat (vl-position (apply 'max col) col)
  13.       (setq mat (append (cdr mat) (list (car mat))))
  14.     )
  15.     (if (equal (setq piv (caar mat)) 0.0 1e-14)
  16.       (setq mat nil
  17.             res nil
  18.       )
  19.       (setq piv (/ 1.0 piv)
  20.             row (mapcar '(lambda (x) (* x piv)) (car mat))
  21.             mat (mapcar
  22.                   '(lambda (r / e)
  23.                      (setq e (car r))
  24.                      (cdr (mapcar '(lambda (x n) (- x (* n e))) r row))
  25.                   )
  26.                   (cdr mat)
  27.                 )
  28.             res (cons
  29.                   (cdr row)
  30.                   (mapcar
  31.                     '(lambda (r / e)
  32.                        (setq e (car r))
  33.                        (cdr (mapcar '(lambda (x n) (- x (* n e))) r row))
  34.                      )
  35.                     res
  36.                   )
  37.                 )
  38.       )
  39.     )
  40.   )
  41.   (reverse res)
  42. )
  43.  
  44. ;; http://www.theswamp.org/index.php?topic=22638.msg334208#msg334208
  45. ;; IMAT (gile)
  46. ;; Returns the specified dimension identity matrix
  47. ;;
  48. ;; Argument
  49. ;; d : the matrix dimension (positive integer)
  50. (defun Imat (d / i n r m)
  51.   (setq i d)
  52.   (while (<= 0 (setq i (1- i)))
  53.     (setq n d r nil)
  54.     (while (<= 0 (setq n (1- n)))
  55.       (setq r (cons (if (= i n) 1.0 0.0) r))
  56.     )
  57.     (setq m (cons r m))
  58.   )
  59. )
  60.  
  61. (defun _Conv_Pickset_To_EnameList (ss / i ret)
  62.   (if ss
  63.     (repeat (setq i (sslength ss))
  64.       (setq ret (cons (ssname ss (setq i (1- i))) ret))
  65.     )
  66.   )
  67. )
  68.  
  69. (defun c:test ( / doc mat name ss)
  70.   (if (= (logand (getvar 'undoctl) 8) 8)
  71.     (vla-endundomark doc)
  72.   )
  73.   (if (setq ss (ssget))
  74.     (progn
  75.       (setvar 'cmdecho 0)
  76.       (setq name (strcat "TMP_UCS_" (rtos (getvar 'cdate) 2 8)))
  77.       (princ "\nSelect face for top: ")
  78.       (command "_.ucs" "_face" "\\" "")
  79.       (command "_.ucs" "_named" "_save" name)
  80.       (setq mat
  81.         (vlax-tmatrix
  82.           (InverseMatrix (vlax-invoke (vla-get-activeucs doc) 'getucsmatrix))
  83.         )
  84.       )
  85.       (foreach ent (_Conv_Pickset_To_EnameList ss)
  86.         (vla-transformby (vlax-ename->vla-object ent) mat)
  87.       )
  88.       (command "_.ucs" "_world")
  89.       (command "_.ucs" "_named" "_delete" name)
  90.       (setvar 'cmdecho 1)
  91.     )
  92.   )
  93.   (princ)
  94. )
« Last Edit: May 26, 2015, 10:08:32 AM by roy_043 »

HofCAD

  • Guest
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #6 on: May 26, 2015, 10:05:59 AM »
Dear Emk,

Select the command Align
 1) Select all objects
 2) Specify first source point: S1
 3) Specify first destination point: 0.0
 4) Specify second source point: S2
 5) Specify second destination point: 0,0,1
 6) Specify third source point S3
 7) Specify third destination point: 0.1

Regards

andy_lee

  • Newt
  • Posts: 147
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #7 on: May 26, 2015, 08:21:12 PM »
Here is a solution using the TransformBy method.
The function c:test uses InverseMatrix by Gile.
The final result will vary depending on the selected face but also on the point that was picked in the selection process.

Many thanks roy. but
Select objects:
Select face for top: ; error: multi dimension safearray not supported
andy.
Best regards.

andy_lee

  • Newt
  • Posts: 147
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #8 on: May 26, 2015, 08:29:46 PM »
Dear Emk,

Select the command Align
 1) Select all objects
 2) Specify first source point: S1
 3) Specify first destination point: 0.0
 4) Specify second source point: S2
 5) Specify second destination point: 0,0,1
 6) Specify third source point S3
 7) Specify third destination point: 0.1

Regards

Dear Hof
I test ,but unsuccessful , and this method is not simple.

I think ,if need specify three point, can use coding ?  eg. choose a face ,can get 4 point .
andy.
Best regards.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #9 on: May 27, 2015, 03:06:56 AM »
My code works fine on BricsCAD.
Maybe it will work on AutoCAD if you change:
Code - Auto/Visual Lisp: [Select]
  1.       (setq mat
  2.         (vlax-tmatrix
  3.           (InverseMatrix (vlax-invoke (vla-get-activeucs doc) 'getucsmatrix))
  4.         )
  5.       )
To:
Code - Auto/Visual Lisp: [Select]
  1.       (setq mat
  2.         (vlax-tmatrix
  3.           (InverseMatrix
  4.             (vlax-safearray->list
  5.               (vlax-variant-value (vla-getucsmatrix (vla-get-activeucs doc)))
  6.             )
  7.           )
  8.         )
  9.       )

HofCAD

  • Guest
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #10 on: May 27, 2015, 03:18:27 AM »
Dear Emk,

Set all Dynamic Input features, including dynamic prompts, off (DYNMODE 0).
Otherwise you must provide the destination points 0,0 , 0,0,1 and 0,1
with an asterisk *0,0 , *0,0,1 and *0,1.
Turn the running object snap settings for Endpoint on,
or type the abbreviation END!
Then you can snap the Endpoints S1,S2 and S3!

Command: ALIGN
Select objects: ALL
4 found
Select objects: ‘Enter’
Specify first source point: END of ‘pick S1’
Specify first destination point: 0,0
Specify second source point: END of ‘pick S2’
Specify second destination point: 0,0,1
Specify third source point or <continue>: END of ‘pick S3’
Specify third destination point: 0,1

Explanation:
The selected objects move from the source point S1 to the destination point 0,0.
The selected object is rotated (S1 and S2) so that it aligns with the destination object (0,0 and 0,0,1).
The selected object is then rotated again (S2 and S3) so that it aligns with the destination object (0,0,1 and 0,1).

http://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-Core/files/GUID-D0FA10D5-76EE-4B80-A285-43C7F39916DB-htm.html

Regards
« Last Edit: May 27, 2015, 07:24:22 AM by HofCAD »

andy_lee

  • Newt
  • Posts: 147
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #11 on: May 27, 2015, 03:30:58 AM »
My code works fine on BricsCAD.
Maybe it will work on AutoCAD if you change:
Code - Auto/Visual Lisp: [Select]
  1.       (setq mat
  2.         (vlax-tmatrix
  3.           (InverseMatrix (vlax-invoke (vla-get-activeucs doc) 'getucsmatrix))
  4.         )
  5.       )
To:
Code - Auto/Visual Lisp: [Select]
  1.       (setq mat
  2.         (vlax-tmatrix
  3.           (InverseMatrix
  4.             (vlax-safearray->list
  5.               (vlax-variant-value (vla-getucsmatrix (vla-get-activeucs doc)))
  6.             )
  7.           )
  8.         )
  9.       )


Many thanks ,roy .
It's so Beautiful!  This is " Select face for top " , how change to " select face for front " ?
andy.
Best regards.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #12 on: May 27, 2015, 03:47:59 AM »
Many thanks ,roy .
It's so Beautiful!  This is " Select face for top " , how change to " select face for front " ?

Try changing:
Code - Auto/Visual Lisp: [Select]
  1.       (princ "\nSelect face for top: ")
  2.       (command "_.ucs" "_face" "\\" "")
  3.       (command "_.ucs" "_named" "_save" name)

to:
Code - Auto/Visual Lisp: [Select]
  1.       (princ "\nSelect face for front: ")
  2.       (command "_.ucs" "_face" "\\" "" "_.ucs" "_x" "-90" "_.ucs" "_named" "_save" name)

andy_lee

  • Newt
  • Posts: 147
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #13 on: May 27, 2015, 03:57:39 AM »
Dear Emk,

Turn the running object snap settings for Endpoint on,
or type the abbreviation END!
Then you can snap the Endpoints S1,S2 and S3!

Command: ALIGN
Select objects: ALL
4 found
Select objects: ‘Enter’
Specify first source point: END of ‘pick S1’
Specify first destination point: 0,0,0
Specify second source point: END of ‘pick S2’
Specify second destination point: 0,0,1
Specify third source point or <continue>: END of ‘pick S3’
Specify third destination point: 0,1

Explanation:
The selected objects move from the source point S1 to the destination point 0,0,0.
The selected object is rotated (S1 and S2) so that it aligns with the destination object (0,0,0 and 0,0,1).
The selected object is then rotated again (S2 and S3) so that it aligns with the destination object (0,0,1 and 0,1).

http://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-Core/files/GUID-D0FA10D5-76EE-4B80-A285-43C7F39916DB-htm.html

Regards

Dear Hof
Many thanks ,  successful!!! 
before,unsuccessful , Because.  "Dynamic Input " is Enable.  so if I enter "0,0,0" will become to "@0,0,0"






andy.
Best regards.

andy_lee

  • Newt
  • Posts: 147
Re: Marko, How Rotating 3D SOLID quickly ?
« Reply #14 on: May 27, 2015, 04:08:07 AM »
Many thanks ,roy .
It's so Beautiful!  This is " Select face for top " , how change to " select face for front " ?

Try changing:
Code - Auto/Visual Lisp: [Select]
  1.       (princ "\nSelect face for top: ")
  2.       (command "_.ucs" "_face" "\\" "")
  3.       (command "_.ucs" "_named" "_save" name)

to:
Code - Auto/Visual Lisp: [Select]
  1.       (princ "\nSelect face for front: ")
  2.       (command "_.ucs" "_face" "\\" "" "_.ucs" "_x" "-90" "_.ucs" "_named" "_save" name)


Many thanks , Lee,  It's very nice !
andy.
Best regards.