Author Topic: dwg tools  (Read 7117 times)

0 Members and 1 Guest are viewing this topic.

Notsober

  • Guest
Re: dwg tools
« Reply #15 on: December 01, 2008, 11:26:24 AM »
Deeg, still willing to help me out?

I barely have time to read this as it is, sorry unsober one. I'll chime in when/if I can.

no big hurry man... noticed the original post date? LoL

deegeecees

  • Guest
Re: dwg tools
« Reply #16 on: December 01, 2008, 12:12:25 PM »
I just modified my earlier posted routine, by changing the block name. It works as you spec'ed, but it also checks for multiple instances of the block, and checks for standard scaling as well. That functionality was already there so what the heck, keep it (unless it's something you'd rather not utilize).

Code: [Select]
;dwgtools.lsp
;Created for Notsober. by P.R.Donnelly
;Date: Nov. of 2008
;Description: Inserts the drawing tools
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;start prog

(defun isatter ()
(SETQ isatt1 (SSGET "X" '((2 . "eka-22x34-Border"))))
(if isatt1
(progn
(setq qtyisatt1 (sslength isatt1))
(if (= 1 qtyisatt1)
(setq gtg 1)
(progn
(setq err_line (strcat "There are multiple instances of eka-22x34-Border please select the one to keep"))
(alert err_line)
(command "erase" isatt1 "r" pause pause)
)
)
)
)
)

(defun getinfo ();(/ tester1 fixer1 ats3)
(setq tester1 (SSGET "X" (LIST (CONS 0 "insert") (CONS 2 "eka-22x34-Border"))))
(if tester1
(progn
(SETQ fixer1 (ssname tester1 0))
(SETQ ats3 (ENTGET fixer1))
(if ats3
(progn
(setq atstd1(cdr (assoc 41 ats3)))
(setq wutscale (rtos atstd1))
(setq atstd2
(cond
((= atstd1 1.0) "0.09375")
((= atstd1 4.0) "0.375")
((= atstd1 6.0) "0.5625")
((= atstd1 8.0) "0.75")
((= atstd1 12.0) "1.125")
((= atstd1 16.0) "1.5")
((= atstd1 24.0) "2.25")
((= atstd1 32.0) "3.0")
((= atstd1 48.0) "4.5")
((= atstd1 64.0) "6.0")
((= atstd1 96.0) "9.0")
((= atstd1 128.0) "12.0")
((= atstd1 192.0) "18.0")
((= atstd1 384.0) "36.0")
((= atstd1 120.0) "11.25")
((= atstd1 240.0) "22.5")
((= atstd1 360.0) "33.75")
((= atstd1 480.0) "45.0")
((= atstd1 600.0) "56.25")
((= atstd1 720.0) "67.5")
((= atstd1 1200.0) "112.5")
((= atstd1 2400.0) "225.0")
((= atstd1 3600.0) "337.5")
((= atstd1 12000.0) "1125.0")
((= atstd1 24000.0) "2250.0")
)
)

)
)
)
(alert "\n***No Block Data Found - Insert eka-22x34-Border at a standard scale and try again***")
)
(princ)
);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;end getinfo



(defun c:dwgtools ()
(setq ins_pnt01 (getpoint "\nSelect Insertion Point"))
(isatter)
(getinfo)
(if (= atstd2 nil)
(progn
(if wutscale
(progn
(setq alertxt (strcat "*eka-22x34-Border* border scale is set at " wutscale " and is not consistent with drafting standards"))
(alert alertxt)
)
)
)
)

(if (/= atstd2 nil)
(progn
(command "-insert" "*dwg_tools" ins_pnt01 atstd1 "" "")
(setq atstd2 nil)
(princ)
));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;if progn for atstd2
)
(princ)

Happy Holidays!

hmspe

  • Bull Frog
  • Posts: 362
Re: dwg tools
« Reply #17 on: December 01, 2008, 01:14:46 PM »
I want the code to first get the scale of the dwg, wait for me to pick insertion point, rotation angle is always 0, and lastly explode the block.

this is how i'm accomplishing it now under the INSERT menu pulldown:
Quote
ID_InsTools    [DWG Tools]^C^C-insert;dwg_tools;s;\;  ex;;

but it's still not exploding the block like I want it to.

I do all my standard symbols from toolbars.  Here's a sample:

Code: [Select]
(defun C:insert_240v-1ph-200a ()
  (setvar "cmdecho" 0)
  (setpower)
  (setq ds (getvar "dimscale"))
  (prompt "\nSelect insertion point...  ")
  (command "_insert" "E_240v-1ph-200a" "PS" ds pause ds ds 0)
  (command "_explode" "_last")
  (PRINC)
)

(setpower) is a function that sets the active layer to "POWER".  My drawings are all model space, scaled as appropriate, so my blocks are scaled based on dimscale.       

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

Notsober

  • Guest
Re: dwg tools
« Reply #18 on: December 01, 2008, 02:05:52 PM »
I just modified my earlier posted routine, by changing the block name. It works as you spec'ed, but it also checks for multiple instances of the block, and checks for standard scaling as well. That functionality was already there so what the heck, keep it (unless it's something you'd rather not utilize).

Code: [Select]
;dwgtools.lsp
;Created for Notsober. by P.R.Donnelly
;Date: Nov. of 2008
;Description: Inserts the drawing tools
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;start prog

(defun isatter ()
(SETQ isatt1 (SSGET "X" '((2 . "eka-22x34-Border"))))
(if isatt1
(progn
(setq qtyisatt1 (sslength isatt1))
(if (= 1 qtyisatt1)
(setq gtg 1)
(progn
(setq err_line (strcat "There are multiple instances of eka-22x34-Border please select the one to keep"))
(alert err_line)
(command "erase" isatt1 "r" pause pause)
)
)
)
)
)

(defun getinfo ();(/ tester1 fixer1 ats3)
(setq tester1 (SSGET "X" (LIST (CONS 0 "insert") (CONS 2 "eka-22x34-Border"))))
(if tester1
(progn
(SETQ fixer1 (ssname tester1 0))
(SETQ ats3 (ENTGET fixer1))
(if ats3
(progn
(setq atstd1(cdr (assoc 41 ats3)))
(setq wutscale (rtos atstd1))
(setq atstd2
(cond
((= atstd1 1.0) "0.09375")
((= atstd1 4.0) "0.375")
((= atstd1 6.0) "0.5625")
((= atstd1 8.0) "0.75")
((= atstd1 12.0) "1.125")
((= atstd1 16.0) "1.5")
((= atstd1 24.0) "2.25")
((= atstd1 32.0) "3.0")
((= atstd1 48.0) "4.5")
((= atstd1 64.0) "6.0")
((= atstd1 96.0) "9.0")
((= atstd1 128.0) "12.0")
((= atstd1 192.0) "18.0")
((= atstd1 384.0) "36.0")
((= atstd1 120.0) "11.25")
((= atstd1 240.0) "22.5")
((= atstd1 360.0) "33.75")
((= atstd1 480.0) "45.0")
((= atstd1 600.0) "56.25")
((= atstd1 720.0) "67.5")
((= atstd1 1200.0) "112.5")
((= atstd1 2400.0) "225.0")
((= atstd1 3600.0) "337.5")
((= atstd1 12000.0) "1125.0")
((= atstd1 24000.0) "2250.0")
)
)

)
)
)
(alert "\n***No Block Data Found - Insert eka-22x34-Border at a standard scale and try again***")
)
(princ)
);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;end getinfo



(defun c:dwgtools ()
(setq ins_pnt01 (getpoint "\nSelect Insertion Point"))
(isatter)
(getinfo)
(if (= atstd2 nil)
(progn
(if wutscale
(progn
(setq alertxt (strcat "*eka-22x34-Border* border scale is set at " wutscale " and is not consistent with drafting standards"))
(alert alertxt)
)
)
)
)

(if (/= atstd2 nil)
(progn
(command "-insert" "*dwg_tools" ins_pnt01 atstd1 "" "")
(setq atstd2 nil)
(princ)
));;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;if progn for atstd2
)
(princ)

Happy Holidays!

cool dude. everything looks good (haven't tested it yet) but just glancing thru it I noticed "eka-22x34-Border"

that was just a sample border that I used for an example of where I place the "tools" (maybe i should start calling it "section marks and other miscellaneous blocks that I use all the time"?)

I use these "tools" on just about on every dwg that gets opened on my machine.... do I just delete that, or do ya have to tweak it a little more to make it work on just the active drawing?
« Last Edit: December 01, 2008, 02:10:40 PM by Notsober »

deegeecees

  • Guest
Re: dwg tools
« Reply #19 on: December 01, 2008, 03:04:14 PM »
Yes, it would have to be tweaked since it bases the scaling off of the eka-22x34-Border block. I'd need a list of all possible titleblocks to look for to make this functional, plus it would make more sense to put the getpoint statement right before the insert line (I was rushing it).

deegeecees

  • Guest
Re: dwg tools
« Reply #20 on: December 01, 2008, 03:44:02 PM »
I was thinking that to simplify this, one could select the block to scale off of, so it could work on any drawing regardless of the titleblocks name.

Notsober

  • Guest
Re: dwg tools
« Reply #21 on: December 02, 2008, 10:22:48 AM »
I was thinking that to simplify this, one could select the block to scale off of, so it could work on any drawing regardless of the titleblocks name.

yes. exactly.



we draw everything in modelspace, so if the scale factor was not physically visible just yet, I type in LI for LIST to get the block's scale factor.

We always use a 34x22 sized border at 1:1 (SF=1), and scale it up from there. So, basically the limits would be set to 2'-10" x 1'-10" at 1:1. At 1"=1'-0" (SF=12) the limits are 34'-0" x 22'-0".

The routine wouldn't necessarily need to automatically pick the insertion point, just get scale, I'll pick the insertion point, insert at proper scale, then explode.

deegeecees

  • Guest
Re: dwg tools
« Reply #22 on: December 02, 2008, 11:16:09 AM »
Quick and dirty, will fail if no block is selected:

Code: [Select]
;dwgtools.lsp
;Created for Notsober. by P.R.Donnelly
;Date: Nov. of 2008
;Description: Inserts the drawing tools
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;start prog

(defun c:dwgtools ()
(setq en1 (entsel"\nSelect BLOCK for scaling: "))
(setq en2 (entget (car en1)))
(setq scl1 (cdr (assoc 42 en2)))
(setq ins_pnt01 (getpoint "\nSelect Insertion Point"))
(command "-insert" "*dwg_tools" ins_pnt01 scl1 "" "")
(princ)
)

Notsober

  • Guest
Re: dwg tools
« Reply #23 on: December 04, 2008, 02:38:20 PM »
awesome job man... but there are instances sometimes where the title block isn't a "block" at all...

how do you put an option in there to maybe choose my own scale if there isn't a block to get scale from?


maybe something like: Select BLOCK for scaling, or enter scale factor <12>:

(the <12> being an example of the last SF used if I pressed enter, or something like that...) just trying to make it somewhat error proof.

deegeecees

  • Guest
Re: dwg tools
« Reply #24 on: December 04, 2008, 02:39:33 PM »
That's doable, just need a break in the action here. I'll post a solution soon...

Notsober

  • Guest
Re: dwg tools
« Reply #25 on: December 04, 2008, 02:41:08 PM »
coolness...

Notsober

  • Guest
Re: dwg tools
« Reply #26 on: December 04, 2008, 05:38:03 PM »
uh oh, i just noticed this...
Quote
Command: dwgtools

Select BLOCK for scaling:
Select Insertion Point-insert Enter block name or [?]: *dwg_tools Specify
insertion point for block: Specify scale factor for XYZ axes: 16.00000000000000
Specify rotation angle <0.00>: Duplicate definition of block REVTRI  ignored.
Duplicate definition of block Detail_Header  ignored.
Duplicate definition of block Section_Header  ignored.
Duplicate definition of block Construction_Stamp  ignored.

Command: DWGTOOLS Unknown command "DWGTOOLS".  Press F1 for help.

deegeecees

  • Guest
Re: dwg tools
« Reply #27 on: December 05, 2008, 12:18:04 PM »
Try a purge before using that.

Notsober

  • Guest
Re: dwg tools
« Reply #28 on: December 05, 2008, 12:36:07 PM »
i already thought of that... it still does it. No matter what drawing I'm in...


but in A2004, this is what happens -
Quote
Command: purge

Command: dwgtools

Select BLOCK for scaling:
Select Insertion Point-insert Enter block name or [?]: *dwg_tools Specify
insertion point for block: Specify scale factor for XYZ axes: 16.00000000000000
Specify rotation angle <0.00>: Duplicate definition of block REVTRI  ignored.
Duplicate definition of block Detail_Header  ignored.
Duplicate definition of block Section_Header  ignored.
Duplicate definition of block Construction_Stamp  ignored.
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)

Command: DWGTOOLS Unknown command "DWGTOOLS".  Press F1 for help.

Notsober

  • Guest
Re: dwg tools
« Reply #29 on: December 05, 2008, 12:38:52 PM »
i have to add... it actually places my dwg tools in A2007, but not in 2004