Error when using vlax-curve-getFirstDeriv function

Error when using vlax-curve-getFirstDeriv function

rlheath117
Contributor Contributor
1,642 Views
9 Replies
Message 1 of 10

Error when using vlax-curve-getFirstDeriv function

rlheath117
Contributor
Contributor

Hi everyone,

I am writing what I thought would be a simple lisp to rotate my snapang based on a selected point of an existing entity. Part of the lisp uses the getFirstDeriv function at a selected location on the entity. The abbreviated code is as follows:

 

(defun c:oline ( / p1 p2 ent )
(vl-load-com)

(setq esel (nentsel "\nSelect an Object:"))

ent (car esel)
pt1 (getpoint "\nSelect Location of Intersection:"))

(princ pt1)

(setq pt2 (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent pt1)))

(princ)
)

 

It works when I am in WCS and in a UCS if the base point is the same as the WCS base point. But, if I create a UCS that has a different basepoint than the WCS I get an error.

 

I think it might have something to do with a point translation of some kind but I can't figure it out. Any help would be appreciated.

 

Thanks

0 Likes
Accepted solutions (2)
1,643 Views
9 Replies
Replies (9)
Message 2 of 10

Moshe-A
Mentor
Mentor

@rlheath117 hi,

 

the first argument of (vlax-curve-getFirstDeriv) and (vlax-curve-getFirstDeriv) should be VLX-object 

 

 

moshe

 

0 Likes
Message 3 of 10

Anonymous
Not applicable

This is the issue which I generally used to get earlier but after taking help from Epson projector support this is the first time i am getting same error once again. How do I solve this issue, I am thinking of contacting again. It works when I am in WCS and in a UCS if the base point is the same as the WCS base point.

0 Likes
Message 4 of 10

Kent1Cooper
Consultant
Consultant

@rlheath117 wrote:

.... if I create a UCS that has a different basepoint than the WCS I get an error.

 

I think it might have something to do with a point translation of some kind ....


 

Try this [further abbreviated to essentials]:

 

(setq
  esel (nentsel "\nSelect an Object:")
  ent (car esel)
  pt1 (trans (getpoint "\nSelect Location of Intersection:") 1 0); current-UCS to WCS
  pt2 (vlax-curve-getFirstDeriv (vlax-ename->vla-object ent) (vlax-curve-getParamAtPoint ent pt1))
)

 

The (getpoint) returns in the current UCS, but the (...getParamAtPoint) wants a WCS location.

Kent Cooper, AIA
0 Likes
Message 5 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

Well, Kent was little bit faster. But it does not have to be VLX.

 

(vl-load-com)

(defun c:oline ( / p1 p2 ent )

  (if (and (setq esel (nentsel "\nSelect an Object:"))
	   (setq ent (car esel))
	   (setq pt1 (getpoint "\nSelect Location of Intersection:"))
	   )
    (print (setq pt2 (vlax-curve-getFirstDeriv ent (vlax-curve-getParamAtPoint ent (vlax-curve-getClosestPointTo ent (trans pt1 1 0)))))))

(princ)
)
0 Likes
Message 6 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

@ВeekeeCZ wrote:

.... it does not have to be VLX.


 

True -- I think I know what other function I was mixing it up with that requires a VLA-object rather than an entity name.  You can omit the red parts in the second line containing red parts in my previous reply.

Kent Cooper, AIA
0 Likes
Message 7 of 10

rlheath117
Contributor
Contributor

 Kent1Cooper and BeekeeCZ,

 

Thanks for the replies, but I still get an error when I use it in a UCS that has a different base point than the WCS.

 

Are you able to use it in that case?

0 Likes
Message 8 of 10

Kent1Cooper
Consultant
Consultant

@rlheath117 wrote:

.... I still get an error when I use it in a UCS that has a different base point than the WCS.

Are you able to use it in that case?


 

Just the pared-down part I posted worked for me.  If you're incorporating into something larger, maybe there's something in the relationship to what surrounds it.

Kent Cooper, AIA
0 Likes
Message 9 of 10

rlheath117
Contributor
Contributor

Kent,

Sorry for wasting your time on that last reply... what you supplied worked.

 

Thanks to you and BeekeeCZ.

 

 

0 Likes
Message 10 of 10

Anonymous
Not applicable

this is really true that it might have something to do with a point translation of some kind but I can't figure it out. Any help would be appreciated but helped me to get all the detail of this.

0 Likes