Jump to content

Rotating a block at insertion


aloy

Recommended Posts

Hi everyone,

 

I have a series of lines connected from end to end. I want to do two things:

 

1) Place a text giving the length of the line on perpendicular bisector near the center of each line.

 

2) Insert a block (an arrow) at the center of each line aligned with the line.

 

I can do the second, but the first does't work with the following, what ever the angle I give in place of 0,

the block appears in the same original rotation.

 
;(setq plst1(list pt pt1 alfa dis))
;(setq plist(cons plst1 plist))
(defun draw1()

 (mapcar '(lambda(a) (command "_insert" "arrow" (car a) 1 1 0)) plist)

 (mapcar '(lambda(a) (command "_text" "_non"(car a) 0.6 (* (caddr a) 57.3) (rtos (cadddr a) 2 2))) plist)
 
(princ)
)

 

Is there a way to solve this?.

 

Thanking in advance.

 

Aloy

Link to comment
Share on other sites

I would recommend looking into ( entmake ) the arrow INSERT

 

[color=#8b4513];|[/color]
 Assuming :
   The BLOCK [color=#2f4f4f]"ARROW"[/color] exists in the current drawing
   The arrow direction points 0 degrees X axis WCS
   sp = Start Point
   ep = End Point
|[color=#8b4513];[/color]

 [b][color=BLACK]([/color][/b]entmake [b][color=FUCHSIA]([/color][/b]list [b][color=NAVY]([/color][/b]cons 0 [color=#2f4f4f]"INSERT"[/color][b][color=NAVY])[/color][/b]
                [b][color=NAVY]([/color][/b]cons 2 [color=#2f4f4f]"ARROW"[/color][b][color=NAVY])[/color][/b]
                [b][color=NAVY]([/color][/b]cons 10 [b][color=MAROON]([/color][/b]mapcar '[b][color=GREEN]([/color][/b]lambda [b][color=BLUE]([/color][/b]a b[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]* [b][color=RED]([/color][/b]+ a b[b][color=RED])[/color][/b] 0.5[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] sp ep[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
                [b][color=NAVY]([/color][/b]cons 50 [b][color=MAROON]([/color][/b]angle sp ep[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

 

-David

Link to comment
Share on other sites

Thanks David & Tharwat for replying.

 

Modified the code a bit as follows:

 

(mapcar '(lambda(a) (entmake (list (cons 0 "INSERT") (cons 2 "ARROW") (cons 10 (car a)) (cons 50 (caddr a))))) plist)

 

Works perfectly. Here is a picture.

Picturex.jpg

Link to comment
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
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...