TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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!
-
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.
-
Tim,
Looks fantastic!
One minor problem:
Specify scale factor: <1>
.-insert Enter block name or [?]: S:\ACAD\Blocks\\J-Box.dwg
Invalid block name.
; error: Function cancelled
-
This fixed it. Not sure how it affects DWG Library type blocks...
(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)
)
-
This fixed it. Not sure how it affects DWG Library type blocks...
(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.
-
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?
-
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!
-
Very nice Tim! Will have to test tomorrow.
-
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.
-
This fixed it. Not sure how it affects DWG Library type blocks...
(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?
-
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.
-
Folder, and that happened no matter which block I chose. For the record, the one I posted above was named J-Box.dwg
-
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.
(setq CANN0SCALE (getvar "cannoscalevalue"))
(setq ARCHVALUE (/ 1 CANN0SCALE)) ;start of Calculations
Returns
ARCHVALUE = 96.0
CANN0SCALE = 0.0104167
I have it inserting Dumb Blocks all day long?
Am i using it wrong?
-
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.
-
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.
-
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.
-
I find this functionality limited for a number of reasons.
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.
-
James, I think you should try this again. But this time with an alignment grip on the insertionpoint.
-
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?
-
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
-
Just tested . . . interesting. Heading over to OpenDCL.com to see what's up. Will report back later.
-
I find this functionality limited for a number of reasons.
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
-
OK, Owen is fixing the lock file issue in the next alpha build.
-
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.
-
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.
-
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.
(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)
)
-
CAD,
You will have to go to the end of the code
;;;
;;; ------------ 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.
-
^^^Moving on up^^^
^-^
-
Tim,
I am getting an error when I run this.
Type "SBM" to start
OPENDCL ; error: bad argument type: stringp nil
-
I assume that you have opendcl loaded?
-
yeah Tim, I had loaded it for the last version
-
Does the palette show at all?
-
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
-
Paste these into the command line
(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.
-
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.
-
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.
-
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
-
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.
-
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"
-
Now get the following error
-
And yet this
-
Hello, I have this error you have some solution
Bye
-
What version of OpenDCL do you have?
-
What version of OpenDCL do you have?
Hello, OpenDCL v. 5.1.2.3
Thanks again.
-
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
-
Have you run this before with out any errors?
-
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
-
I'd recommend everyone use
Current Build [6.0.2.1]
http://www.opendcl.com/download/
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.