Jump to content

Recommended Posts

Posted

Hello,

I have made this small Lisp to draw a small arrow, But it does not work with vertical or angular directions. So any ideas to force that this Lisp to work properly at all directions ?.

(defun c:arrow (/ p1 Len Alen p2 p3)
(setq p1 (getpoint	"\nSpecify Start point of Arrow:")
     p2 (getpoint p1 	"\nSpecify End point of Arrow:")
     dist (distance p1 p2)
     vrt (/ dist 3)
     p3 (list (car p2)(- (cadr p2) vrt))
     p4 (list (car p3) (+ (cadr p3)(* vrt 2))) )
(setq old (getvar 'osmode) new (setvar 'osmode 0))
(vl-cmdf "_.pline" p1 "_w" 0 0 p3 p4 "_c" )
(vl-cmdf "_.-hatch" "_s" (entlast) "" "_p" "_solid" "" "")
(setvar 'osmode old)
 (princ))

 

Tharwat

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    9

  • alanjt

    8

  • jammie

    3

  • fixo

    1

Popular Days

Top Posters In This Topic

Posted

Take a look at ORTHOMODE system variable

 

~'J'~

Posted

Actually the ORTHOMODE can't affect on my Lisp due to the (cadr value) or I can

call it the predesigned or precast Lisp. :lol:

 

Tharwat

Posted

You may need to introduce a few extra calcs to get it to work. The functions POLAR & ANGLE should be useful

 

Just a s sample, working with your code

 


     (setq  dist (distance p1 p2)
     vrt (/ dist 3))
     (setq  pickAngle (angle p1 p2))

     (setq p3 (polar p2 (+ pickAngle (/ pi 2)) vrt))
     (setq p4 (polar p2 (- pickAngle (/ pi 2)) vrt))

      ))

 

There could be some additional considertaions possibly, ANGDIR setvar

Posted
You may need to introduce a few extra calcs to get it to work. The functions POLAR & ANGLE should be useful

Just a s sample, working with your code

There could be some additional considertaions possibly, ANGDIR setvar

Thank you jammie, That's really helpful.

Posted
You may need to introduce a few extra calcs to get it to work. The functions POLAR & ANGLE should be useful

 

Just a s sample, working with your code

 

Thanks jammie, very nice.

 

My best regards

 

Tharwat

Posted

Why not just draw an LWPolyline with a width, rather than a closed one with hatch?

 

Quick and dumb example...

 

(defun c:TEst (/ p1 p2)
 (if (and (setq p1 (getpoint "\nSpecify first point: "))
          (setq p2 (getpoint p1 "\nSpecify next point: "))
     )
   (progn
     (command "_.pline" "_non" p1 "_w" 0. (/ (distance p1 p2) 3.) "_non" p2 "")
     (setvar 'plinewid 0.)
   )
 )
 (princ)
)

Posted
Why not just draw an LWPolyline with a width, rather than a closed one with hatch?

 

I have thought of that once before, but I wanted to hit tow birds with one shout.:wink:

 

First, to know the principle of following the direction of the GETPOINT for my future routines.

Second, my drawings are in different scales, so the LWPolyline needs to specify the second width of it manually.

 

Tharwat

Posted
I have thought of that once before, but I wanted to hit tow birds with one shout.:wink:

 

First, to know the principle of following the direction of the GETPOINT for my future routines.

Second, my drawings are in different scales, so the LWPolyline needs to specify the second width of it manually.

 

Tharwat

OK. I just followed similar principals to your above routine.
Posted
Why not just draw an LWPolyline with a width, rather than a closed one with hatch?

 

Quick and dumb example...

 

(defun c:TEst (/ p1 p2)
 (if (and (setq p1 (getpoint "\nSpecify first point: "))
          (setq p2 (getpoint p1 "\nSpecify next point: "))
     )
   (progn
     (command "_.pline" "_non" p1 "_w" 0. (/ (distance p1 p2) 3.) "_non" p2 "")
     (setvar 'plinewid 0.)
   )
 )
 (princ)
)

HA HA

I believe that your codes were not posted from the first time. when I wrote my last reply.

 

Right..... ?

Posted
HA HA

I believe that your codes were not posted from the first time. when I wrote my last reply.

 

Right..... ?

COrrect.......

Posted

BTW, you should post your completed/fixed routine for completeness and it might help someone else down the line.:wink:

Posted

Here it goes with no hesitation at all to all my dear members ....... enjoy it.

(defun c:arrow (/ p1 p2 dist vrt pickangle p3 p4 old new)
(setq p1 (getpoint	"\nSpecify Start point of Arrow:")
     p2 (getpoint p1 	"\nSpecify End point of Arrow:")
     dist (distance p1 p2)
     vrt (/ dist 3)
     pickAngle (angle p1 p2)
    p3 (polar p2 (+ pickAngle (/ pi 2)) vrt)
    p4 (polar p2 (- pickAngle (/ pi 2)) vrt))
(setq old (getvar 'osmode)
     new (setvar 'osmode 0))
(vl-cmdf "_.pline" p1 "_w" 0 0 p3 p4 "_c" )
(vl-cmdf "_.-hatch" "_s" (entlast) "" "_p" "_solid" "" "")
(setvar 'osmode old)
 (princ))

 

Tharwat

Posted

See revisions...

 

(defun c:arrow (/ p1 Len Alen p2 p3)
 (if (and (setq p1 (getpoint "\nSpecify Start point of Arrow:"))
          (setq p2 (getpoint p1 "\nSpecify End point of Arrow:"))
     )
   (progn
     (setq dist      (distance p1 p2)
           vrt       (/ dist 3)
           pickAngle (angle p1 p2)
           p3        (polar p2 (+ pickAngle (/ pi 2)) vrt)
           p4        (polar p2 (- pickAngle (/ pi 2)) vrt)
     )
     (vl-cmdf "_.pline" "_non" p1 "_w" 0 0 "_non" p3 "_non" p4 "_c")
     (vl-cmdf "_.-hatch" "_s" (entlast) "" "_p" "_solid" "")
   )
 )
 (princ)
)

Posted

Really strong and faster. certainlly.

No comments .

 

And what's made it that strong in implementing the routine ?

Is it the IF function ?

 

 

Thanks

Posted
Really strong and faster. certainlly.

No comments .

 

And what's made it that strong in implementing the routine ?

Is it the IF function ?

 

 

Thanks

 

See notes...

 

(defun c:arrow (/ p1 Len Alen p2 p3)
 (if (and (setq p1 (getpoint "\nSpecify Start point of Arrow:")) ; notice these are broken up to avoid error if the first is not defined, etc.
          (setq p2 (getpoint p1 "\nSpecify End point of Arrow:")) ; only if these two variables are filled, will the routine continue
     )
   (progn
     (setq dist      (distance p1 p2)
           vrt       (/ dist 3)
           pickAngle (angle p1 p2)
           p3        (polar p2 (+ pickAngle (/ pi 2)) vrt)
           p4        (polar p2 (- pickAngle (/ pi 2)) vrt)
     )
     (vl-cmdf "_.pline" "_non" p1 "_w" 0 0 "_non" p3 "_non" p4 "_c") ; if you add "_non" before defining a point in any command, it will ignore any running OSnaps. Thus, you don't have to worry with osmode
     (vl-cmdf "_.-hatch" "_s" (entlast) "" "_p" "_solid" "")
   )
 )
 (princ)
)

Posted

I am Speechless.

you did convinced me well.

 

Thanks Alan

 

My best regards

 

Tharwat

Posted
Thank you jammie, That's really helpful.

Your welcome Michaels, glad you found it helpful

Posted
Thanks jammie, very nice.

 

My best regards

 

Tharwat

 

No problem, your welcome tharwat313

Posted
I am Speechless.

you did convinced me well.

 

Thanks Alan

 

My best regards

 

Tharwat

Enjoy. :)......

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...