Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Attaching DWS via VLISP?

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
790 Views, 10 Replies

Attaching DWS via VLISP?

Could someone give me an idea on how to attach a dws file to a drawing via
LISP - since Adesk didn't include a command line option...
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: Anonymous

"pkirill" wrote:
> Could someone give me an idea on how to attach a dws file to a drawing via
> LISP - since Adesk didn't include a command line option...

It seems you can with the code below, however, the "xref" isn't visible. It
shows up in the Xref dialog box, but it doesn't show up in the Insert Dialog
or in the graphics area. Very strange . . ..

jb

(defun c:jbAttachDWSFile( / file space PathName Name InsertionPoint XScale
YScale ZScale Rotation bOverlay)
(if (setq file(getfiled "\nSelect a Standards file to attach: " (getvar
"dwgprefix") "dws;dwg" 0))
(progn
(setq pathname file
name(vl-filename-base file)
InsertionPoint(getpoint "\nSelect Insertion Point: ")
Rotation(getAngle InsertionPoint "\nRotation: ")
XScale(getdist "\nX scale: "))
(if(not(setq Yscale(getdist (strcat "\nY scale: or " (rtos XScale)))))
(setq Yscale Xscale))

(if(not(setq Zscale(getdist (strcat "\nZ scale: or " (rtos XScale)))))
(setq Zscale Xscale))

(initget "Yes No")
(setq bOverlay(getkword "\nOverlay? - Yes or No ")

space(vla-get-modelspace(vla-get-activedocument(vlax-get-acad-object))))

(if (= bOverlay "Yes")(setq bOverlay :vlax-true)(setq bOverlay
:vlax-false))

(if (and space PathName Name InsertionPoint XScale YScale ZScale
Rotation bOverlay)
(vla-attachexternalreference space PathName Name
(vlax-3d-point InsertionPoint) XScale YScale ZScale Rotation
bOverlay)))

(princ "\nSee ya!"))
(princ))
Message 3 of 11
Anonymous
in reply to: Anonymous

I get "error: Automation Error. File access error"

I tried running an 'insert' style routine earlier and couldn't get it to
recognize a dws file.

Here's what I'm trying to do exactly:

When we send drawings to clients, we use a custom batch processor to bind
them and place them in a "to send" directory. One particular client is
'asking' that we convert our layer colors to match their pen tables. I need
to attach a DWS file to these bound drawings in order to batch convert layer
colors to meet their plotting standards. I was hoping to do it in a two
step batch conversion (one to attach and one to convert). But attaching the
DWS is a problem.

In the 2004 forum, Robert Bell had mentioned that the DWS was a dictionary.
But I have no idea how to attached or create that dictionary...






"James Buzbee" wrote in message
news:216680CF08CD567214143E2308C07782@in.WebX.maYIadrTaRb...
> "pkirill" wrote:
> > Could someone give me an idea on how to attach a dws file to a drawing
via
> > LISP - since Adesk didn't include a command line option...
>
> It seems you can with the code below, however, the "xref" isn't visible.
It
> shows up in the Xref dialog box, but it doesn't show up in the Insert
Dialog
> or in the graphics area. Very strange . . ..
>
> jb
>
> (defun c:jbAttachDWSFile( / file space PathName Name InsertionPoint XScale
> YScale ZScale Rotation bOverlay)
> (if (setq file(getfiled "\nSelect a Standards file to attach: " (getvar
> "dwgprefix") "dws;dwg" 0))
> (progn
> (setq pathname file
> name(vl-filename-base file)
> InsertionPoint(getpoint "\nSelect Insertion Point: ")
> Rotation(getAngle InsertionPoint "\nRotation: ")
> XScale(getdist "\nX scale: "))
> (if(not(setq Yscale(getdist (strcat "\nY scale: or " (rtos
XScale)))))
> (setq Yscale Xscale))
>
> (if(not(setq Zscale(getdist (strcat "\nZ scale: or " (rtos
XScale)))))
> (setq Zscale Xscale))
>
> (initget "Yes No")
> (setq bOverlay(getkword "\nOverlay? - Yes or No ")
>
> space(vla-get-modelspace(vla-get-activedocument(vlax-get-acad-object))))
>
> (if (= bOverlay "Yes")(setq bOverlay :vlax-true)(setq bOverlay
> :vlax-false))
>
> (if (and space PathName Name InsertionPoint XScale YScale ZScale
> Rotation bOverlay)
> (vla-attachexternalreference space PathName Name
> (vlax-3d-point InsertionPoint) XScale YScale ZScale Rotation
> bOverlay)))
>
> (princ "\nSee ya!"))
> (princ))
>
>
Message 4 of 11
Anonymous
in reply to: Anonymous

Here is a function to permit you to attach a DWS:

;;;Michael Puckett
(defun cdrs (key lst / pair rtn)
(while (setq pair (assoc key lst))
(setq rtn (cons (cdr pair) rtn)
lst (cdr (member pair lst))))
(reverse rtn))

;;;R. Robert Bell
(defun AddDWS (FileN / DictN eDict XRInt)
(setq DictN "AcStStandard"
eDict (cond ((cdr (assoc -1 (dictsearch (namedobjdict) DictN))))
((dictadd (namedobjdict)
DictN
(entmakex '((0 . "DICTIONARY") (100 .
"AcDbDictionary")))))))
(if (setq XRInt (cdrs 3 (entget eDict)))
(setq XRInt (1+ (apply 'max (mapcar 'atoi XRInt))))
(setq XRInt 0))
(dictadd eDict
(itoa XRInt)
(entmakex
(list '(0 . "XRECORD") '(100 . "AcDbXrecord") (cons 1 FileN)))))

Usage: (AddDWS "c:\\program files\\AutoCAD 2004\\Sample\\MKMStd.dws")


--
R. Robert Bell, MCSE
www.AcadX.com


"pkirill" wrote in message
news:F796FEEB7B7C3BA650921AB6E6A50A95@in.WebX.maYIadrTaRb...
| I get "error: Automation Error. File access error"
|
| I tried running an 'insert' style routine earlier and couldn't get it to
| recognize a dws file.
|
| Here's what I'm trying to do exactly:
|
| When we send drawings to clients, we use a custom batch processor to bind
| them and place them in a "to send" directory. One particular client is
| 'asking' that we convert our layer colors to match their pen tables. I
need
| to attach a DWS file to these bound drawings in order to batch convert
layer
| colors to meet their plotting standards. I was hoping to do it in a two
| step batch conversion (one to attach and one to convert). But attaching
the
| DWS is a problem.
|
| In the 2004 forum, Robert Bell had mentioned that the DWS was a
dictionary.
| But I have no idea how to attached or create that dictionary...
|
|
|
|
|
|
| "James Buzbee" wrote in message
| news:216680CF08CD567214143E2308C07782@in.WebX.maYIadrTaRb...
| > "pkirill" wrote:
| > > Could someone give me an idea on how to attach a dws file to a drawing
| via
| > > LISP - since Adesk didn't include a command line option...
| >
| > It seems you can with the code below, however, the "xref" isn't visible.
| It
| > shows up in the Xref dialog box, but it doesn't show up in the Insert
| Dialog
| > or in the graphics area. Very strange . . ..
| >
| > jb
| >
| > (defun c:jbAttachDWSFile( / file space PathName Name InsertionPoint
XScale
| > YScale ZScale Rotation bOverlay)
| > (if (setq file(getfiled "\nSelect a Standards file to attach: "
(getvar
| > "dwgprefix") "dws;dwg" 0))
| > (progn
| > (setq pathname file
| > name(vl-filename-base file)
| > InsertionPoint(getpoint "\nSelect Insertion Point: ")
| > Rotation(getAngle InsertionPoint "\nRotation: ")
| > XScale(getdist "\nX scale: "))
| > (if(not(setq Yscale(getdist (strcat "\nY scale: or " (rtos
| XScale)))))
| > (setq Yscale Xscale))
| >
| > (if(not(setq Zscale(getdist (strcat "\nZ scale: or " (rtos
| XScale)))))
| > (setq Zscale Xscale))
| >
| > (initget "Yes No")
| > (setq bOverlay(getkword "\nOverlay? - Yes or No ")
| >
| > space(vla-get-modelspace(vla-get-activedocument(vlax-get-acad-object))))
| >
| > (if (= bOverlay "Yes")(setq bOverlay :vlax-true)(setq bOverlay
| > :vlax-false))
| >
| > (if (and space PathName Name InsertionPoint XScale YScale ZScale
| > Rotation bOverlay)
| > (vla-attachexternalreference space PathName Name
| > (vlax-3d-point InsertionPoint) XScale YScale ZScale Rotation
| > bOverlay)))
| >
| > (princ "\nSee ya!"))
| > (princ))
| >
| >
|
|
Message 5 of 11
Anonymous
in reply to: Anonymous

Robert... Thank you... Works wonderfully!

Now see, I promised myself I wouldn't cry!


"R. Robert Bell" wrote in message
news:1001D3B2291065D14703B41E5D69B72C@in.WebX.maYIadrTaRb...
> Here is a function to permit you to attach a DWS:
>
> ;;;Michael Puckett
> (defun cdrs (key lst / pair rtn)
> (while (setq pair (assoc key lst))
> (setq rtn (cons (cdr pair) rtn)
> lst (cdr (member pair lst))))
> (reverse rtn))
>
> ;;;R. Robert Bell
> (defun AddDWS (FileN / DictN eDict XRInt)
> (setq DictN "AcStStandard"
> eDict (cond ((cdr (assoc -1 (dictsearch (namedobjdict) DictN))))
> ((dictadd (namedobjdict)
> DictN
> (entmakex '((0 . "DICTIONARY") (100 .
> "AcDbDictionary")))))))
> (if (setq XRInt (cdrs 3 (entget eDict)))
> (setq XRInt (1+ (apply 'max (mapcar 'atoi XRInt))))
> (setq XRInt 0))
> (dictadd eDict
> (itoa XRInt)
> (entmakex
> (list '(0 . "XRECORD") '(100 . "AcDbXrecord") (cons 1
FileN)))))
>
> Usage: (AddDWS "c:\\program files\\AutoCAD 2004\\Sample\\MKMStd.dws")
>
>
> --
> R. Robert Bell, MCSE
> www.AcadX.com
>
>
> "pkirill" wrote in message
> news:F796FEEB7B7C3BA650921AB6E6A50A95@in.WebX.maYIadrTaRb...
> | I get "error: Automation Error. File access error"
> |
> | I tried running an 'insert' style routine earlier and couldn't get it to
> | recognize a dws file.
> |
> | Here's what I'm trying to do exactly:
> |
> | When we send drawings to clients, we use a custom batch processor to
bind
> | them and place them in a "to send" directory. One particular client is
> | 'asking' that we convert our layer colors to match their pen tables. I
> need
> | to attach a DWS file to these bound drawings in order to batch convert
> layer
> | colors to meet their plotting standards. I was hoping to do it in a two
> | step batch conversion (one to attach and one to convert). But attaching
> the
> | DWS is a problem.
> |
> | In the 2004 forum, Robert Bell had mentioned that the DWS was a
> dictionary.
> | But I have no idea how to attached or create that dictionary...
> |
> |
> |
> |
> |
> |
> | "James Buzbee" wrote in message
> | news:216680CF08CD567214143E2308C07782@in.WebX.maYIadrTaRb...
> | > "pkirill" wrote:
> | > > Could someone give me an idea on how to attach a dws file to a
drawing
> | via
> | > > LISP - since Adesk didn't include a command line option...
> | >
> | > It seems you can with the code below, however, the "xref" isn't
visible.
> | It
> | > shows up in the Xref dialog box, but it doesn't show up in the Insert
> | Dialog
> | > or in the graphics area. Very strange . . ..
> | >
> | > jb
> | >
> | > (defun c:jbAttachDWSFile( / file space PathName Name InsertionPoint
> XScale
> | > YScale ZScale Rotation bOverlay)
> | > (if (setq file(getfiled "\nSelect a Standards file to attach: "
> (getvar
> | > "dwgprefix") "dws;dwg" 0))
> | > (progn
> | > (setq pathname file
> | > name(vl-filename-base file)
> | > InsertionPoint(getpoint "\nSelect Insertion Point: ")
> | > Rotation(getAngle InsertionPoint "\nRotation: ")
> | > XScale(getdist "\nX scale: "))
> | > (if(not(setq Yscale(getdist (strcat "\nY scale: or " (rtos
> | XScale)))))
> | > (setq Yscale Xscale))
> | >
> | > (if(not(setq Zscale(getdist (strcat "\nZ scale: or " (rtos
> | XScale)))))
> | > (setq Zscale Xscale))
> | >
> | > (initget "Yes No")
> | > (setq bOverlay(getkword "\nOverlay? - Yes or No ")
> | >
> | >
space(vla-get-modelspace(vla-get-activedocument(vlax-get-acad-object))))
> | >
> | > (if (= bOverlay "Yes")(setq bOverlay :vlax-true)(setq bOverlay
> | > :vlax-false))
> | >
> | > (if (and space PathName Name InsertionPoint XScale YScale ZScale
> | > Rotation bOverlay)
> | > (vla-attachexternalreference space PathName Name
> | > (vlax-3d-point InsertionPoint) XScale YScale ZScale Rotation
> | > bOverlay)))
> | >
> | > (princ "\nSee ya!"))
> | > (princ))
> | >
> | >
> |
> |
>
>
Message 6 of 11
Anonymous
in reply to: Anonymous

Happy to help... you reach little child inside of you! 😉

--
R. Robert Bell, MCSE
www.AcadX.com


"pkirill" wrote in message
news:503980B324A97BC0AF2CD637A70DF82D@in.WebX.maYIadrTaRb...
| Robert... Thank you... Works wonderfully!
|
| Now see, I promised myself I wouldn't cry!
|
|
Message 7 of 11
Anonymous
in reply to: Anonymous

When I try this lisp, it gets hung up in a loop and loads the DWS file numerous times until I escape? I am using Acad 2k6.

Thanks for any help.
Message 8 of 11
Anonymous
in reply to: Anonymous

How about posting the lsp?
Message 9 of 11
Anonymous
in reply to: Anonymous

It's the same lisp for Robert Bell posted above except with the DWS file location changed.

;;;Michael Puckett
(defun cdrs (key lst / pair rtn)
(while (setq pair (assoc key lst))
(setq rtn (cons (cdr pair) rtn)
lst (cdr (member pair lst))))
(reverse rtn))


(defun AddDWS (FileN / DictN eDict XRInt)
(setq DictN "AcStStandard"
eDict (cond ((cdr (assoc -1 (dictsearch (namedobjdict) DictN))))
((dictadd (namedobjdict)
DictN
(entmakex '((0 . "DICTIONARY") (100 .
"AcDbDictionary")))))))
(if (setq XRInt (cdrs 3 (entget eDict)))
(setq XRInt (1+ (apply 'max (mapcar 'atoi XRInt))))
(setq XRInt 0))
(dictadd eDict
(itoa XRInt)
(entmakex
(list '(0 . "XRECORD") '(100 . "AcDbXrecord") (cons 1 FileN)))))

Usage: (AddDWS "C:\\lbi.dws")
Message 10 of 11
dreno99
in reply to: Anonymous

The routine is just what I want to be able to apply a dws to several hundred files using a script. but when I test it, I get this:

 

Command:
Command: (AddDWS "S:\DIES\~Standard Dies\dies.dws")
<Entity name: 7ffff7aadb0>

 

any clue on what I am doing wrong? using AutoCAD 2013 here.

Message 11 of 11
randyspear6624
in reply to: Anonymous

Is there anyway to specify which plugins to apply as well?

I have a dws loading using similar lisp but I only want the text styles plugin to be checked.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost