Jump to content

Recommended Posts

Posted

How can you add some blocks that will be used in a project so when I gave the compiled version to my friends there don't be any need to copy block files by hand?

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • anishtain4

    10

  • pBe

    5

  • Lee Mac

    2

  • Tharwat

    2

Posted

Can you be more specific to the point , or explain more ?

Posted

Assume that you are using some blocks in your drawings, a lot of your coworkers do the same but they may not be in your office. i want to make a project and embed these blocks in the project. my ultimate goal is to make a dcl so by clicking on them they put only these standard blocks by making it easy for them. So the question is how do you embed blocks (dwg files) into your project?

Posted

Does it mean that you want to extract all your blocks within a specific drawing to a separate drawing ? :?

Posted

I have a block library for myself as dwg files, like sink.dwg, wc.dwg, ...

 

I load them in my lisp using lines like this one:

(command "._insert" (strcat mhjv-blocks "/Schematics/BathTub.dwg") *cancel*)

 

but when I compile the lisp file and hand it to my colleagues it's not possible (I don't say this out of laziness) to ask them copy library in the file, so I'm looking for a way to embed these drawings in my lisp and address them withing the project.

 

PS: putting library on the network, tool palette, design center are not applicable in my case

Posted

You can entmake your blocks in your code. With some special object that cann't entmake, just make an dxf file, read-line all binary and write-line as a dxf file whenever lisp run, then insert and final delete it

Posted

Well having an entmake is too cumbersome as the blocks are not all simple!!

I didn't get the dxf part, you mean to include the dxf file along with the project? or somehow put its lines in my lisp and make a file out of them on run time?

Posted
Assume that you are using some blocks in your drawings, a lot of your coworkers do the same but they may not be in your office. i want to make a project and embed these blocks in the project. my ultimate goal is to make a dcl so by clicking on them they put only these standard blocks by making it easy for them. So the question is how do you embed blocks (dwg files) into your project?

 

By "project" you mean a lisp program?

 

but when I compile the lisp file and hand it to my colleagues it's not possible (I don't say this out of laziness) to ask them copy library in the file, so I'm looking for a way to embed these drawings in my lisp and address them withing the project.

 

PS: putting library on the network, tool palette, design center are not applicable in my case

 

One thing i dont get anishtain4, if you can give them access to your "project" (program file) , why not give them the blocks along with the lisp file? a single drawing file with all the blocks in there would be enough. Its not laziness, its called "Adherance to Standards and Procedures"

 

If your guys cant handle that, might as well "recreate" all your blocks within the lisp program (suggested by ketxu). and that will make the lisp file rather large and will run very slow IMO. and that will defeat the purpose of the "project"

 

I'm just saying,.... ;)

Posted

Dear pBe, I will not give the lisp file, I have to compile it to make only one file. I can't hand a series of files since the program is going to be distributed in several offices and I don't have the chance to explain it to everyone who is using this project. However I may hand one folder. would this help? how can you get the path of current folder where your file is running from? (not the current document path)

Posted

Make an executable zip file that includes the lisp program and drawing files . winzip (or any other file compression program out there) has the ability to include the full path info. When extracting the file it would still go to its orignal Folder path.(preferably drive letter "C" and you can maintain a full path on your "insert" line (strcat mhjv-blocks "c:/Schematics/BathTub.dwg") as the extracted file would include the blocks on the same directory name.

Posted

What if I want to find the location of the file that current lisp function is running from? I'm going to compile the program as vlx not lisp

Posted

I have absolutely no idea what you're talking about :D

 

I was using some lisp files on my own and my boss suggested I make them usable for other, by distributing a set of this lisps in side of our products (pipes) we have a better market chance and they will give me a good raise. So this is the first time I'm making a project, that's why I'm so noob in it

Posted

pBe I couldn't see how this was related to my question. anyhow

 

Does visual lisp has a function to load blocks from a file instead of using

 

(command "._insert" (strcat blocks-root "/Schematics/Package.dwg") *cancel*)

Posted

Well this is a too good example, but I have set out blocks using wblock so now every file is a block itself. I just need a function, something like (vla-load-block) or else. unfortunately developers documentation is missing a lot of functions and I can't find the appropriate function to do this.

 

Is it good to stick with the (command "._insert" ...) function? I'm only loading 13 blocks and the hesitation is obvious, like 3-5 sec waiting time

Posted (edited)

Here's another one: ---> http://lee-mac.com/copyblockfromdrawing.html

 

What i'm trying to tell you is the VL function to use is vla-CopyObjects, its easier to understand the function by looking at a code thats already been done.

Look at the code first then ask the questions. ;)

 

Is it good to stick with the (command "._insert" ...) function? I'm only loading 13 blocks and the hesitation is obvious, like 3-5 sec waiting time

 

You can also use vla-insertblock method if thats what you need, it doesnt take as long as the native insert.

 

Compared with vla-copyobjects method the latter physically placed block the block on the drawing space whilst the former in the drawing document

Edited by pBe
Posted

I think that he want to entmake a block

 

this is my way

- Create the block normally

- Use CAB's routine

- And/Or this

- And/Or this

- And/Or this

- ANd/Or this

- Add the created lisp to your routine

- Have fun

Posted

Here's an idea: WBlock your blocks to a DXF file each. Then add the following function to your lisps:

(defun getBlockFileName (name / fname str source dest)
 (if (and (setq source (open (setq fname (strcat name ".DXF")) "r"))
          (setq fname (strcat (getvar 'TempPrefix) fname))
          (setq dest (open fname "w")))
   (progn
     (while (setq str (read-line source)) (write-line str dest))
     (close source)
     (close dest)
     fname)))

;; (vl-doc-export 'getBlockFileName) ;Only needed if you want to call this from outside the VLX

Compile all your lisps into a VLX and include the DXF blocks as resources in that same VLX.

 

Once the VLX is loaded, you can call this function which will copy the DXF block into the user's temp directory and then return the path to that file. This path you can send to the insert command as normal.

Posted

I haven't tested the idea, but would you necessarily need to copy the DXF resources to the temp directory? If you have access to the resources from the VLX, could you not insert the DXF data directly from the VLX?

 

/guessing

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