Jump to content

script problem: blank space in file path


lacciap

Recommended Posts

Hi to everyone,

 

this is my first post on the forum and I want to thanks to all of you will have patience to read my post.

 

I have a problem with the blank space in some filepaths of my script.

something like

 

C:\Documents and settings\test.txt

 

in a script line. AutoCAD consider the first blank space like an enter and of course it doesn't know the 'AND' command. :)

and my script doesn't work.

 

I know the most easy answer would be 'change your path in a different one without blank spaces!' but unfortunately I can't.

 

I don't know how to solve this problem. I heard AutoLISP is a stronger tool to use for that scope but I don't know anything about LISP. So I'll appreciate all of your tips and your help.

Thanks.

Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • lacciap

    11

  • Lee Mac

    8

  • irneb

    7

  • fixo

    3

Top Posters In This Topic

for those without access to the link: just use "quotes"

 

"C:\Documents and settings\test.txt"

instead of

C:\Documents and settings\test.txt

Link to comment
Share on other sites

Thank you very much Lee Mac!

I didn't think it could be so easy and thanks for your quick answer! :)

 

You're welcome, I thought it would give a more complete answer, and maybe answer any other questions you might have :)

Link to comment
Share on other sites

thanks designerstuart and thanks for your help guys!

I like this forum and I hope to be useful to someone in the future.

 

Maybe when I'll a little bit more skilled! :)

Link to comment
Share on other sites

Hi everyone,

 

maybe I should open a new thread but since this is the second step of my project after running script files in AutoCAD I write here.

 

I'd like to create a batch application (I use C#) that launch AutoCAD, minimize the AutoCAD window and execute the script file. I found ScriptPro (thanks alanjt!) with its source code and I saw it uses reflection to open and manage AutoCAD, but I don't find the way to minimize AutoCAD window in its code.

Did anybody of you make something similar in your experiences, maybe without reflection?

Thanks again.

Link to comment
Share on other sites

Hi everyone,

 

maybe I should open a new thread but since this is the second step of my project after running script files in AutoCAD I write here.

 

I'd like to create a batch application (I use C#) that launch AutoCAD, minimize the AutoCAD window and execute the script file. I found ScriptPro (thanks alanjt!) with its source code and I saw it uses reflection to open and manage AutoCAD, but I don't find the way to minimize AutoCAD window in its code.

Did anybody of you make something similar in your experiences, maybe without reflection?

Thanks again.

You might want to look at this page:

https://sites.google.com/site/bushmansnetlaboratory/lab/pof

(but the explantion is on Russian only - use web translator)

Link to comment
Share on other sites

Hi Fixo,

 

I checked your link but I have couple of problems,

 

I don't understand why but I can't find the Autodesk.AutoCAD.Interop class in my acmgd.dll file. I don't know why, maybe my dll file is corrupted? I use AutoCAD 2008.

 

I can't open your solution because I use VS2008. Do you know a way to convert the project from 2010 to 2008?

 

Many thanks again.

Link to comment
Share on other sites

Hi Fixo,

 

I checked your link but I have couple of problems,

 

I don't understand why but I can't find the Autodesk.AutoCAD.Interop class in my acmgd.dll file. I don't know why, maybe my dll file is corrupted? I use AutoCAD 2008.

 

I can't open your solution because I use VS2008. Do you know a way to convert the project from 2010 to 2008?

 

Many thanks again.

You need to add reference to acmgdinternal.dll as well

(don't forget to set 'Copy Local' to false for libraries)

 

~'J'~

Link to comment
Share on other sites

Hi fixo,

 

I found and add the reference of acmgdinternal.dll but I still can find the namespace Autodesk.AutoCAD.Interop. thought it is in acmgd.dll but I don't know why it isn't in mine. Looking at the VS Object Browser I can't see any Autodesk.AutoCAD.Interop namespace in my autocad dlls.

Do you have any ideas about that?

 

thanks.

Link to comment
Share on other sites

Hi guys,

it's still me with a problem to solve.

 

is it possible to make a script that select a single block from a dwg where there are 2 different block and edit its attributes?

in ex.: I have blocks.dwg where there are block1 and block2. I'd like to generate newsheet.dwg with only block1 inside.

 

I've tried with insert command selecting blocks.dwg but it comes with both of block1 and block2.

 

Any ideas will be appreciated. :)

Thanks!

Link to comment
Share on other sites

I just want to be clear on this: You've modified ScriptPro's source in C# to run your scripts the way you want them, unclear why you don't use ScriptPro as is, or even better AutoScript? In which case why don't you use the DotNet to extract the block from the Blocks.DWG file in question?

 

Anyhow, if you want a SCR file to do such, the "simplest" way would be to have it insert the Blocks.DWG file. Then explode last. Then use some lisp direct in the SCR to select previous (ssget "P") then step through that in a loop, get the DXF data of each thing (ssname & entget). Then test for it being a block (DXF code 0 = "INSERT") and the block's name (DXF code 2 = "Block1") then if it's not both of those, do an entdel. Finally purge.

 

The "hardest" way would be to use ObjectDBX in the lisp inside the SCR to extract only the block's definition - recreate it inside the current drawing & then create an INSERT of that definition. In which case this would probably be more efficient if you did it directly in DotNet.

Link to comment
Share on other sites

I just want to be clear on this: You've modified ScriptPro's source in C# to run your scripts the way you want them, unclear why you don't use ScriptPro as is, or even better AutoScript? In which case why don't you use the DotNet to extract the block from the Blocks.DWG file in question?

 

Hi irneb, thanks for your reply!

The fact is that I still don't know what is the best way to do to get my issue. Even because I'm totally new about AutoCAD and this not help.

The core of my issue is create a batch process to generate a dwg file inserting blocks and editing their attributes. The blocks are in a different dwg and up to two blocks can be in the same dwg.

Searching and posting here I found AutoScript and ScriptPro but I can't use that because launching script file, if it is, is just a part of the process.

I was trying to see if a script file can do what I want but you said I need lisp in scr and I don't know lisp. So I don't know if going deeper in lisp and still follow this way is a good idea.

 

The "hardest" way would be to use ObjectDBX in the lisp inside the SCR to extract only the block's definition - recreate it inside the current drawing & then create an INSERT of that definition. In which case this would probably be more efficient if you did it directly in DotNet.

 

I don't know this option. Can you give me a little bit more info about did it in dotnet?

Do you think this should be better than make a script launcher batch process?

 

Many thanks again

Link to comment
Share on other sites

Firstly, the DotNet method would be something where you create a specific command, compiled into a DLL. It would not be a script in itself, but could probably be called from a script. This is the major reason most use Lisp instead, it's a quick-fix general purpose way of making an intelligent script. The overhead of doing a DotNet DLL each time you have something strange to fix in multiple DWGs makes most avoid it.

 

I'd say if you're going to do a lot of these things, it's probably a good idea to get at least a basic understanding of lisp. And you have posted this into the lisp forum, so ... that's probably the language of choice over here. Anyway, there should be numerous examples of getting hold of blocks & their attributes in these (and other) forums - I'd even venture to say this place may be positively riddled with them. Just do a search in this forum for BLOCK ATTRIBUTE MODIFY ... there's should be quite a few samples (56 threads at present), from which you may be able to adjust one to your exact needs.

 

The major reason that lisp is "easy" to use in this case - it can be typed directly into the command line. Thus it can be copied into the SCR file as well - it's then as if you typed those keys into ACad's command line. The draw-backs of lisp are:

 

  • It can't natively work with multiple drawings in sequence / at once. For that you require something else to open & close DWGs and then call the lisp. That's why the ScriptPro / AutoScript - there's other ways as well, but that's the easiest for the novice. And IMO works the best, or at least well enough for me.
  • You don't have all the capabilities you'd have gotten through using DotNet / ARX. But you get all the capabilities you'd have been able to with VBA ... and then some - just the previous point applies here as compared to VBA.
  • It would be a bit slower running than DotNet / ARX, but usually your code would be so small that loading the DLL / ARX file would negate the speed benefit.

Link to comment
Share on other sites

Anyway, there should be numerous examples of getting hold of blocks & their attributes in these (and other) forums - I'd even venture to say this place may be positively riddled with them. Just do a search in this forum for BLOCK ATTRIBUTE MODIFY ... there's should be quite a few samples (56 threads at present), from which you may be able to adjust one to your exact needs.

 

I put this together recently also. :)

Link to comment
Share on other sites

I put this together recently also. :)
Lee, just to be on the safe side ... I'd advise you to change the Vanilla Lisp SetAttribute function to not use the entire DXF list when doing the entupd - may cause problems with annotative scales. Rather change the internal of the while loop to this:
   (if (eq tag (cdr (assoc 2 elist)))
     (progn
       (entupd
         [color=red][b](list
           (assoc -1 elist)
           (cons 1 value)
         )[/b][/color]
       )
       (setq done value)
     )
   )

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