Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inserting a block on a point of an arc

6 REPLIES 6
Reply
Message 1 of 7
sovby
431 Views, 6 Replies

Inserting a block on a point of an arc

Does anyone know of a lisp routine that would insert a block @ a specific point on an arc? For instance if I have an arc that has a radius of 20'-0" & I want to insert a block at a set distance from the end of the arc.i could probably use the divide or measure command but I was hoping I could do it with lisp. I would also like to be able to move the object along the path of the arc at a specific distance. Any help would be greatly appreciated
6 REPLIES 6
Message 2 of 7
_Tharwat
in reply to: sovby

Try this ... and change the block name to you required one ..

 

(defun c:Test (/ BlockName dist entity lngth)
  (vl-load-com)
  ;;; Tharwat 19. May. 2012 ;;;
  (setq BlockName "MyBlock")
  (cond
    ((not (setq dist (getdist "\n specify distance on Arc :"))))
    ((not (setq entity (car (entsel "\n select Arc :")))))
    ((not (eq (cdr (assoc 0 (entget entity))) "ARC")))
    ((if (> (setq lngth (vlax-curve-getDistatPoint
                          entity
                          (vlax-curve-getEndPoint entity)
                        )
            )
            dist
         )
       (entmakex
         (list
           '(0 . "INSERT")
           (cons 2 BlockName)
           (cons 10 (vlax-curve-getpointatdist entity (- lngth dist)))
           '(41 . 1.0)
           '(42 . 1.0)
           '(43 . 1.0)
         )
       )
       (princ "\n Distance is Longer than the Arc 's Length *** ")
     )
    )
  )
  (princ)
)

 

Message 3 of 7
_Tharwat
in reply to: sovby

Another routine using if function and start the distance from the start point or an Arc ... also change the "MyBlock" to your Block name .

 

(defun c:Test (/ BlockName dist entity lngth)
  (vl-load-com)
 (setq BlockName "MyBlock")
  (if (and (setq dist (getdist "\n specify distance on Arc :"))
           (setq entity (car (entsel "\n select Arc :")))
           (eq (cdr (assoc 0 (entget entity))) "ARC")
      )
    (if (> (setq lngth (vlax-curve-getDistatPoint
                         entity
                         (vlax-curve-getEndPoint entity)
                       )
           )
           dist
        )
      (entmakex
        (list '(0 . "INSERT")
              (cons 2 BlockName)
              (cons 10 (vlax-curve-getpointatdist entity dist))
              '(41 . 1.0)
              '(42 . 1.0)
              '(43 . 1.0)
        )
      )
      (princ "\n Distance of Arc is longer than Arc 's Length ")
    )
    (princ)
  )
  (princ)
)

 

Message 4 of 7
sovby
in reply to: _Tharwat

Thanks, I really appreciate your help. I will try these & let you know how it works

Message 5 of 7
sovby
in reply to: _Tharwat

The first one seems to work the best. I made a slight error in what i was asking. It is actually a polyline with a radius instead of an arc so i just replaced arc with lwpolyline & it worked pretty good. I should of asked you this before but it would be great if i could rotate the block on the radius of the polyline just like you would do if you had a polar array. I am enclosing a sample file, the poyline is offset from a curb at 5'-0" & i want to be able to insert the block & rotate it along the distance that i specify from the end of the polyline & then i will just move the equipment to the curb that is parallel to the polyline. Thanks again & any help you can give me would be very much appreciated

Message 6 of 7
pbejse
in reply to: sovby


@sovby wrote:
@Anonymous anyone know of a lisp routine that would insert a block @ a specific point on an arc? For instance if I have an arc that has a radius of 20'-0" & I want to insert a block at a set distance from the end of the arc.i could probably use the divide or measure command but I was hoping I could do it with lisp. I would also like to be able to move the object along the path of the arc at a specific distance. Any help would be greatly appreciated

Here's a suggestion, why not make the COD-Menuboard part of the car block or vice versa, it appears that the location of the board wil rely upon the persons point of view inside the vehicle.

 (DB visibility parameter <see atatched dwg file>)

 

As for using divide/measure within a lisp code

(defun c:demo ()
       (setq dist (cond
 ((getdist (strcat "\nEnter distance"
                 (if dist (strcat " <" (rtos dist) ">: ") ": ")
                            )))(dist))
                )
       (command "_measure" pause "_Block" "COD-Menuboard" "_Yes" dist)
      (princ)
      )

 

But you need to redefine the COD-Menuboard insertion point to eliminate the need to move the object after insertion.

 

You can modify tharwats code to include control for visibility.

 

Message 7 of 7
sovby
in reply to: pbejse

Yes, thats true. There will be a car there that needs to have a clear line of sight for the menuboard. Basically the client has standards setup that they want followed. The distance between the two drive thu windows is usually 42'-45' & they like around 80' from the rear drive thru window to the first cod equipment. I just mentioned the measure command because in the past we have been doing this by using the lengthen command to get the desired distance & then drawing a line from the polyline that is offset 5' to the inside radius of the curb & putting the cod equipment there. The line that is offset is the line that the 80' distance is set. The menuboard is always a set angle from the cod equipment so i made that into a block. I figured lisp would be a great way to make this happen instead of using multiple commands but i am still learning about what the different code will do. I like your idea of changing the insertion point for the block so i wont have to move it. That's what i am trying do. I want to lessen the number of picks & clicks i use for this repetitive task & speed things up.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost