TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TimSpangler on March 03, 2010, 01:04:00 PM

Title: Block Manager [Option 2]
Post by: TimSpangler on March 03, 2010, 01:04:00 PM
****NEW CODE ADDED****
-Check the lisp header for changes

So in response to this thread >Here< (http://www.theswamp.org/index.php?topic=32058.0).

I have finally gotten off of my arse and finished the first OpenDCL project that I started.  I want to thank JB for some of the ObjectDBX code.

A quick run down:

-It is a palette form that utilizes OpenDCL.
-It was created in [5.1.2.3]
-It writes all of its setting to the registry (theswamp\block manager\)
-It can use either a Folder library or a Drawing container Library
-It has the ability to save libraries as favorites for quicker access
-It has the ability to select the insert layer as long as it is in the drawing
-It has the ability to open the current block for editing
-It has a quick link to theswamp.....

Here are some pics:

The Palette:
(http://www.theswamp.org/screens/index.php?dir=TimSpangler/&file=Palette.png)

The Favorites:
(http://www.theswamp.org/screens/index.php?dir=TimSpangler/&file=Favorites.png)

The File info:
(http://www.theswamp.org/screens/index.php?dir=TimSpangler/&file=FileInfo.png)

The palette starts with a dialog asking for the library type.  Once selected it will then ask for the library location:

-For Folder type this will be the top level of the library and will show all the sub folders as libraries in the drop down.  Select the library and it will show all of the drawings in that
sub folder as blocks in the list.

-For Drawing type this will be the folder that contains all of the container drawings.  The drawing will be listed as libraries.  Select the library and the blocks in that drawing will be listed as block in the list.

You can change library type by selecting either the large text or the button.

To add the current library as a favorite select the favorite button (the little piece of paper) and it will bring up the dialog.  Just hit add. Delete should be obvious.  Load is as it says, you can also load by dbl clicking the favorite in the list.

To reset the directory, just click the open file button and reselect the directory.  This will change the current directory.

Double clicking the block in the block list will show the file properties of the selected block (if it is a drawing) or the properties of the container drawing.

Double clicking the the block preview will insert the block on the layer listed (if it is not changed it should be the current layer).  Using the insert button will do the same.

Close button will close the palette (duh)

The ? will not do anything  (YET).

I hope that this explains most everything, if not, you know where to find me (hiding in the corner)

Comments / Feedback welcome

ENJOY!

Title: Re: Block Manager [Option 2]
Post by: jbuzbee on March 03, 2010, 01:18:46 PM
Tim,

Excellent work!  I like the graphic at the bottom!  Thanks for doing this - I was getting bored with mine (very short attention span  :lol: )

I'm eager to download it and give it a try.  Looks like a lot of nice features . . ..

jb

PS: good work.
Title: Re: Block Manager [Option 2]
Post by: nivuahc on March 03, 2010, 01:26:10 PM
Tim,

Looks fantastic!

One minor problem:

Code: [Select]
Specify scale factor: <1>
.-insert Enter block name or [?]: S:\ACAD\Blocks\\J-Box.dwg
Invalid block name.
; error: Function cancelled
Title: Re: Block Manager [Option 2]
Post by: nivuahc on March 03, 2010, 01:30:50 PM
This fixed it. Not sure how it affects DWG Library type blocks...

Code: [Select]
(defun c:BLOCK_PREVIEW_OnDblClicked (/ TmpEnt tmpScale)

;; Get the insertion scale
(if (null (setq tmpScale (getreal "\n Specify scale factor: <1>")))
(setq tmpScale 1)
)
;; Insert the selected block
(if (= SBM_LibType "Folder")
;; Insert the block
[color=red];(command ".-insert" (strcat SBM_Directory "\\" SBM_Library "\\" SBM_Block) "scale" tmpScale PAUSE PAUSE)[/color]
[color=blue](command ".-insert" (strcat SBM_Directory "\\" SBM_Library SBM_Block) "scale" tmpScale PAUSE PAUSE)[/color]
(progn
;; Import the block from the container
(BLOCK_ImportDbx (strcat SBM_Directory "\\" SBM_Library) SBM_Block)
;; Insert the block
(command ".-insert" SBM_Block "scale" tmpScale PAUSE PAUSE)
)
)
;; Get the block
(setq TmpEnt (entget(entlast)))
;; Change the layer
(setq TmpEnt (subst (cons 8 SBM_Layer)(assoc 8 TmpEnt) TmpEnt))
(entmod TmpEnt)
;; Send status
(princ (strcat "\n " SBM_Block " was inserted...."))
;; Silent Exit
(princ)
)
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on March 03, 2010, 01:33:59 PM
This fixed it. Not sure how it affects DWG Library type blocks...

Code: [Select]
(defun c:BLOCK_PREVIEW_OnDblClicked (/ TmpEnt tmpScale)

;; Get the insertion scale
(if (null (setq tmpScale (getreal "\n Specify scale factor: <1>")))
(setq tmpScale 1)
)
;; Insert the selected block
(if (= SBM_LibType "Folder")
;; Insert the block
[color=red];(command ".-insert" (strcat SBM_Directory "\\" SBM_Library "\\" SBM_Block) "scale" tmpScale PAUSE PAUSE)[/color]
[color=blue](command ".-insert" (strcat SBM_Directory "\\" SBM_Library SBM_Block) "scale" tmpScale PAUSE PAUSE)[/color]
(progn
;; Import the block from the container
(BLOCK_ImportDbx (strcat SBM_Directory "\\" SBM_Library) SBM_Block)
;; Insert the block
(command ".-insert" SBM_Block "scale" tmpScale PAUSE PAUSE)
)
)
;; Get the block
(setq TmpEnt (entget(entlast)))
;; Change the layer
(setq TmpEnt (subst (cons 8 SBM_Layer)(assoc 8 TmpEnt) TmpEnt))
(entmod TmpEnt)
;; Send status
(princ (strcat "\n " SBM_Block " was inserted...."))
;; Silent Exit
(princ)
)

Weird?  It has been working great since I started testing it a week ago.  Let me have another look at that.  As far as drawing blocks that code is right below the code that you modified.
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on March 03, 2010, 01:35:54 PM
James,

I do have one small issue with the dbx code.  It seems to leave the selected container drawing locked until autocad closes?  have you seen this?
Title: Re: Block Manager [Option 2]
Post by: jbuzbee on March 03, 2010, 01:39:24 PM
I'm out of the office and my laptop doesn't have ACAD so I can't look / test, but you are releasing the DBXDOC object?  This should be done as soon as possible in the code.  I'll have a look tonight at home - that is until Ghost Hunters comes on!

Title: Re: Block Manager [Option 2]
Post by: alanjt on March 03, 2010, 02:28:48 PM
Very nice Tim! Will have to test tomorrow.
Title: Re: Block Manager [Option 2]
Post by: Krushert on March 03, 2010, 03:16:50 PM
As for the Scale, I would suggest of adding a check box(s) the set to the scale to dimscale and/or cannoscale.
My 1/2 cent opinion.
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on March 03, 2010, 03:28:33 PM
This fixed it. Not sure how it affects DWG Library type blocks...

Code: [Select]
(defun c:BLOCK_PREVIEW_OnDblClicked (/ TmpEnt tmpScale)

;; Get the insertion scale
(if (null (setq tmpScale (getreal "\n Specify scale factor: <1>")))
(setq tmpScale 1)
)
;; Insert the selected block
(if (= SBM_LibType "Folder")
;; Insert the block
[color=red];(command ".-insert" (strcat SBM_Directory "\\" SBM_Library "\\" SBM_Block) "scale" tmpScale PAUSE PAUSE)[/color]
[color=blue](command ".-insert" (strcat SBM_Directory "\\" SBM_Library SBM_Block) "scale" tmpScale PAUSE PAUSE)[/color]
(progn
;; Import the block from the container
(BLOCK_ImportDbx (strcat SBM_Directory "\\" SBM_Library) SBM_Block)
;; Insert the block
(command ".-insert" SBM_Block "scale" tmpScale PAUSE PAUSE)
)
)
;; Get the block
(setq TmpEnt (entget(entlast)))
;; Change the layer
(setq TmpEnt (subst (cons 8 SBM_Layer)(assoc 8 TmpEnt) TmpEnt))
(entmod TmpEnt)
;; Send status
(princ (strcat "\n " SBM_Block " was inserted...."))
;; Silent Exit
(princ)
)

Chuck,

What is the actual block name that you are inserting?  Are you using folder or drawing library?

Title: Re: Block Manager [Option 2]
Post by: Crank on March 03, 2010, 03:29:09 PM
As for the Scale, I would suggest of adding a check box(s) the set to the scale to dimscale and/or cannoscale.
My 1/2 cent opinion.
If you want to use cannoscale, you have to make the block annotative and let Autocad handle the scaling.
I think the scale options should be the same as with normal toolpalettes.
Title: Re: Block Manager [Option 2]
Post by: nivuahc on March 03, 2010, 03:37:22 PM
Folder, and that happened no matter which block I chose. For the record, the one I posted above was named J-Box.dwg
Title: Re: Block Manager [Option 2]
Post by: Krushert on March 03, 2010, 03:51:45 PM
As for the Scale, I would suggest of adding a check box(s) the set to the scale to dimscale and/or cannoscale.
My 1/2 cent opinion.
If you want to use cannoscale, you have to make the block annotative and let Autocad handle the scaling.
I think the scale options should be the same as with normal toolpalettes.


Code: [Select]

(setq CANN0SCALE (getvar "cannoscalevalue"))
(setq ARCHVALUE (/ 1 CANN0SCALE)) ;start of Calculations

Returns
Quote
ARCHVALUE = 96.0
CANN0SCALE = 0.0104167
I have it inserting Dumb Blocks all day long? 
Am i using it wrong?
Title: Re: Block Manager [Option 2]
Post by: jbuzbee on March 03, 2010, 04:04:26 PM
Quote
I have it inserting Dumb Blocks all day long? 
Am i using it wrong?

No.  That's how I use it for like tags and stuff.  The new way is to let AutoCAD manage annotative blocks, scaling them when the annoscale changes.  I find this functionality limited for a number of reasons.  Besides, we use the Project Navigator in Architecture so all annotation goes into a View drawing which never changes scale.
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on March 03, 2010, 04:08:50 PM
Folder, and that happened no matter which block I chose. For the record, the one I posted above was named J-Box.dwg

From you example above, it seems to be adding extra \  between the library and the block?  I am not seeing that.  I will check through the code again.
Title: Re: Block Manager [Option 2]
Post by: Krushert on March 03, 2010, 04:15:58 PM
Quote
I have it inserting Dumb Blocks all day long? 
Am i using it wrong?

No.  That's how I use it for like tags and stuff.  The new way is to let AutoCAD manage annotative blocks, scaling them when the annoscale changes.  I find this functionality limited for a number of reasons.  Besides, we use the Project Navigator in Architecture so all annotation goes into a View drawing which never changes scale.
How so?  The annotative blocks or fixed scaled blocks?

I messed with annotative blocks when they first come out for a project and found them cumbersome.  I have only found two to four blocks in our library that could be annotative.  One of them desirable so but the others could go either way.
Title: Re: Block Manager [Option 2]
Post by: jbuzbee on March 03, 2010, 05:29:39 PM
Quote
I find this functionality limited for a number of reasons.

Quote
How so?  The annotative blocks or fixed scaled blocks?

Annotative Blocks.  When scaled there never in the right place - everything has to be moved / rearranged.  Very time consuming.  I use Fixed Scaled Blocks.
Title: Re: Block Manager [Option 2]
Post by: Crank on March 04, 2010, 07:01:58 AM
James, I think you should try this again. But this time with an alignment grip on the insertionpoint.
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on March 04, 2010, 08:24:29 AM
I'm out of the office and my laptop doesn't have ACAD so I can't look / test, but you are releasing the DBXDOC object?  This should be done as soon as possible in the code.  I'll have a look tonight at home - that is until Ghost Hunters comes on!



James,

I think this has something to do with the dcl_BlockView_DisplayDwg control.  When i am in the Folder lib and have explorer open as I select a block from the list it creates a .dwl and .dwl2 file and they remain until autocad closes.  They can not be deleted.  I imagine that if enough blocks were selected it would crash autocad?  Is there something that I am coding wrong?
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on March 04, 2010, 09:22:07 AM
James,
I just tested your last release again.  It seems to be doing the same thing.  It must be in the dcl_BlockView_DisplayDwg control issue?.  It creates 2 lock files and they don't get released until autocad closes.

Maybe it is a version thing.  I am using OpenDCL 5.1.2.3, ACA09, XP 32 SP3
Title: Re: Block Manager [Option 2]
Post by: jbuzbee on March 04, 2010, 09:51:01 AM
Just tested . . . interesting.  Heading over to OpenDCL.com to see what's up.  Will report back later.
Title: Re: Block Manager [Option 2]
Post by: Krushert on March 04, 2010, 12:53:24 PM
Quote
I find this functionality limited for a number of reasons.

Quote
How so?  The annotative blocks or fixed scaled blocks?

Annotative Blocks.  When scaled there never in the right place - everything has to be moved / rearranged.  Very time consuming.  I use Fixed Scaled Blocks.
My thoughts too.  Thanks
Title: Re: Block Manager [Option 2]
Post by: jbuzbee on March 04, 2010, 04:06:03 PM
OK, Owen is fixing the lock file issue in the next alpha build.
Title: Re: Block Manager [Option 2]
Post by: cadmonkey13 on June 23, 2010, 04:56:34 AM
Tim I have downloaded these files and placed them in my first support path.  When I load the BlockManager.lsp I get the following error:

BlockManager.lsp successfully loaded.
Command:
TheSwamp Block Manager v0.1 (BETA)©
 Timothy Spangler,
 February, 2010....loaded.
Type "SBM" to startOPENDCL Unknown command "OPENDCL".  Press F1 for help.
Command: ; error: no function definition: DCL_PROJECT_IMPORT

I have never run and OpenDCL file before so I don't know if I'm going about it all wrong.
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on June 23, 2010, 07:15:46 AM
you will need to go over to Opendcl.com (http://opendcl.com/wordpress/) download the latest runtime build and install it.  Then everything should work as expected.
Title: Re: Block Manager [Option 2]
Post by: cadmonkey13 on June 28, 2010, 10:05:53 AM
I got the block manager running but I have a problem.  I put the three files in the my first support path and the following line in my acaddoc.lsp:
(load "BlockManager" "BlockManager.lsp failed to load")

Now every time I open a new drawing the block manager appears.  How do I make it that it only appears on demand??
I tried modifying this part of the code to do that but it didn't work for me.

Code: [Select]
(defun C:SBM (/)

;; Load ActiveX COM
(vl-load-com)
;; Demand load OpenDCL
(command "OPENDCL")
(BLOCK_PROJECT)
;; Load the project
;(BLOCK_LOAD_PROJECT "BlockManager.odcl")
(dcl_project_import SBM_Project nil nil)
;; Start the project
(BLOCK_START)
)
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on June 28, 2010, 12:10:01 PM
CAD,

You will have to go to the end of the code

Code: [Select]
;;;
;;; ------------ COMMAND LINE LOAD SEQUENCE --------------------------------------------
(princ "\nTheSwamp Block Manager v0.1 (BETA)© \n Timothy Spangler, \n February, 2010....loaded.")
(print)
(princ "Type \"SBM\" to start")
(princ)
(C:SBM)   [color=red]<-----Comment out this line[/color]


I do have a newer version so I'll see if I can get it ready and post it.
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on August 05, 2010, 01:45:37 PM
^^^Moving on up^^^
 ^-^

Title: Re: Block Manager [Option 2]
Post by: cadmonkey13 on August 06, 2010, 04:23:49 AM
Tim,

I am getting an error when I run this.

Type "SBM" to start
 OPENDCL ; error: bad argument type: stringp nil
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on August 06, 2010, 08:23:54 AM
I assume that you have opendcl loaded?
Title: Re: Block Manager [Option 2]
Post by: cadmonkey13 on August 06, 2010, 09:10:59 AM
yeah Tim,  I had loaded it for the last version
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on August 06, 2010, 10:48:05 AM
Does the palette show at all?
Title: Re: Block Manager [Option 2]
Post by: cadmonkey13 on August 06, 2010, 10:55:05 AM
No Tim,

When I open a drawings after putting it in my LISP folder the dialog comes up asking me to pick a directory but then it gived the error below.
OPENDCL
Command: ; error: bad argument type: stringp nil
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on August 06, 2010, 12:24:56 PM
Paste these into the command line

Code: [Select]
(vl-registry-delete "HKEY_CURRENT_USER\\Software\\TheSwamp\\Block Manager")
(vl-registry-delete "HKEY_CURRENT_USER\\Software\\TheSwamp")

They should both return T.  Once this is done re-run the block manager.
Title: Re: Block Manager [Option 2]
Post by: cadmonkey13 on August 09, 2010, 04:34:37 AM
Great Tim,  that worked a treat.  I like the additions you've made to it.  I am going to get the guys in our place to use it as our block importer.

Thanks again.
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on August 09, 2010, 07:13:57 AM
Glad that worked.  There are still a few more little things to take care of before it is totally ready, but at this point it is very usable. (I've been using it since the beginning.)

I'll post up any changes.
Title: Re: Block Manager [Option 2]
Post by: Hugo on August 13, 2010, 01:57:49 PM
Hallo
Will this error

Befehl: (LOAD "C:/Users/Dober/Downloads/Lisp/BlockManager0.8/BlockManager.lsp")
TheSwamp Block Manager v0.8 (BETA)©
 Timothy Spangler,
 July, 2010....loaded.

 Type "SBM" to start
 OPENDCL
Befehl: ; Fehler: Fehler bei ADS-Anforderung
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on August 13, 2010, 02:05:16 PM
Did you run the last version?  If so then copy and paste the above code the the command line and re-run the program.  It needs to reset the registry keys in order to function.
Title: Re: Block Manager [Option 2]
Post by: Hugo on August 13, 2010, 02:15:36 PM
Hallo
Will this error



Befehl: (Vl-registry-delete "HKEY_CURRENT_USER \ \ Software \ \ TheSwamp \ \
Block Manager")
; Fehler: Unbekannter Stamm für Registrierungsschlüssel: "HKEY_CURRENT_USER   
Software   TheSwamp   Block Manager"
Title: Re: Block Manager [Option 2]
Post by: Hugo on August 13, 2010, 02:24:54 PM
Now get the following error

Title: Re: Block Manager [Option 2]
Post by: Hugo on August 13, 2010, 02:25:41 PM
And yet this
Title: Re: Block Manager [Option 2]
Post by: linuxsun on January 19, 2011, 05:48:20 AM
Hello, I have this error you have some solution
Bye
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on January 19, 2011, 07:43:55 AM
What version of OpenDCL do you have?
Title: Re: Block Manager [Option 2]
Post by: linuxsun on January 19, 2011, 11:17:51 AM
What version of OpenDCL do you have?

Hello, OpenDCL v. 5.1.2.3
Thanks again.
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on January 19, 2011, 12:35:28 PM
Let me check to be sure that dcl_Control_SetToolTipTitle was available then.  The last version that I have been using is 6.0.1.3.

BRB
Title: Re: Block Manager [Option 2]
Post by: TimSpangler on January 19, 2011, 12:43:38 PM
Have you run this before with out any errors?
Title: Re: Block Manager [Option 2]
Post by: linuxsun on January 21, 2011, 03:21:11 AM
Let me check to be sure that dcl_Control_SetToolTipTitle was available then.  The last version that I have been using is 6.0.1.3.

BRB

And before the time that I use OpenDCL v. 5.1.2.3 I have not tried the 6.0.1.3 version. Error could be caused from the language of autocad ITA and not ENG.
Thanks
Title: Re: Block Manager [Option 2]
Post by: Kerry on January 21, 2011, 04:45:47 AM

I'd recommend everyone use
Current Build [6.0.2.1]

http://www.opendcl.com/download/

Quote from: owenwengerd https://sourceforge.net/projects/opendcl/forums/forum/658811/topic/4051257
2011/01/13 : Release Candidate 1 is now available. I still want to do some detailed testing
and tweaking of control bar and palette forms in Bricscad, but otherwise RC1
is what I expect to be released as the finished OpenDCL 6.0.