Author Topic: Can't figure out how to pass individual Block into Lee Mac's STEAL Script  (Read 1475 times)

0 Members and 1 Guest are viewing this topic.

encepta

  • Mosquito
  • Posts: 13
This code works with Lee Macs Steal.lsp script.

Code: [Select]
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    ("MECHCP16")
                                )
                            )
                        )


However I want to pass in the ("MECHCP16") using a variable:

Code: [Select]
                        (setq BlockName "MECHCP12")
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    (BlockName)
                                )
                            )
                        )

This gives me: Error: bad argument type: stringp BLOCKNAME

I read into Steal.lsp and it required a List for input, so I did this:
Code: [Select]
                        (setq BlockName (list "MECHCP12"))
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    (BlockName)
                                )
                            )
                        )

It gives me this error: Error: bad argument type: stringp BLOCKNAME

Any idea how I can get this working? Any suggestions are welcome.

Thank you.


danAllen

  • Newt
  • Posts: 134
Haven't tested, but remove parenthesis from (BlockName) to be just BlockName. When in parenthesis then lisp is calling a subroutine with that name, rather than using variable data.

dexus

  • Bull Frog
  • Posts: 217
This code works with Lee Macs Steal.lsp script.

Code: [Select]
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    ("MECHCP16")
                                )
                            )
                        )


However I want to pass in the ("MECHCP16") using a variable:

Code: [Select]
                        (setq BlockName "MECHCP12")
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    (BlockName)
                                )
                            )
                        )

This gives me: Error: bad argument type: stringp BLOCKNAME

I read into Steal.lsp and it required a List for input, so I did this:
Code: [Select]
                        (setq BlockName (list "MECHCP12"))
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    (BlockName)
                                )
                            )
                        )

It gives me this error: Error: bad argument type: stringp BLOCKNAME

Any idea how I can get this working? Any suggestions are welcome.

Thank you.
In your second example BlockName is not read as a variable because of the quote.
You can read more here to understand what is happening: http://www.lee-mac.com/quote.html

Something like this should work:
Code - Auto/Visual Lisp: [Select]
  1.   (setq BlockName "MECHCP12")
  2.   (Steal "C:\\DWG_WITH_BLOCKS.dwg"
  3.     (list
  4.       (list
  5.         "Blocks"
  6.         (list BlockName)
  7.       )
  8.     )
  9.   )

encepta

  • Mosquito
  • Posts: 13
Haven't tested, but remove parenthesis from (BlockName) to be just BlockName. When in parenthesis then lisp is calling a subroutine with that name, rather than using variable data.

I've tried that already, gives the following error: when BlockName is defined as a string and/or a list.

Error: bad argument type: listp BLOCKNAME

encepta

  • Mosquito
  • Posts: 13
This code works with Lee Macs Steal.lsp script.

Code: [Select]
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    ("MECHCP16")
                                )
                            )
                        )


However I want to pass in the ("MECHCP16") using a variable:

Code: [Select]
                        (setq BlockName "MECHCP12")
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    (BlockName)
                                )
                            )
                        )

This gives me: Error: bad argument type: stringp BLOCKNAME

I read into Steal.lsp and it required a List for input, so I did this:
Code: [Select]
                        (setq BlockName (list "MECHCP12"))
                        (Steal "C:\\DWG_WITH_BLOCKS.dwg"
                           '(
                                (
                                    "Blocks"
                                    (BlockName)
                                )
                            )
                        )

It gives me this error: Error: bad argument type: stringp BLOCKNAME

Any idea how I can get this working? Any suggestions are welcome.

Thank you.
In your second example BlockName is not read as a variable because of the quote.
You can read more here to understand what is happening: http://www.lee-mac.com/quote.html

Something like this should work:
Code - Auto/Visual Lisp: [Select]
  1.   (setq BlockName "MECHCP12")
  2.   (Steal "C:\\DWG_WITH_BLOCKS.dwg"
  3.     (list
  4.       (list
  5.         "Blocks"
  6.         (list BlockName)
  7.       )
  8.     )
  9.   )

Thank you! This worked. Although it's much slower computationally than I thought it would... For each point in the DWG, I grab its blockname (from an attribute), steal the block from the respective external DWG, and replace the point with its block.