Jump to content

Recommended Posts

Posted

(defun c:test ()

(setq p1 (getpoint "\nPick point L: ")

p2 (getpoint "\nPick point R: ")

p3 (polar p2 (dtr 270.0) (+ (/ 0.10 2)0.10))

p4 (polar p3 (dtr 180.0)0.10)

p5 (polar p4 (dtr 150.0)0.10)

sum (- (distance p1 p2 )0.373)

p6 (polar p5 (dtr 180.0) sum)

p7 (polar p6 (dtr 210.0)0.10)

p8 (polar p7 (dtr 180.0)0.10)

Layer "A-BEAM"

);endq

 

(command "_layer" "m" Layer "")

(command "pline" p1 p2 p3 p4 p5 p6 p7 p8 p1 "")

(princ)

)

 

 

(defun dtr (x)

;define degrees to radians function

 

(* pi (/ x 180.0))

;divide the angle by 180 then

;multiply the result by the constant PI

 

) ;end of function

(princ)

Posted

First, you will need to provide more information regarding what you want to achieve - after disabling the OSMODE the routine draw something, just cannot know if is wrong or not:

 

(setvar "OSMODE" 0)

 

Second, please edit your post to follow the rules for code posting.

 

Regards,

Mircea

Posted

untitled.jpg

 

pick p1 p2 draw section concrete slab on ground

Posted

Please see below my corections in red:

 

(defun c:test ( / [color=red]MyOldOsmode MyOldOrtho[/color] )
[color=red] ;retain current setting to be able to restore later
(setq MyOldOsmode (getvar "OSMODE")
      MyOldOrtho (getvar "ORTHOMODE"))
;disable auto-Osnap and activate Ortho mode
(setvar "OSMODE" 0) (setvar "ORTHOMODE" 1)
[/color] 
(setq p1 (getpoint "\nPick point L: ")
      p2 (getpoint p1 "\nPick point R: ")
      p3 (polar p2 (dtr 270.0) (+ (/ 0.10 2)0.10))
      p4 (polar p3 (dtr 180.0)0.10)
      p5 (polar p4 (dtr 150.0)0.10)
      sum (- (distance p1 p2 )0.373)
      p6 (polar p5 (dtr 180.0) sum)
      p7 (polar p6 (dtr 210.0)0.10)
      p8 (polar p7 (dtr 180.0)0.10)
      Layer "A-BEAM"
);endq

(command "_layer" "m" Layer "")
(command "pline" p1 p2 p3 p4 p5 p6 p7 p8 p1 "")

[color=red] ;restore previous environment
(setvar "OSMODE" MyOldOsmode) (setvar "ORTHOMODE" MyOldOrtho)
[/color] (princ)
)

 

Regards,

Mircea

Posted

Mircea , you have localized your added variables only , so what about the rest variables and the subfunction DTR ?

Posted
Mircea , you have localized your added variables only , so what about the rest variables and the subfunction DTR ?

There are many improvements that can be done to that piece of code - I have only fixed it to work as OP expected. I don't intent to re-write it.

 

Regards,

Mircea

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...