Author Topic: Revising Code  (Read 2266 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Revising Code
« on: July 17, 2015, 07:33:56 AM »
This ties back to the code on this page here.

http://www.theswamp.org/index.php?topic=49770.msg549346#new


I'm trying to understand how to add a circle to a portion of the code above.
When you execute the original code it will draw a parking stall line that is a "T" 20' long.
I would like it to draw a parking stall line "I" and add a circle to the right side that is 2' Radius in the middle of the parking stall.
h2 = 20' (Because it would draw a 9'x20' parking stall).

Right now as it draws it creates a polyline that is a "T".
Code: [Select]
(command "pline" (list 0 0 0) (list 0 h2 0) (list -0.5 h2 0) (list 0.5 h2 0) "")
I wanted to remove the "T" and just have a line "I" and a circle "o" to one side if possible.
Code: [Select]
(command "pline" (list 0 0 0) (list 0 h2 0) "circle" (list 4.5 4.5 0) (list "Radius Size") "")


Code: [Select]
;;------------------------------Create Block-------------------------------   
 (defun BLKP()
   (if (not (tblsearch "block" "PARP"))
      (progn
         (setq osm (getvar "OSMODE"))
         (setvar "OSMODE" 0)

   ; Enter parking bay Block Length
          (if (not h2) (setq h2 6.00))

          (setq h (getreal (strcat "\nSpecify Parking Bay Height <" (rtos h2 2 2) ">:")))
       (if (not h) (setq h h2)(setq h2 h))

         (command "CLAYER" "0")
         (command "pline" (list 0 0 0) (list 0 h2 0) (list -0.5 h2 0) (list 0.5 h2 0) "")
         (command "-BLOCK" "PARP" (list 0 0 0) (entlast) "")
         (setvar "OSMODE" osm)
      ) ;progn
    ) ;if
  ) ;defun


I hope this makes some sense. Thanks for any help on this!
Civil3D 2020

jvillarreal

  • Bull Frog
  • Posts: 332
Re: Revising Code
« Reply #1 on: July 20, 2015, 02:07:39 PM »
Just draw your objects including the "I" and the circle, then, rather than using entlast in this line:
(command "-BLOCK" "PARP" (list 0 0 0) (entlast) "")
which only selects the last object created, maybe create a selection set beforehand and pass the selection set to your block command.
« Last Edit: July 20, 2015, 03:20:59 PM by jvillarreal »

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Revising Code
« Reply #2 on: July 20, 2015, 03:38:27 PM »
Hey, thanks for the input. That is ALOT easier to control thru the lisp. Thanks for sharing.
Civil3D 2020

ChrisCarlson

  • Guest
Re: Revising Code
« Reply #3 on: July 20, 2015, 04:18:38 PM »
I'd move to entmake

Code - Auto/Visual Lisp: [Select]
  1. (defun Circle (cen rad)
  2.   (entmakex (list (cons 0 "CIRCLE")
  3.                   (cons 10 cen)
  4.                   (cons 40 rad))))

http://www.cadtutor.net/forum/showthread.php?44768-Entmake-Functions

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Revising Code
« Reply #4 on: July 20, 2015, 05:11:13 PM »
I think I am not understanding how this would fit into the lisp above. I do understand the block concept. Hassel is I have to create or bring in the block everytime oppose to on the fly.
Civil3D 2020

squirreldip

  • Newt
  • Posts: 114
Re: Revising Code
« Reply #5 on: July 20, 2015, 07:51:10 PM »
This is an issue I've had and now create needed blocks within code:

http://www.theswamp.org/index.php?topic=49794

Hope someone finds this method useful.