Author Topic: Revolve in 3D help please.  (Read 2020 times)

0 Members and 1 Guest are viewing this topic.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Revolve in 3D help please.
« on: February 17, 2021, 10:31:51 AM »
Just over a week ago I posted on Cadtutor asking for help with modifying code from their forum.
Unfortunately I've had no replies.

Now I did contact their Admin to ask if copying/modifying code from their site was OK before posting, the reply was yes.
 
So the original code by The Buzzzard, here:

https://www.cadtutor.net/forum/topic/20659-pressure-vessel-dished-head-lisp/#comments

I am trying to create a 3D piping End Cap, very similar to the Dished Heads, using the modified code below.
My first venture into Entmake code!!

The code works, but it puts the cap on the WCS plane NOT at the selected Insertion Point.

The goal is the user selects the insertion point of the end cap and the direction of the closed end of the pipework and the cap is drawn.
 
Code: [Select]
(defun DRAW_END_CAP (/ BA# BF# BF1# BF2# BF3# CUS DCL_ID DUNT$ FLG# HTHK$ HTHK# HOD$ HOD# HID# HOD_LST ;
                HTHK_LST IDR# IKR# INPT IANG LNAM$ LOOP$ SFLG$ SFLG# SFLG_LST THKL$ VRT# bf4# bf5# bf6#)
;
; (setq DH:HOD$  (rtos N6)) ;default OD dia, take from DIM file
; (setq DH:HTHK$ (rtos N9)) ;default wall thickness, take from DIM file
; (setq DH:SFLG$ (rtos N3)) ;default Straight Flange (required), take from DIM file
(setq DH:HOD$  "610.0")
(setq DH:HTHK$ "12.7")
(setq DH:SFLG$ "138")
(setq INPT (getpoint "\nSpecify Insertion point of End Cap: "))
(setq IANG (getpoint INPT "\nDrag cursor to select head orientation angle.")
                  INPT (trans INPT 1 0)
                  IANG (trans IANG 1 0)
  )
(DH_SSP)
 ) ;end DRAW_END_CAP  

; Set Size Parameters Function.
;
(defun DH_SSP ()
  (setq HOD$  DH:HOD$ ;HOD$ is the main OD.
        HTHK$ DH:HTHK$ ;HTHK# is the wall thickness.
        SFLG$ DH:SFLG$ ;SFLG$ is the flange straight length.
        HOD#  (distof HOD$  2) ;distof converts string to real value, with 2 = decimal
        HTHK# (distof HTHK$ 2)
        SFLG# (distof SFLG$ 2)
        HID#  (- HOD# (* HTHK# 2))
        THKL$ DH:THKL$)
;
(setq IDR# (* HID# 0.9045) ;Head Rad ; change these if require to get profile shape (* HID# 0.9045)
   IKR# (* HID# 0.1727) ;Knuckle Rad ; change these if require to get profile shape (* HID# 0.1727)
  )
  (DH_CDH)
  )
;
; - Calculate Dished Head Function.
;
(defun DH_CDH (/ A1# A2# BA# CP01 CP02 CP03 DEG# PT01 PT02 PT03 PT04 PT05 PT06 PT07 PT08 PT09
                 RAD# RAD#A Sa# Sa2# Sb# Sc# TP01 TP02 TP03 TP04)
;
(setq RAD#   (angle INPT IANG)
  DEG#   (DH_RTD RAD#))
;
    (setq Sb#    (- (/ HID# 2.0) IKR#)
           Sc#    (- IDR# IKR#)
           Sa2#   (- (* Sc# Sc#)(* Sb# Sb#))
           Sa#    (sqrt Sa2#)
           RAD#A  (/ Sb# Sc#)
           A1#    (DH_RTD RAD#A)
           A2#    (- 360 A1#)
   );end setq
;
(setq BA# (list -64.3743 -52.7755))  ;part of LWPolyline bulge calculation
;
    (setq PT01 (polar INPT (DH_DTR (+ DEG#   90))(/ HID# 2)) ;from insertion point.
           PT03 (polar PT01 (DH_DTR (+ DEG#    0))   SFLG#)
           PT02 (polar INPT (DH_DTR (+ DEG#  270))(/ HID# 2)) ;from insertion point.
           PT04 (polar PT02 (DH_DTR (+ DEG#    0))   SFLG#)
           PT05 (polar PT01 (DH_DTR (+ DEG#   90))   HTHK#)
           PT07 (polar PT05 (DH_DTR (+ DEG#    0))   SFLG#)
           PT06 (polar PT02 (DH_DTR (+ DEG#  270))   HTHK#)
           PT08 (polar PT06 (DH_DTR (+ DEG#    0))   SFLG#)
           PT09 (polar INPT (DH_DTR (+ DEG#    0))   SFLG#)
           CP01 (polar PT03 (DH_DTR (+ DEG#  270))   IKR#)
           CP02 (polar PT09 (DH_DTR (+ DEG#  180))   Sa#)
           CP03 (polar PT04 (DH_DTR (+ DEG#   90))   IKR#)
           TP01 (polar CP01 (DH_DTR (+ DEG#  A1#))   IKR#)
           TP03 (polar CP01 (DH_DTR (+ DEG#  A1#))(+ IKR# HTHK#))
           TP02 (polar CP03 (DH_DTR (+ DEG#  A2#))   IKR#)
           TP04 (polar CP03 (DH_DTR (+ DEG#  A2#))(+ IKR# HTHK#))
           BF1# (DH_ETC (/ (DH_DTR (nth 0 BA#)) 4)) ;bulge factor for curved lwpolylines
           BF2# (DH_ETC (/ (DH_DTR (nth 1 BA#)) 4)) ;bulge factor for curved lwpolylines
           BF3# (DH_ETC (/ (DH_DTR (nth 0 BA#)) 4)) ;bulge factor for curved lwpolylines
   bf4# (* bf1# -1)
   bf5# (* bf2# -1)
   bf6# (* bf3# -1)    
   )
  (DH_OLL) ; outside arc Point/Bulge list (DH_OLL)
)
;
; - Outline List Function.
;
(defun DH_OLL ()
     (setq VRT# (list PT01 PT05 PT07 TP03 TP04 PT08 PT06 PT02 pt04 tp02 tp01 pt03)
            BF# (list 0.0 0.0 BF1# BF2# BF3# 0.0 0.0 0.0 bf6# bf5# bf4# 0.0) FLG# 1)

  (DH_DDH)
  )
;
; - Draw Dished Head Function.
;
(defun DH_DDH ()
  (entmakex
  (list
            (cons 0 "LWPOLYLINE") ;defines draw a LWPOLYLINE remember ""'s
            (cons 100 "AcDbEntity") ;defines draw an entity
;-----------(cons 8 LNAM) ;defines the layer specifics, if ommited uses default (is that current?)
            (cons 100 "AcDbPolyline") ;defines draw a LWPOLYLINE
            (cons 90 (length VRT#))
            (cons 70 1)
(cons 10 PT01) ;(cons 10 PNT number)  
(cons 42 0.0) ;(cons 42 BF  number)  
(cons 10 PT05)  
(cons 42 0.0)  
(cons 10 PT07)
(cons 42 BF1#)  
(cons 10 TP03)
(cons 42 BF2#)
(cons 10 TP04)
(cons 42 BF3#)
(cons 10 PT08)
(cons 42 0.0)
(cons 10 PT06)
(cons 42 0.0)
(cons 10 PT02)
(cons 42 0.0)
(cons 10 PT04)
(cons 42 BF6#)
(cons 10 TP02)
(cons 42 BF5#)
(cons 10 TP01)
(cons 42 BF4#)
(cons 10 PT03)
(cons 42 0.0)
)
)
;--------------------------------------------------------------------
; - draw 3D end Cap
(progn
(command "ucs" "ZA" INPT IANG)
(setq ENT1 (entlast))
(command "revolve" ENT1 "" "0,0,0" "0,0,100" "180")   ; aim is for this (command "revolve" ENT1 INPT IANG "180")
(command "ucs" "_P")
)
  )
;
; degree To Radians
;
(defun DH_DTR (a)(* pi (/ a 180.0)))
;
; Radian To Degrees
;
(defun DH_RTD (RAD#)(* 180.0 (/ RAD# pi)))
;
;  Elbow Tangent Calculation Function.
;
(defun DH_ETC (a) (/ (sin a) (cos a)))
;



To help see the problem here is a pic to explain a bit more:
.

The left end cap (red) was created by the earlier lisp code by selecting the end point of the white line as the insertion point and the end of the vertical yellow line as the orientation point. The end cap is created as expected.
The Right hand (closed lwpolyline) shape was created by selecting the RH end point of the blue line as the insertion point and the LH endpoint of the same line as the orientation point.

The shape is correct, but as the shape has not been drawn at the selected insertion point, so it is not on the correct axis for the following Revolve command to create the solid.
Any pointer appreciated.

Steve
There is no such  thing as a 'silly question' to those who do not know!

d2010

  • Bull Frog
  • Posts: 323
Re: Revolve in 3D help please.
« Reply #1 on: February 17, 2021, 02:09:47 PM »
Please help-us,
We need sample-file-drawing.dwg, where you execute your lisp.script
in this mode the helpers@swamp.com avoid UCS issues, UCSName reject script/s.
So,you upload as version AutoCad2009, or AutoCAd2007 with saveAs-old-version.
before you upload here on the -swamp -forum.
Just over a week ago I posted on Cadtutor asking for help with modifying code from their forum.
Unfortunately I've had no replies.
I found many error/s inside yoursource.lisp
**1)You must check the entmakex failed, wtih the variable $rr and you compare
$rr with ent1.
or (setq doublecheck (entmakex (list (cons 0............)))
(if (and  (/= ent1 $rr) (/= doublecheck nil))
  (alert "EntMakex-doubleGood")
  (alert "EntMakex-DoubleCheckFailed")
)
(if  (/= ent1 $rr)
  (alert "EntMakex-Good")
  (alert "EntMakex-Failed")
)
 **2)The revolve command are different in AutoCAD2021, AutoCad2010,
ZwCad,GstarCad.You ask and select type of Revolve
Now I did contact their Admin to ask if copying/modifying code from their site was OK before posting, the reply was yes.
**3)I recovery all math'equation/s for C++, C# compatibilty
23=#varname
24=var$ will be var24
Code: [Select]
/*c2s: rad23=angle(inpt,iang),
       deg23=dh_rtd(rad23),
       sb23=(hid23/2.0)-ikr23),
       sc23= (idr23-ikr23),
       sa223=((sc23*sc23)- (sb23*sb23)),
       sa23=sqrt(sa223),
       rad23a=(sb23/sc23),
       a123=dh_rtd(rad23a),
       a223=(360-a123);
       ba23=list(-64.3743,-52.7755),
       wsahelp=";part of lwpolyline bulge calculation";
       pt01=polar(inpt,dh_dtr( (deg23+90)), (hid23/2)),
       wsahelp=";from insertion point",
       pt03=polar(pt01,dh_dtr( (deg23+0)),sflg23),
       pt02=polar(inpt,dh_dtr( (deg23+270)), (hid23/2)),
       wsahelp=";from insertion point",
       pt04=polar(pt02,dh_dtr( (deg23+0)),sflg23),
       pt05=polar(pt01,dh_dtr( (deg23+90)),hthk23),
       pt07=polar(pt05,dh_dtr( (deg23+0)),sflg23),
       pt06=polar(pt02,dh_dtr( (deg23+270)),hthk23),
       pt08=polar(pt06,dh_dtr( (deg23+0)),sflg23),
       pt09=polar(inpt,dh_dtr( (deg23+0)),sflg23),
       cp01=polar(pt03,dh_dtr( (deg23+270)),ikr23),
       cp02=polar(pt09,dh_dtr( (deg23+180)),sa23),
       cp03=polar(pt04,dh_dtr( (deg23+90)),ikr23),
       tp01=polar(cp01,dh_dtr( (deg23+a123)),ikr23),
       tp03=polar(cp01,dh_dtr( (deg23+a123)), (ikr23+hthk23)),
       tp02=polar(cp03,dh_dtr( (deg23+a223)),ikr23),
       tp04=polar(cp03,dh_dtr( (deg23+a223)), (ikr23+hthk23)),
       bf123=dh_etc( (dh_dtr(nth(0,ba23))/4)),
       wsahelp=";bulge factor for curved lwpolylines",
       bf223=dh_etc( (dh_dtr(nth(1,ba23))/4)),
       wsahelp=";bulge factor for curved lwpolylines",
       bf323=dh_etc( (dh_dtr(nth(0,ba23))/4)),
       wsahelp=";bulge factor for curved lwpolylines",
       bf423= (bf123*-1),bf523= (bf223*-1),bf623= (bf323*-1);
       dh_oll("outside arc point/bulge list")
*/
/*c2s: hod24=dh_hod24,
       wsahelp="hod24 is the main od",
       hthk24=dh_hthk24,
       wsahelp=";hthk23 is the wall thickness.",
       sflg24=dh_sflg24,
       wsahelp=";sflg24 is the flange straight length.",
       hod23=distof(hod24,2),
       hthk23=distof(hthk24,2),
       sflg23=distof(sflg24,2),
       hid23= (hod23- (hthk23*2)),
       thkl24=dh_thkl24;
       idr23= (hid23*0.9045),
       wsahelp=";head rad\011\011; change these if require to get profile shape (* hid23 0.9045)",
       ikr23= (hid23*0.1727),
       wsahelp=";knuckle rad\011; change these if require to get profile shape (* hid23 0.1727)";
       $rr=dh_cdh();
*/
/*c2s: dh_hod24="610.0",
       dh_hthk24="12.7",
       dh_sflg24="138",
       inpt=getpoint("\nspecify insertion point of end cap: ");
       iang=getpoint(inpt,"\ndrag cursor to select head orientation angle."),
       inpt=trans(inpt,1,0),
       iang=trans(iang,1,0);
       dh_ssp();
*/
The left end cap (red) was created by the earlier lisp code by selecting the end point of the white line as the insertion point and the end of the vertical yellow line as the orientation point. The end cap is created as expected.
The Right hand (closed lwpolyline) shape was created by selecting the RH end point of the blue line as the insertion point and the LH endpoint of the same line as the orientation point.
**4) you must use (princ ..) after (entmakex......)
Code: [Select]
(setq $rr (entlast))
         (setq doublecheck (entmakex (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length vrt23)) (cons 70 1) (cons 10 pt01) (cons 42 0.0) (cons 10 pt05) (cons 42 0.0) (cons 10 pt07) (cons 42 bf123) (cons 10 tp03) (cons 42 bf223) (cons 10 tp04) (cons 42 bf323) (cons 10 pt08) (cons 42 0.0) (cons 10 pt06) (cons 42 0.0) (cons 10 pt02) (cons 42 0.0) (cons 10 pt04) (cons 42 bf623) (cons 10 tp02) (cons 42 bf523) (cons 10 tp01) (cons 42 bf423) (cons 10 pt03) (cons 42 0.0)))
       (princ)
**5)
C:Q2=Why version AutoCad2007 of sample-file-drawing.dwg?
C:A2=Because old ProgeCad do not load a new version of Ac2021
 
« Last Edit: February 22, 2021, 10:11:41 AM by d2010 »

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: Revolve in 3D help please.
« Reply #2 on: February 18, 2021, 04:03:23 AM »
@d2010
Thank you for your post, it will take me a bit of time to digest as there is quite a lot I do not understand.
Sample drawing attached, one is 2007 & the other is 2010 (my default, for compatibility with other software)

Steve
There is no such  thing as a 'silly question' to those who do not know!

d2010

  • Bull Frog
  • Posts: 323
Re: Revolve in 3D help please.
« Reply #3 on: February 22, 2021, 06:25:07 AM »
Yo do not fix alone inside yourDesktop,  :-o
C:Q1=I need help, why  the command("VPOint"..) not exists?
Code: [Select]
      for(;dyn!="N";)   
        { dyn=dfn_getx_readkey("[YRLFB10Nn]","\nDo you wish RevolveOptions?(Y.revolve)(R.right)(L.left)\n(F.forw)(B.backz)(P.pow)(1.allone)(N.needexit):");
           if (dyn=="R") command("-vpoint","1,0,0");else
           if (dyn=="L") command("-vpoint","-1,0,0");else
           if (dyn=="F") command("-vpoint","0,-1,0");else
           if (dyn=="B") command("-vpoint","0,1,0");else
           if (dyn=="P") command("-vpoint","0,0,1");else
           if (dyn=="1") command("_.vpoint","1,1,1");else
           if (dyn=="Y")
              { command("ucs","ZA",INpt,IANG);
                 command("revolve",ent1,"","0,0,0","0,0,100","180");
                 command("ucs","_P");
                 dyn="0";
               };
           if (dyn=="0")
              vla.Regen(con_acdoc,acActiveViewport);
        };
@d2010
Thank you for your post, it will take me a bit of time to digest as there is quite a lot I do not understand.
Sample drawing attached, one is 2007 & the other is 2010 (my default, for compatibility with other software)
Steve

Code: [Select]
(F.forw)(B.backz)(P.pow)(1.allone)(N.needexit):F-vpoint Unknown command
"-VPOINT".  Press F1 for help.

Command: 0,-1,0 Unknown command "0,-1,0".  Press F1 for help.

Command:
Do you wish RevolveOptions?(Y.revolve)(R.right)(L.left)
(F.forw)(B.backz)(P.pow)(1.allone)(N.needexit):B-vpoint Unknown command
"-VPOINT".  Press F1 for help.
Command: 0,1,0 Unknown command "0,1,0".  Press F1 for help.


Code - Auto/Visual Lisp: [Select]
  1.  )
  2.   (if (= ent1 $rr)
  3.     (alert (strcat msg readme.txt))
  4.     (progn
  5.       (while (/= dyn "N")
  6.         (progn (setq ;|a29470|;
  7.                  dyn
  8.                   (dfn_getx_readkey
  9.                     "[YRLFB10Nn]"
  10.                     "\nDo you wish RevolveOptions?(Y.revolve)(R.right)(L.left)\n(F.forw)(B.backz)(P.pow)(1.allone)(N.needexit):"
  11.                   )
  12.                )
  13.                (if (= dyn "R")
  14.                  (command "-vpoint" "1,0,0")
  15.                  (if (= dyn "L")
  16.                    (command "-vpoint" "-1,0,0")
  17.                    (if (= dyn "F")
  18.                      (command "-vpoint" "0,-1,0")
  19.                      (if (= dyn "B")
  20.                        (command "-vpoint" "0,1,0")
  21.                        (if (= dyn "P")
  22.                          (command "-vpoint" "0,0,1")
  23.                          (if (= dyn "1")
  24.                            (command "_.vpoint" "1,1,1")
  25.                            (if (= dyn "Y")
  26.                              (progn (command "ucs" "ZA" INpt IANG)
  27.                                     (command "revolve"  ent1
  28.                                              ""         "0,0,0"
  29.                                              "0,0,100"  "180"
  30.                                             )
  31.                                     (command "ucs" "_P")
  32.                                     (setq ;|a29864|;
  33.                                       dyn "0"
  34.                                     )
  35.                              )
  36.                            )
  37.                          )
  38.                        )
  39.                      )
  40.                    )
  41.                  )
  42.                )
  43.                (if (= dyn "0")
  44.                  (vla-regen con_acdoc acActiveViewport)
  45.                )
  46.         )
  47.       )
  48.     )
  49.   )
« Last Edit: February 22, 2021, 06:42:30 AM by d2010 »

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: Revolve in 3D help please.
« Reply #4 on: February 22, 2021, 07:04:35 AM »
Thank you d2010 for trying to help me, unfortunately my skills do not match yours and I am unable to understand what you are telling me/asking me.
Quote
C:Q1=I need help, why  the command("VPOint"..) not exists?
This exists within the CAD package (CMS Intellicad 10).

s.
There is no such  thing as a 'silly question' to those who do not know!

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: Revolve in 3D help please.
« Reply #5 on: February 25, 2021, 09:48:37 AM »
Hi All
Update:
I have made progress and now have the End Caps working, though probably not as slick as some, but working :)

I change direction slightly, by drawing the profile and creating the solid at World UCS 0,0,0,
I then created a block which was inserted and then orientated as required in the code, so almost invisible to the user :)
Here is the code, as I said not as a purist would like

Code: [Select]
;-----------------------------------------------------------------------;
; copied and modified code from https://www.cadtutor.net/forum/topic/20659-pressure-vessel-dished-head-lisp
;  
(defun DRAW_END_CAP (/ BA# BF# BF1# BF2# BF3# CUS DCL_ID DUNT$ FLG# HTHK$ HTHK# HOD$ HOD# HID# ;
                IDR# IKR# INPT IANG LNAM$ SFLG$ SFLG# THKL$ VRT# bf4# bf5# bf6# ENT1 ENT2)
;
(setq DH:HOD$  (rtos N6)) ;default OD dia, take from DIM file
(setq DH:HTHK$ (rtos N9)) ;default wall thickness, take from DIM file
(setq DH:SFLG$ (rtos N3)) ;default Straight Flange (required), take from DIM file
(setq EC1  (nth 1 SIZE_DIMS))
;
(setq INPT (getpoint "\nSpecify Insertion point of Fittng: "))
(setq IANG (getpoint INPT "\nDrag cursor to select Fitting orientation angle. ")
                  INPT (trans INPT 1 0) ; translates INPT from UCS to WORLD???
                  IANG (trans IANG 1 0)
)
(DH_SSP)
 ) ;end DRAW_END_CAP  

; Set Size Parameters Function.
;
(defun DH_SSP ()
  (setq HOD$  DH:HOD$ ;HOD$ is the main OD.
        HTHK$ DH:HTHK$ ;HTHK# is the wall thickness.
        SFLG$ DH:SFLG$ ;SFLG$ is the flange straight length.
        HOD#  (distof HOD$  2) ;distof converts string to real value, with 2 = decimal
        HTHK# (distof HTHK$ 2)
        SFLG# (distof SFLG$ 2)
        HID#  (- HOD# (* HTHK# 2))
        THKL$ DH:THKL$)
;
(setq IDR# (* HID# 0.9045) ;Head Rad ; change these if require to get profile shape (* HID# 0.9045)
   IKR# (* HID# 0.1727) ;Knuckle Rad ; change these if require to get profile shape (* HID# 0.1727)
  )
  (DH_CDH)
  )
;
; - Calculate Dished Head Function.
;
(defun DH_CDH (/ A1# A2# BA# CP01 CP02 CP03 DEG# PT01 pt01z1 PT02 pt02z1 PT03 pt03z1 PT04 pt04z1 PT05 PT06 PT07 PT08 PT09
                 RAD# RAD#A Sa# Sa2# Sb# Sc# TP01 tp01z1 TP02 tp02z1 TP03 TP04 P1 P2)
;
(setq ORIG (GETVAR 'UCSORG)) ;UCS ORG co-ords
(setq P1 ORIG)
(setq P2 (list 100 0 0))
;
; (setq RAD#   (angle INPT IANG)
(setq RAD#   (angle P1 P2)
  DEG#   (DH_RTD RAD#))
;
    (setq Sb#    (- (/ HID# 2.0) IKR#)
           Sc#    (- IDR# IKR#)
           Sa2#   (- (* Sc# Sc#)(* Sb# Sb#))
           Sa#    (sqrt Sa2#)
           RAD#A  (/ Sb# Sc#)
           A1#    (DH_RTD RAD#A)
           A2#    (- 360 A1#)
   );end setq
;
(setq BA# (list -64.3743 -52.7755))  ;part of LWPolyline bulge calculation
;
    (setq PT01 (polar ORIG (DH_DTR (+ DEG#   90))(/ HID# 2)) ;from insertion point.
  PT01z1 (POLAR PT01 (DH_DTR (+ DEG# 342))(* 1.5 HTHK#))
          PT03 (polar PT01 (DH_DTR (+ DEG#    0))   SFLG#)
          PT03z1 (polar PT01z1 (DH_DTR (+ DEG#    0))(- SFLG# (* 1.5 HTHK#)))
          PT02 (polar ORIG (DH_DTR (+ DEG#  270))(/ HID# 2)) ;from insertion point.
  PT02z1 (POLAR PT02 (DH_DTR (+ DEG# 18))(* 1.5 HTHK#))
          PT04 (polar PT02 (DH_DTR (+ DEG#    0))   SFLG#)
          PT04z1 (polar PT02z1 (DH_DTR (+ DEG#    0))(- SFLG# (* 1.5 HTHK#)))
          PT05 (polar PT01 (DH_DTR (+ DEG#   90))   HTHK#)
          PT07 (polar PT05 (DH_DTR (+ DEG#    0))   SFLG#)
          PT06 (polar PT02 (DH_DTR (+ DEG#  270))   HTHK#)
          PT08 (polar PT06 (DH_DTR (+ DEG#    0))   SFLG#)
          PT09 (polar ORIG (DH_DTR (+ DEG#    0))   SFLG#)
          CP01 (polar PT03 (DH_DTR (+ DEG#  270))   IKR#)
          CP02 (polar PT09 (DH_DTR (+ DEG#  180))   Sa#)
          CP03 (polar PT04 (DH_DTR (+ DEG#   90))   IKR#)
          TP01z1 (polar CP01 (DH_DTR (+ DEG#  A1#))(- IKR# (* 0.5 HTHK#)))
          TP03 (polar CP01 (DH_DTR (+ DEG#  A1#))(+ IKR# HTHK#))
          TP02z1 (polar CP03 (DH_DTR (+ DEG#  A2#))(- IKR# (* 0.5 HTHK#)))
          TP04 (polar CP03 (DH_DTR (+ DEG#  A2#))(+ IKR# HTHK#))
          BF1# (DH_ETC (/ (DH_DTR (nth 0 BA#)) 4)) ;bulge factor for curved lwpolylines
          BF2# (DH_ETC (/ (DH_DTR (nth 1 BA#)) 4)) ;bulge factor for curved lwpolylines
          BF3# (DH_ETC (/ (DH_DTR (nth 0 BA#)) 4)) ;bulge factor for curved lwpolylines
  bf4# (* bf1# -1)
  bf5# (* bf2# -1)
  bf6# (* bf3# -1)    
  )
  (DH_OLL) ; outside arc Point/Bulge list
)
;
; - Outline List Function.
;
(defun DH_OLL ()
     (setq VRT# (list PT01 PT05 PT07 TP03 TP04 PT08 PT06 PT02 PT02z1 pt04z1 tp02z1 tp01z1 pt03z1 PT01z1)
           BF# (list 0.0 0.0 0.0 BF1# BF2# BF3# 0.0 0.0 0.0 0.0 bf6# bf5# bf4# 0.0) FLG# 1)
  (DH_DDH)
  )
;
; - Draw Dished Head Profile Function.
;
(defun DH_DDH ( / ENT1 ENT2 )
  (entmakex

  (list
            (cons 0 "LWPOLYLINE") ;defines draw a LWPOLYLINE remember ""'s
            (cons 100 "AcDbEntity") ;defines draw an entity
;-----------(cons 8 LNAM) ;defines the layer specifics, if ommited uses default (is that current?)
            (cons 100 "AcDbPolyline") ;defines draw a LWPOLYLINE
            (cons 90 (length VRT#))
            (cons 70 1) ; 1 for closed 0 overwise
(cons 10 PT01) ;(cons 10 PNT number)  
(cons 42 0.0) ;(cons 42 BF  number)  
(cons 10 PT05)  
(cons 42 0.0)
(cons 10 PT07)
(cons 42 BF1#)  
(cons 10 TP03)
(cons 42 BF2#)
(cons 10 TP04)
(cons 42 BF3#)
(cons 10 PT08)
(cons 42 0.0)
(cons 10 PT06)
(cons 42 0.0)
(cons 10 PT02)
(cons 42 0.0)
(cons 10 PT02z1)  
(cons 42 0.0)
(cons 10 PT04z1)
(cons 42 BF6#)
(cons 10 TP02z1)
(cons 42 BF5#)
(cons 10 TP01z1)
(cons 42 BF4#)
(cons 10 PT03z1)
(cons 42 0.0)
(cons 10 PT01z1)  
(cons 42 0.0)
)
)
;--------------------------------------------------------------------
; - draw 3D end Cap
(progn
(command "ucs" "w" "")
(setq ENT1 (entlast))
(command "revolve" ENT1 "" "0,0,0" "100,0,0" "180")
(setq ENT2 (entlast))
(command "erase" ENT1 "")
(command "-block" EC1 "0,0,0" "L" "")
(command "erase" ENT2 "")
(command "ucs" "ZA" INPT IANG)
(command "insert" EC1 "0,0,0" "" "" "90")
(COMMAND "_ROTATE3D" "L" "" "x" "0,0,0" "90") ;"x" INPT "90")
(command "ucs" "w" "")
)
  )
;
; degree To Radians
(defun DH_DTR (a)(* pi (/ a 180.0)))
;
; Radian To Degrees
(defun DH_RTD (RAD#)(* 180.0 (/ RAD# pi)))
;
;  Elbow Tangent Calculation Function.
(defun DH_ETC (a) (/ (sin a) (cos a)))

Steve
There is no such  thing as a 'silly question' to those who do not know!

d2010

  • Bull Frog
  • Posts: 323
Re: Revolve in 3D help please.
« Reply #6 on: February 25, 2021, 01:20:56 PM »
C:Q1= How to set name for UCS?Do you need name for UCS?
Code: [Select]
Select objects: L 1 found
Select objects:
Specify first point on axis or define axis by
[Object/Last/View/Xaxis/Yaxis/Zaxis/2points]: x Specify a point on the X axis
<0,0,0>: 0,0,0
Specify rotation angle or [Reference]: 90
Command: ucs
Current ucs name:  *NO NAME*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis]
<World>: w
Command:
RevolveOptions?(1.revolve)(R.right)(L.left)
(F.forw)(B.backz)(P.pow)(o.1+1+1)(N.

Hi All.Update:I have made progress and now have the End Caps working, though probably not as slick as some, but working

« Last Edit: February 25, 2021, 02:28:44 PM by d2010 »

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: Revolve in 3D help please.
« Reply #7 on: February 25, 2021, 02:58:08 PM »
Looking at the solid shape the 'Revolve' command is 90deg out.
Probably a difference between the Intellicad I use and the Autocad you are using.

I haven't used Autocad since 2006, so my knowledge is very rusty.
Go to this part of the code and add the ';' below:
Code: [Select]
; - draw 3D end Cap
(progn
(command "ucs" "w" "")
(setq ENT1 (entlast))
; (command "revolve" ENT1 "" "0,0,0" "100,0,0" "180")
; (setq ENT2 (entlast))
; (command "erase" ENT1 "")
; (command "-block" EC1 "0,0,0" "L" "")
; (command "erase" ENT2 "")
; (command "ucs" "ZA" INPT IANG)
; (command "insert" EC1 "0,0,0" "" "" "90")
; (COMMAND "_ROTATE3D" "L" "" "x" "0,0,0" "90")
; (command "ucs" "w" "")
)
  )

It should then draw the closed lwpolyline shape.
It should be located at world 0,0,0 with the X axis running thro the middle, similar to the blue profile in my first post. try that first

Assuming that is correct remove the ';' you added at the Revolve command. and try that, you should have the solid at world 0,0,0
There is no such  thing as a 'silly question' to those who do not know!