Author Topic: Half ellipse with ActiveX  (Read 1658 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Half ellipse with ActiveX
« on: July 01, 2010, 11:00:50 PM »
This was fun so I thought I'd share it.

Sometimes we need to draw half an ellipse.

See the piccy below .. the left side view showing the hidden lines.

I can't post the complete code for this, but those interested may find the ellipse drawing code usefull.

Some of the methods are from my library, but I think you'll get the core idea.


note : code may be best viewed using the forum Mercury theme, set 'Current Theme' in Forum Profile ' Look and Layout Preferences'
Code: [Select]
;;-----------------------------------------------------------
  (defun _selectPoints ()
    (and (setq sp (kdub:getpoint "Select Start Point (ENTER to QUIT)"
                                 "Quit"
                                 1
                                 '("Quit")
                                 nil
                                )
         )
         (/= "Quit" sp)
         (setq
           op (kdub:sgp "Select ORIENTATION Direction (in current UCS)" nil sp)
         )
         (setq orient_ang (angle sp op)
               sp         (polar sp orient_ang weldgap)
         )
    )
  )
  ;;-----------------------------------------------------------
  ;;
  (while (_selectPoints)
    ;;Proceed
    (kdub:ucs:blackbox
      nil
      (trans sp acucs acworld)
      (kdub:vec:points->vector
        (trans sp acucs acworld)
        (trans (polar sp (+ orient_ang kglobal:rad90) -100) acucs acworld)
      )
      (kdub:vec:points->vector (trans sp acucs acworld)
                               (trans op acucs acworld)
      )
      t
    )
    ;;---------------------------------------   
    ;; Draw the outline
    (kdub:mark)
    (setq outline (vlax-ename->vla-object
                    (kbub:EntmakePlineInUCS vertexlist var:layer-outline50 0)
                  )
    )
    ;; Add Xdata to profile
    (_xdata_elbow45 (entlast))
    ;;--------------------------------------
    ;; add ellipse halves
    (if (= index 0)
      ;; left view
      (progn (vla-put-layer
               (setq obj (vlax-invoke kglobal:modelspace
                                      'addEllipse
                                      (trans (list 0. var7 0.) acucs acworld)
                                      (trans (list od2 0. 0.) acucs acworld T)
                                      (sin kglobal:rad45)
                         )
               )
               var:layer-hiddenmedium
             )
             (vla-offset obj (- wt))
             (vlax-put obj 'StartParameter PI)
             (vlax-put obj 'EndParameter 0.0)
             (vla-put-layer (vlax-invoke obj
                                         'mirror
                                         (vlax-curve-getStartPoint obj)
                                         (vlax-curve-getEndPoint obj)
                            )
                            var:layer-outline50
             )
      )
      ;; else right view
      (progn (vla-put-layer
               (setq obj (vlax-invoke kglobal:modelspace
                                      'addEllipse
                                      (trans (list 0. var7 0.) acucs acworld)
                                      (trans (list od2 0. 0.) acucs acworld T)
                                      (sin kglobal:rad45)
                         )
               )
               var:layer-outline50
             )
             (vla-offset obj (- wt))
      )
    )
    ;;---------------------------------------   
    ;; Draw the CenterLine
    (if (= pipe:drawcenterline 1)
      (vla-put-layer (vlax-invoke kglobal:modelspace
                                  'addline
                                  (trans (list 0. 0. 0.) acucs acworld)
                                  (trans (list 0. var7 0.) acucs acworld)
                     )
                     var:layer-centershort
      )
    )
    ;;---------------------------------------   
    ;; Draw the WallThickness
    (if (= pipe:drawwallthickness 1)
      (progn (vla-put-layer
               (setq wallLine (vlax-invoke kglobal:modelspace
                                           'addline
                                           (trans (list 0. 0. 0.) acucs acworld)
                                           (trans (list 0. var7 0.) acucs acworld)
                              )
               )
               var:layer-hiddenmedium
             )
             (vla-offset wallLine (- od2 wt))
             (vla-offset wallLine (- (- od2 wt)))
             (vla-delete wallLine)
      )
    )
    ;;--------------------------------------
    (getstring "\n Paused for debug")
    ;;--------------------------------------
    (vl-cmdf "_.REDRAW")
    (vl-cmdf "_.UCS" "_Restore" prev:ucs)
  )

« Last Edit: July 01, 2010, 11:33:59 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

AIberto

  • Guest
Re: Half ellipse with ActiveX
« Reply #1 on: May 21, 2016, 05:12:55 AM »
Oh! miss many many sub-function ,and Variable has no value

eg.
variable: weldgap ,acucs, acworld ,kglobal:rad90

sub-function:
kdub:mark
kdub:vec:points->vector
_xdata_elbow45
pipe:drawcenterline
pipe:drawwallthickness

many! many! ..........

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2148
  • class keyThumper<T>:ILazy<T>
Re: Half ellipse with ActiveX
« Reply #2 on: May 21, 2016, 05:43:56 AM »
Quote
I can't post the complete code for this, but those interested may find the ellipse drawing code useful.

Some of the methods are from my library, but I think you'll get the core idea.

Some of those are AutoCAD variables also.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.