Jump to content

Insert a block w/o inserting a block?


guitarguy1685

Recommended Posts

I am creating a lisp to use dimlinear to draw beams for structural drawings. What I'm doing is creating a custom user arrow to create a gap at the ends of the beams. For moment connections I am using Datum and Datum filled. I am also using DOT for drag connections and BOX for hinge ends. However the stock arrow heads do not come with a gap.

 

At first I was going to create more custom ones for them. When I tried that I found it was not easy to edit the arrow heads with Quick Properties. If the arrow head is already "Userd arrow" I could not simply select it again and find it. I would have to click a stock one first THEN go back to "User arrow". So what I did was edit the stock ones to give me the gap I want. This would make it feel similar to what Revit does.

 

This is where the LISP comes in. I wrote a lisp to draw a beam on the correct layer and skip text input. What I want my lisp to do is insert my edited "stock" arrow head blocks if they do not already exist. I knwo how to use tblsearch to find if they exist.

 

What I want to do is insert the 5 blocks I want with out actually picking insertion points and then having to delete them after. I hope this makes sense. Below is a picture of what I am looking to do.

 

beams.jpg

Link to comment
Share on other sites

Open your Template file (.DWT), and insert all of your custom arrow head blocks, then delete the instances shown in model space... be sure to leave the block references (i.e., do no purge the block references). Perhaps even setup your default Dimension Style(s). Save.

 

Now every time you open a new drawing from your template, the custom arrow heads are already available.

 

Hope this helps!

Link to comment
Share on other sites

For something like that, I'd keep them in the template, as RenderMan said, but I'd also put them in a separate DWG and have them inserted in the drawing at startup. That way, you can safely purge or open a drawing that wasn't created with the template and still have the desired arrowhead blocks.

I use this method for dim/text/mleader styles.

 

Here's the code I keep in our acaddoc.LSP file:

  (command "_.insert" "CES-DIMSETUP=" nil)
 (command "_.purge" "_b" "CES-DIMSETUP" "_n")

 

The first line will only insert the block definition, which brings in all styles and block definitions existing withing the DWG. The second line is optional, but it just purges the inserted block definition our, keeping everything that's actually wanted/needed.

Link to comment
Share on other sites

Awesome thanks for your help. The (command "...) line works great. apparently it doesn't work with (vl-cmdf "_.insert" "block nill). It kept giving me an error.

 

I do have it in the template. I just wanted to program a failsafe into the lisp just incase it those blocks were purged in a maintenance process. The lisp looks like this.

 

(defun C:BEAM (/ CRlayr CRecho *error* pt1 pt2)

(setq CRlayr (getvar "CLAYER"))

(setq CRecho (getvar "CMDECHO"))

;-------------------------------------------------------------------------

(setq *error* ;;;resets sysvar incase of

(lambda (msg) ;;;an error, esc, exit, cancel

(setvar "CMDECHO" CRecho)

(setvar "CLAYER" CRlayr)

(princ msg)

(princ)))

;---------------------------------------------------------------

(setvar "CMDECHO" 0)

(if

(= (tblsearch "layer" "S-STEL-BEAM") nil)

(vl-cmdf "_.layer" "new" "S-STEL-BEAM" "color" "4" "S-STEL-BEAM" "set" "S-STEL-BEAM" "")

(setvar "CLAYER" "S-STEL-BEAM")

);if

(if

(= (tblsearch "block" "_Beam") nil)

(progn

(command "_.insert" "_Beam" nil);;;;I figure if this block is not inuse the others have not been inserted either. I will probably chage this area and run a check for each block

(command "_.insert" "_BoxBlank" nil)

(command "_.insert" "_DatumBlank" nil)

(command "_.insert" "_DatumFilled" nil)

(command "_.insert" "_Dot" nil)

);prong

);if

(if

(= (tblsearch "dimstyle" "LPAS-BEAM") nil)

(progn

(vl-cmdf "_.dimstyle" "restore" "Standard")

(_beam_setup);;;;;runs subroutine to set dimvars

(vl-cmdf "_.dimstyle" "save" "LPAS-BEAM")

)

(vl-cmdf "_.dimstyle" "restore" "LPAS-BEAM")

);if

(setq pt1 (getpoint "\nSelect start of beam: "))

(setq pt2 (getpoint "\nSlect end of beam: " pt1))

;(setvar "CLAYER" "S-STEL-BEAM")

(vl-cmdf "_.dimstyle" "r" "LPAS-BEAM")

(vl-cmdf "_.dimaligned" pt1 pt2 "t" " " pt1)

(setvar "CLAYER" CRlayr)

(setvar "CMDECHO" CRecho)

(princ)

)

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