Jump to content

offset 2 lines add dimensions and tag


gazzalp

Recommended Posts

id like a lisp that would add a band beam to a plan. the way i see it working is i select a grid, it offsets a line 1200mm to each side on a layer called concrete, and set to linetype "awthidden2". Id like it to also automatically add the dimension of 2400, as well as a block we have called SYM-SlabTag (not sure if this one is do-able, and if it is if the person writing the lisp needs to see the block)

Link to comment
Share on other sites

Here you go. For now i just have put it all on one dwg, but what would actually happen ios the grid will be on an xref, all the other items i want on the new drawing. So i will open a new drawing with nothing on it, xref in the grid, start the lisp and it will ask for the grid, i select the grid (select top and bottom of grid) and it puts the two green lines on (1200 each side of grid) with the dimension and "slab tag" Thanks guys

test.dwg

Link to comment
Share on other sites

It will be really hard to offset lines each side of an Xref - that is the trouble I am finding.

 

Because, obviously with a block one is unable to offset any lines off of the block itself.

Link to comment
Share on other sites

I kind of worded it bad; it doesnt necisserily have to offset those lines. The way i see it is we have a grid line, The lisp could ask us for the centre line (pick the bottom and top most points of the grid) then it knows the outside most lines will be 1200 either side of the points we picked. Then in the middle add tjhe dimension and tag. In a way its like a multiline, where theres 2 lines that are dashed and the centre of that multiline is the grid (except i dont want a multiline, thats just an example) hope this clears things up.

Link to comment
Share on other sites

Try this:

 

(defun c:gridline (/ *error* varLst oldVars tpt bpt ang llpt l1 lrpt l2 l1mid l2mid)

 ;     --- Error Trap ---

   (defun *error* (msg)
   (mapcar 'setvar varLst oldVars)
   (if (= msg "")
       (princ "\nFunction Complete.")
       (princ "\nError or Esc pressed... ")
   ) ;_  end if
   (princ)
   ) ; end of *error*

   (setq varLst  (list "CMDECHO" "CLAYER" "OSMODE")
     oldVars (mapcar 'getvar varLst)
   ) ; end setq 

 ;    --- Error Trap ---

   (setvar "cmdecho" 0)

   (defun makelay (x)
   (if (not (tblsearch "Layer" x))
       (command "-layer" "m" x "")
   ) ;_  end if
   ) ;_  end defun

   (if    (and
       (setq tpt (getpoint "\nSelect Top Point of Gridline: "))
       (setq bpt (getpoint "\nSelect Base Point of Gridline: "))
   ) ;_  end and
   (progn
       (setq ang (angle tpt bpt))
       (setvar "osmode" 0)
       (makelay "Concrete")
       (setvar "clayer" "Concrete")
       (command "_line"
            (setq llpt (polar tpt (+ ang (/ pi 2)) 1200))
            (polar llpt ang (distance tpt bpt))
            ""
       ) ;_  end command
       (setq l1 (entlast))
       (command "_line"
            (setq lrpt (polar tpt (- ang (/ pi 2)) 1200))
            (polar lrpt ang (distance tpt bpt))
            ""
       ) ;_  end command
       (setq l2 (entlast))
       (command "_chprop" l1 l2 "" "lt" "awthidden2" "")
       (setq l1mid (polar llpt ang (/ (distance tpt bpt) 2)))
       (setq l2mid (polar lrpt ang (/ (distance tpt bpt) 2)))
       (makelay "Dimensions")
       (setvar "clayer" "Dimensions")
       (command "_dimaligned" l1mid l2mid l1mid)
       (alert
       "\nI'm not sure what you would like done with the block...
          \nCheers
           \nLee Mac."
       ) ;_  end alert
   ) ;_  end progn
   (alert "\nProgram Requires Two Selected Points.")
   ) ;_  end if
   (*error* "")
) ;_  end defun




Link to comment
Share on other sites

Awesome Lee, you are a champion. Only thing is it doesnt insert the block (which you know about because it came up with the dialog box telling me) all i want with the block is it to be inserted under the dimension, in the middle of the band (as long as it doesnt clash with the dimension it should be fine). Is this possible?thanks for your help.

Link to comment
Share on other sites

Awesome Lee, you are a champion. Only thing is it doesnt insert the block (which you know about because it came up with the dialog box telling me) all i want with the block is it to be inserted under the dimension, in the middle of the band (as long as it doesnt clash with the dimension it should be fine). Is this possible?thanks for your help.

 

I can add that, but is the block stored under a specific filepath, or just in th ACAD search directory? If its in the search directory, I'll just need the block name, if its somewhere else, I'll need the block name and full filepath to add to the LISP. Or I can leave that part blank for you to fill in.

Link to comment
Share on other sites

Dont have alot of time now to look for it, but if you leave the areas i need to fill in (maybe put in bold something like add file path/name here) that way i wont have to bother you again asking where to put it :P

Link to comment
Share on other sites

Lee, the block is in a folder that is located on our server, so im guessing i need the file path... If you leave the part blank and let me know what to fill in where i should be able to handle that. Thanks alot

Link to comment
Share on other sites

Try this:

 

(defun c:gridline (/ *error* varLst oldVars tpt bpt slab
          ang llpt l1 lrpt l2 l1mid l2mid blkpt)

 ;     --- Error Trap ---

   (defun *error* (msg)
   (mapcar 'setvar varLst oldVars)
   (if (= msg "")
       (princ "\nFunction Complete.")
       (princ "\nError or Esc pressed... ")
   ) ;_  end if
   (princ)
   ) ; end of *error*

   (setq varLst  (list "CMDECHO" "CLAYER" "OSMODE")
     oldVars (mapcar 'getvar varLst)
   ) ; end setq 

 ;    --- Error Trap ---

   (setvar "cmdecho" 0)

   (defun makelay (x)
   (if (not (tblsearch "Layer" x))
       (command "-layer" "m" x "")
   ) ;_  end if
   ) ;_  end defun

   (if    (and
       (setq tpt (getpoint "\nSelect Top Point of Gridline: "))
       (setq bpt (getpoint "\nSelect Base Point of Gridline: "))
       (setq slab (getstring t "\nSpecify Slab Thickness: "))
   ) ;_  end and
   (progn
       (setq ang (angle tpt bpt))
       (setvar "osmode" 0)
       (makelay "Concrete")
       (setvar "clayer" "Concrete")
       (command "_line"
            (setq llpt (polar tpt (+ ang (/ pi 2)) 1200))
            (polar llpt ang (distance tpt bpt))
            ""
       ) ;_  end command
       (setq l1 (entlast))
       (command "_line"
            (setq lrpt (polar tpt (- ang (/ pi 2)) 1200))
            (polar lrpt ang (distance tpt bpt))
            ""
       ) ;_  end command
       (setq l2 (entlast))
       (command "_chprop" l1 l2 "" "lt" "awthidden2" "")
       (setq l1mid (polar llpt ang (/ (distance tpt bpt) 2)))
       (setq l2mid (polar lrpt ang (/ (distance tpt bpt) 2)))
       (makelay "Dimensions")
       (setvar "clayer" "Dimensions")
       (command "_dimaligned" l1mid l2mid l1mid)
       (setq blkpt (polar tpt ang (- (/ (distance tpt bpt) 2) 1000)))
       (command "-insert"
            [b][color=Red]"C:\..." ; << Filepath goes here[/color][/b]
            blkpt
            ""
            ""
            "0.0"
            slab)    
   ) ;_  end progn
   (alert "\nProgram Requires Two Selected Points.")
   ) ;_  end if
   (*error* "")
) ;_  end defun

 

REMEMBER: when you specify a filepath, use double \\ to indicate one backslash.

 

i.e

 

C:\\Users\\Lee Mac\\Documents\\block.dwg

Link to comment
Share on other sites

Ok its making more sense to me now.... Two problems - could we possibly change it so the block that is inserted goes on a layer called "Tags" and also scales to 100 (it inserts at 1) Thanks Lee

Link to comment
Share on other sites

Ok its making more sense to me now.... Two problems - could we possibly change it so the block that is inserted goes on a layer called "Tags" and also scales to 100 (it inserts at 1) Thanks Lee

 

Try this:

 

(defun c:gridline (/ *error* varLst oldVars tpt bpt slab
          ang llpt l1 lrpt l2 l1mid l2mid blkpt)

 ;     --- Error Trap ---

   (defun *error* (msg)
   (mapcar 'setvar varLst oldVars)
   (if (= msg "")
       (princ "\nFunction Complete.")
       (princ "\nError or Esc pressed... ")
   ) ;_  end if
   (princ)
   ) ; end of *error*

   (setq varLst  (list "CMDECHO" "CLAYER" "OSMODE")
     oldVars (mapcar 'getvar varLst)
   ) ; end setq 

 ;    --- Error Trap ---

   (setvar "cmdecho" 0)

   (defun makelay (x)
   (if (not (tblsearch "Layer" x))
       (command "-layer" "m" x "")
   ) ;_  end if
   ) ;_  end defun

   (if    (and
       (setq tpt (getpoint "\nSelect Top Point of Gridline: "))
       (setq bpt (getpoint "\nSelect Base Point of Gridline: "))
       (setq slab (getstring t "\nSpecify Slab Thickness: "))
   ) ;_  end and
   (progn
       (setq ang (angle tpt bpt))
       (setvar "osmode" 0)
       (makelay "Concrete")
       (setvar "clayer" "Concrete")
       (command "_line"
            (setq llpt (polar tpt (+ ang (/ pi 2)) 1200))
            (polar llpt ang (distance tpt bpt))
            ""
       ) ;_  end command
       (setq l1 (entlast))
       (command "_line"
            (setq lrpt (polar tpt (- ang (/ pi 2)) 1200))
            (polar lrpt ang (distance tpt bpt))
            ""
       ) ;_  end command
       (setq l2 (entlast))
       (command "_chprop" l1 l2 "" "lt" "awthidden2" "")
       (setq l1mid (polar llpt ang (/ (distance tpt bpt) 2)))
       (setq l2mid (polar lrpt ang (/ (distance tpt bpt) 2)))
       (makelay "Dimensions")
       (setvar "clayer" "Dimensions")
       (command "_dimaligned" l1mid l2mid l1mid)
       (setq blkpt (polar tpt ang (- (/ (distance tpt bpt) 2) 1000)))
       (makelay "Tags")
       (setvar "clayer" "Tags")
       (command "-insert"
            [b][color=Red]"C:\..." ; << Filepath goes here[/color][/b]
            blkpt
            "100"
            "100"
            "0.0"
            slab)    
   ) ;_  end progn
   (alert "\nProgram Requires Two Selected Points.")
   ) ;_  end if
   (*error* "")
) ;_  end defun




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