Jump to content

Create new drawing with template


woodman78

Recommended Posts

This might seem very simple but I want to create a new drawing with a specified template using Lisp. I was going down the command route. This is what I had:

 

(defun c:Part8 ()

(command "filedia" "0")

(command "new" "T:/Drawing Tools/Templates/CCC Part 8 Cover Sheet.dwt" "")

(command "filedia" "1")

(princ)

)

 

If I run through this on screen it works but no in a lisp. Can anyone help?

Link to comment
Share on other sites

I got a bit further. This version will create the drawing based on the new template but it returns to the drawing that was open when the command was run. How do I avoid that?

 

 
(defun c:Part8 ()
(vla-Add (vla-get-Documents (vlax-get-acad-object)) "CCC Part 8 Cover Sheet.dwt")
(princ)
)

Link to comment
Share on other sites

I recently began writing a routine which is meant to automate some of our sheet creation too... but I went the ObjectDBX route, in lieu of the Documents collection.

 

From our master file, the user selects the frames (which represent the visible area for our plan sheets), and a new drawing is created for each programmatically, using the vla-attachexternalreference, and vla-insertblock functionality. The former to XREF our master file in Model Space, and the latter to insert our title block, logo, etc. into Paper Space.

 

I did include vla-addpviewport which correctly draws the Paper Space Viewport for our title block's dimensions, but for the moment I'm stuck with how to manipulate it's displayed view based on the associated frame selected in the Active Document (our master file). If I can get that to work, then populating the station range for the view in the title block attributes will be fairly easy.

 

I *think* the Target, and Snap* properties have something to do with it... but I need to make some time to test, in order to know for sure. Otherwise, I'll have to drop Visual LISP and go .NET (which I'd rather not do).

Link to comment
Share on other sites

  • 3 weeks later...

cheers alanjt

 

Just what i needed. My finish lisp asks for a template location. For use as a reference lisp for creating a dwt from a tool palette button.

 

 

;New From Template
(defun c:nft ()
(setq template(getstring "Specify Template Location:"))
(vla-activate (vla-Add (vla-get-Documents (vlax-get-acad-object)) template))
(princ)
)

 

Regards

Kapanther

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