Jump to content

Example .NET Jigging: A parabola parable


Recommended Posts

As an exercise in .NET Jigging, I created* a couple of routines that interactively produce parabolas.

 

The routine animated here constructs the parabola based on width and height.

 

Geometry created:

A geometrically precise, degree 2 spline.

 

The benefit of a spline versus the splined polyline version of a parabola is the ability to return accurate Perp and Tan osnaps during subsequent drafting operations.

 

* Footnote:

 

I’m in the process of cleaning up the routines and will post them here shortly (in case anyone is interested).

The routines may seem a bit familiar in that I emulated the ObjectARX SDK's EllipseJig routine. I think enough has been added to qualify as separate examples in and of themselves.

Reduced.gif

Link to post
Share on other sites
  • Replies 56
  • Created
  • Last Reply

Top Posters In This Topic

  • SEANT

    26

  • Lee Mac

    16

  • wannabe

    6

  • khoshravan

    4

Top Posters In This Topic

Posted Images

This animation demonstrates the routine that constructs a parabola based on a vertex, focal point, and width.

 

Geometry created:

Degree 2 spline with Point entity at the focus.

pvf.gif

Link to post
Share on other sites

The routines can still use a little work; specifically to allow a more intuitive direct distance entry. Still, I'm pretty pleased at how they perform (AutoCAD 2009).

 

Attached is the source code as well as a compiled dll if anyone is willing to give it a test drive.

 

All comments and criticisms would be greatly appreciated.

 

Updated routines at this Post

 

http://www.cadtutor.net/forum/showpost.php?p=233991&postcount=34

Link to post
Share on other sites

Thanks.

 

Does "Jigging" work in a similar method to the grvecs in LISP?

 

I have to believe it does.

 

As an old VBAer, though, I’m tempted to say no CAD user deserves so much dynamic interaction. :P

 

Actually, it is kind of fun. :)

Link to post
Share on other sites
Lee Mac
Thanks.

 

 

 

I have to believe it does.

 

As an old VBAer, though, I’m tempted to say no CAD user deserves so much dynamic interaction. :P

 

Actually, it is kind of fun. :)

 

Would you say this kind of level of dynamic interaction is on par with "ghosting" (another term i've seen thrown around on here......) :P

Link to post
Share on other sites

Indeed. But, dynamic interaction, jigging, ghosting . . . .

 

Given the presumption that Computer Aided Drafting should be high precision stuff, an AutoCAD developer may need to think twice about adding features that encourage “eyeballing”.

 

Conversely, the presumption that Computer Aided Design should be a fluid, interactive experience, an AutoCAD developer needs to offer feedback early and often.

 

That kind of leaves it open for us to do what’s most fun. :)

Link to post
Share on other sites
Lee Mac

Given the presumption that Computer Aided Drafting should be high precision stuff, an AutoCAD developer may need to think twice about adding features that encourage “eyeballing”.

 

Yeah, good point - but seeing a live visual representation of what you are designing is a great aid :) Just gotta use it wisely.

Link to post
Share on other sites

 

Does "Jigging" work in a similar method to the grvecs in LISP?

 

 

I have to believe it does.

 

 

After a bit more investigation, this notion should be modified a bit. I’d say JIGGING is part of the same pipeline as GRVECS though, perhaps, slightly further downstream.

 

Presumably, the graphics to display entities consist of 1 to multiple vectors between the appropriate pixels. AutoCAD has a mechanism to create a vector array based on entity type. I think GRVECS (or, in .NET, Editor.DrawVectors) is upstream from mechanism, JIGGING ties into that mechanism.

 

Consequently, a routine that employs jigging can avoid processing a potentially large vector array and just update the parameters of the entity type to achieve the dynamic morphing seen on screen.

 

I’m sure GRVECS and Editor.DrawVectors have their place – especially if the developer is providing entity types not native to AutoCAD. Fortunately, jigging, and the other API counterparts, greatly eases matters involving standard geometries.

Link to post
Share on other sites
Lee Mac
After a bit more investigation, this notion should be modified a bit. I’d say JIGGING is part of the same pipeline as GRVECS though, perhaps, slightly further downstream.

 

Presumably, the graphics to display entities consist of 1 to multiple vectors between the appropriate pixels. AutoCAD has a mechanism to create a vector array based on entity type. I think GRVECS (or, in .NET, Editor.DrawVectors) is upstream from mechanism, JIGGING ties into that mechanism.

 

Consequently, a routine that employs jigging can avoid processing a potentially large vector array and just update the parameters of the entity type to achieve the dynamic morphing seen on screen.

 

I’m sure GRVECS and Editor.DrawVectors have their place – especially if the developer is providing entity types not native to AutoCAD. Fortunately, jigging, and the other API counterparts, greatly eases matters involving standard geometries.

 

Are you saying that whereas GRVECS redraws the array of vectors everytime, Jigging just modifies the existing vectors to suit?

Link to post
Share on other sites

I couldn’t say for certain as AutoCAD does it all behind the scenes. If I had to guess, AutoCAD generates the vectors, and quantity of vectors, as needed.

 

If that is true then AutoCAD would just modify one vector for a line while “rubberbanding”, but dynamically add or subtract vectors as needed for curved entities. If we consider my Width/Height Parabola, Autocad may start out with one vector then add more as the curve tightens.

 

I’m also going to guess that AutoCAD performs a ByEntity regen (as opposed to ByViewport) through the JIGGING process. I say that because the entity is somewhat staccato while morphing quickly, but does not incur too lengthy a delay as would be required for a full view regen.

Link to post
Share on other sites
Lee Mac

I’m also going to guess that AutoCAD performs a ByEntity regen (as opposed to ByViewport) through the JIGGING process. I say that because the entity is somewhat staccato while morphing quickly, but does not incur too lengthy a delay as would be required for a full view regen.

 

Good Point, kind of like a (redraw) during a grvecs or grdraw operation I suppose :)

 

*just trying to associate the two languages*

 

I experimented with the (redraw) and grvecs using a sampler from ASMI's talon LISP :)

 

(defun c:tline    (/ cent    tstr tbox xsiz ysiz grdat spt
          cpt cang apt bpt pt1 pt2 pt3 pt4)
 (vl-load-com)
 (if (and (setq cent (car (entsel "\nSelect Curve to Align Text > ")))
      (member (cdr (assoc 0 (entget cent)))
          '("LINE" "LWPOLYLINE" "POLYLINE" "CIRCLE" "ELLIPSE" "ARC" "SPLINE"))
      (setq tstr (getstring t "\nSpecify Text > ")))
   (progn
     (setq tbox (textbox (list (cons 1 tstr))))
     (alert (vl-princ-to-string tbox))
     (setq xsiz (- (caadr tbox) (caar tbox))
       ysiz (- (cadadr tbox) (cadar tbox)))
     (prompt "\nSelect Text Placement...")
     (while (= 5 (car (setq grdat (grread t 1))))
   (redraw)
   (if (= 'list (type (setq spt (trans (cadr grdat) 1 0))))
     (progn
       (setq cpt  (vlax-curve-getclosestpointto cent spt)
         cang (angle cpt spt)
         apt  (polar cpt cang 2)
         bpt  (polar cpt cang (+ 2 ysiz))
         pt1  (polar apt (+ cang (/ pi 2)) (/ xsiz 2))
         pt2  (polar apt (- cang (/ pi 2)) (/ xsiz 2))
         pt3  (polar bpt (- cang (/ pi 2)) (/ xsiz 2))
         pt4  (polar bpt (+ cang (/ pi 2)) (/ xsiz 2)))
       (grvecs (list 2 pt1 pt2 2 pt2 pt3 2 pt3 pt4 2 pt4 pt1)))))
     (Make_Text apt tstr (- cang (/ pi 2))))
   (princ "\n<!> Error in Selections <!>"))
 (redraw)
 (princ))

(defun Make_Text  (txt_pt txt_val rot)
 (entmake (list '(0 . "TEXT")
        '(8 . "0")
        (cons 10 txt_pt)
        (cons 40 (max 2.5 (getvar "TEXTSIZE")))
        (cons 1 txt_val)
        (cons 50 rot)
        '(7 . "STANDARD")
        '(71 . 0)
        '(72 . 1)
        '(73 . 1)
        (cons 11 txt_pt))))

 

Its quite interesting when you comment out the (redraw) in the grread loop :)

Link to post
Share on other sites

Its quite interesting when you comment out the (redraw) in the grread loop :)

 

 

Hey, that is amusing. :D

 

With regard to regen and redraw, I’d expect to see better jigging performance when dragging an entity (even a complex Block Reference) compared to morphing one. I remember reading how Autodesk made a good effort to minimize graphic delays by using pixel manipulation (Redraw versus the Vector Creation/Regen) when possible.

 

Edit: I have to admit that this bit of speculation (in red) is not panning out. If the Block Reference is complex enough, all forms of modification, dragging or morphing, suffer rather pathetic refresh rates. :oops:

 

In that light, and depending on what constitutes the best dynamic feedback, the "jigging” process may benefit from a temporary adjustment to the VIEWRES system variable. May make morphing excessively complex and curvy entities less staccato.

Link to post
Share on other sites
Lee Mac

How I understand Jigging/ghosting... (please correct me if I am wrong!)

 

Ghosting: - similar to the effect you get when using the "move" command, when dragging an object across the screen

 

Jigging: - produces an effect similar to grvecs in LISP, drawing multiple vectors on the screen.

Link to post
Share on other sites
How I understand Jigging/ghosting... (please correct me if I am wrong!)

 

Ghosting: - similar to the effect you get when using the "move" command, when dragging an object across the screen

 

Jigging: - produces an effect similar to grvecs in LISP, drawing multiple vectors on the screen.

 

Can we delve deeper into the depths of jigging, please? Or just a link to where I can self-educate in this context of the semantics?

Link to post
Share on other sites

I’m not saying I’m qualified necessarily to create a ground up tutorial on jigging – given that I’ve attempted the process only this one time. I do think I learned enough to make and explain (comment the appropriate lines of code) a basic circle creation jig.

 

Provided someone hasn’t posted a more sensible example before then, I’ll try to get something together over the next few days.

 

I haven’t yet done any geometry rotation/translation (“ghosting”) yet so I guess I’d be as interested in an example of that as anyone.

Link to post
Share on other sites
I’m not saying I’m qualified necessarily to create a ground up tutorial on jigging – given that I’ve attempted the process only this one time. I do think I learned enough to make and explain (comment the appropriate lines of code) a basic circle creation jig.

 

Provided someone hasn’t posted a more sensible example before then, I’ll try to get something together over the next few days.

 

I haven’t yet done any geometry rotation/translation (“ghosting”) yet so I guess I’d be as interested in an example of that as anyone.

 

I just don't understand the concept of jigging. I appreciate what's gone before in this thread, but it's just one of those things I need additional help in grasping.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...