See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: vlax-curve and UCS

  1. #1
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Question vlax-curve and UCS

    I like the vlax-curve-* function a lot. They make life soooo much simpler.

    However, I've run into a problem. If I ask the user to select an entity with entsel, then I can use the picked point to get the vlax-curve-GetClosestPointTo. This works fine as long as the entity was drawn parallel to the WCS and the view is plan on the WCS. Try this with (say) a line with different Z values and you get an unexpected point.

    All I can think of is to create a temporary flattened copy of the entity and then obtain the param at this point. Then convert the param back to the original. This becomes quite hectic if you also consider polylines, arcs, etc.

    Does anyone know of an easier way? Am I missing something? The curve functions need a point directly on the entity before you can obtain the param ... from which you can get the rest of the stuff. A point (even) slightly off will produce an error.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  2. #2
    Active Member
    Join Date
    2007-06
    Posts
    97
    Login to Give a bone
    0

    Default Re: vlax-curve and UCS

    Is it possibly a matter of transforming the UCS point returned by entsel to a WCS point required by vlax-curve-GetClosestPointTo?

  3. #3
    I could stop if I wanted to
    Join Date
    2007-08
    Posts
    201
    Login to Give a bone
    1

    Default Re: vlax-curve and UCS

    Hi,

    Assuming :
    Code:
    (setq ent (entsel))
    You can do:
    Code:
    (setq param (vlax-curve-getParamAtPoint
                  (car ent)
                  (trans (osnap (cadr ent) "_nea") 1 0)
                )
    )
    But I had some issues with this expression on old style 2d polylines, so I write the following, which works fine with old style 2d polylines but may return wrong results with 3d polylines...
    Code:
    (setq param (vlax-curve-getParamAtPoint
                  (car ent)
                  (vlax-curve-getClosestPointToProjection
                    (car ent)
                    (trans (cadr ent) 1 0)
                    (mapcar '-
                            (trans (getvar "VIEWDIR") 1 0)
                            (trans '(0 0 0) 1 0)
                    )
                  )
                )
    )

  4. #4
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: vlax-curve and UCS

    Gile, thanks. I think I'd have to go the OSnap-Nearest route. I extremely seldom use the old Polylines. On second thought maybe a combination of the 2, I could always check what entity type it is before getting the point - then use ether of the algorithms depending on which would work.

    The only problem I can see with this is if the DWG is a bit full, you can never be sure that osnap uses the same entity. You aperture is usually differently sized to your pickbox, so it "could" pick-up another entity instead.

    BTW, haven't tried it yet, but would a ssget be more "accurate" if I then use the ssnamex. I know that if I use a (ssget "F" ...) the points returned by ssnamex is exactly on the crossing point of the fenceline. Just not sure how to enforce a single entity by picking a point with ssget, and if the point returned would give something other than entsel.

    seant61, to see what I'm referring to - see the attached DWG. There's a line drawn from 0,0,0 to 200,200,200. Now enter the following on the command prompt:
    Code:
    (setq en (entsel))
    Pick the line about 3/4 of the way up to the right-top end. Then type the following:
    Code:
    (setq eo (vlax-ename->vla-object (car en)))
    (setq pt1 (vlax-curve-getclosestpointto eo (cadr en)))
    (command "_.line" "_non" pt1 pause (cadr en) "")
    When asked pick a point off the line. This should draw 2 lines starting from the ClosestPointTo to the point picked by the user. You can clearly see a large discrepancy between the 2. And the DWG doesn't even have any UCS set. It's all in WCS and Plan view. It's just that the line has different Z values.

    Now a similar thing happens when you've got a polyline / arc / circle / etc on a tilted UCS.
    Attached Files Attached Files
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  5. #5
    Active Member
    Join Date
    2007-06
    Posts
    97
    Login to Give a bone
    0

    Default Re: vlax-curve and UCS

    I see what you mean.

Similar Threads

  1. vlax-curve-... functions
    By David.Hoole in forum AutoLISP
    Replies: 11
    Last Post: 2009-07-17, 10:05 AM
  2. Map VBA's VLAX ?
    By KevinBarnett in forum VBA/COM Interop
    Replies: 2
    Last Post: 2005-01-28, 06:26 AM
  3. Map VBA's VLAX ?
    By KevinBarnett in forum AutoCAD Map 3D - General
    Replies: 0
    Last Post: 2005-01-27, 09:00 AM
  4. vlax-invoke
    By mahazen in forum AutoLISP
    Replies: 2
    Last Post: 2004-08-07, 04:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •