Jump to content

Lisp to insert block but I have a rotation problem


woodman78

Recommended Posts

Hi all,

 

I have a lisp to insert blocks into a drawing. The first block is inserted correctly but the second one is given a rotation of 1. I know it is to do with the insert command but I can't figure out the problem.

 

 

(defun c:LegendBatch (/ laylist SUCE SUOM SUSM SUAB SUAD SUCL SUCR)
 
(setq SUCE (getvar "cmdecho"))
(setq SUOM (getvar "orthomode"))
(setq SUSM (getvar "osmode"))
(setq SUAB (getvar "angbase"))
(setq SUAD (getvar "angdir"))
(setq SUCL (getvar "clayer"))
(setq SUCR (getvar "cecolor"))

 (command "_.-layer" "_M" "CCC_SHEET_LAYOUT_Legend" "_C" "7" "CCC_SHEET_LAYOUT_Legend" "_LW" "0.3" "CCC_SHEET_LAYOUT_Legend" "" )

 (command "_-color"  "bylayer")

(setq laylist '(
("CCC_SERVICES_Existing_Council_Ducting" "Existing_Council_Ducting")
("CCC_SERVICES_Existing_Council_Ducting_Plant_Chamber" "Existing_Council_Ducting_Chamber_Legend")
)
)
(foreach l laylist
(if (and (tblsearch "LAYER" (car l))
          (setq n (findfile (strcat (cadr l) ".dwg")))
     )
   (command "_.-INSERT" n "\\" "1" "1" "0")
 )
)
 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "clayer"    SUCL)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (setvar "cecolor"    SUCR)
(princ))

 

The command line spits this out after running the command:

 

Command: LegendBatch _.-layer
Current layer:  "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _M
Enter name for new layer (becomes the current layer) <0>: CCC_SHEET_LAYOUT_Legend Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _C
New color [Truecolor/COlorbook] : 7
Enter name list of layer(s) for color 7 (white) <CCC_SHEET_LAYOUT_Legend>: CCC_SHEET_LAYOUT_Legend Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _LW
Enter lineweight (0.0mm - 2.11mm): 0.3
Enter name list of layers(s) for lineweight 0.30mm <CCC_SHEET_LAYOUT_Legend>: CCC_SHEET_LAYOUT_Legend Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command: _-color
Enter default object color [Truecolor/COlorbook] <BYLAYER>: bylayer
Command: _.-INSERT Enter block name or [?] <Existing_Council_Ducting_Chamber_Legend>: T:\drawing tools\autocad 2010_warning_do not modify\Existing_Council_Ducting.dwg
Units: Meters   Conversion: 1.00000000
Specify insertion point or [basepoint/Scale/X/Y/Z/Rotate]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: 1 Enter Y scale factor <use X scale factor>: 1
Specify rotation angle <0>: 0
Command: _.-INSERT Enter block name or [?] <Existing_Council_Ducting>: T:\drawing tools\autocad 2010_warning_do not modify\Existing_Council_Ducting_Chamber_Legend.dwg
Units: Meters   Conversion: 1.00000000
Specify insertion point or [basepoint/Scale/Rotate]: Specify scale factor <1>: 1
Specify rotation angle <0>: 1
Command: 0 Unknown command "0".  Press F1 for help.

Command:

 

block rotate.jpg

 

I would appreciate it if anyone could offer a solution to the rotation problem.

 

Thanks.

Woodman78

Link to comment
Share on other sites

Yeah Jman but the first block inserts at a rotation of 0 and they are both inserted by the same routine.

Link to comment
Share on other sites

Change:

(command "_.-INSERT" n "\\" "1" "1" "0")

to:

(command "_.-INSERT" n "_s" "1" "_r" "0" "\\")

 

The X & Y scale prompts will differ depending on whether the block definition permits non-uniform scaling.

Link to comment
Share on other sites

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