Jump to content

pls help...how to use variable in script


nids_1978

Recommended Posts

Currently I am working on set of drawings for which I need to insert DXF files. These DXF files contain BOM extracted from our in house software. I usually prepare the drawings and insert the DXF by simply dragging the file into drawing, then scaling and placing in the right place. This take bit of time and just boring.

I want to do this process using Script. We care currently using this software - ezscriptpro

We are write small scripts like below, it great to changing constant things

Zoom

extent

cht

c

70,22

100,30

 

t

r

ISSUED FOR CONSTRUCTION

 

qsave

The problem this time is I have to insert DXF file using command : Insert (below is the script)

Zoom

extent

-insert

“(substr,$(getvar,dwgname),14,4) “

450,20

1

1

0

qsave

This gives error because insert command need file name not string “(substr,$(getvar,dwgname),14,4) “ but I need string as DXF name keeps changing with Drawing name.

Drawing name –5099221_DD03_5501_001_00.dwg, 5099221_DD03_5502_001_00.dwg, 5099221_DD03_5503_001_00.dwg……………..etc

Dxf name – 5501, 5502, 5503……..etc

“(substr,$(getvar,dwgname),14,4) “ give out put as “5501, 5502, 5503”

If anyone know how to solve this problem or have a better idea to do this process pls let us know.

Link to comment
Share on other sites

Perhaps:

 

(substr (getvar 'DWGNAME) 14 4)

 

Or if you wanted to stick to DIESEL:

 

(menucmd "m=$(substr,$(getvar,dwgname),14,4)")

Link to comment
Share on other sites

Thanx guys for the input...

 

msasu

 

Code - (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4))

give below output..........

Command: (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4))

"5099221_DD03_5514_001_00"

 

Lee...

the code you gave is right.. but the problem is using this in Inset Command.. below is the output..

 

Command: -INSERT

 

Enter block name or [?] : (substr (getvar 'DWGNAME) 14 4)

 

"(substr (getvar 'DWGNAME) 14 4).dwg": Can't find file in search path:

C:\Program Files\AutoCAD 2008\fonts\

C:\Program Files\AutoCAD 2008\help\

C:\Program Files\AutoCAD 2008\Express\

C:\Program Files\AutoCAD 2008\drv\

C:\Program Files\AutoCAD 2008\

*Invalid*

 

Insert command need drawing name... i want to use string so that i can use this in a loop...

Link to comment
Share on other sites

Perhaps:

 

(substr (getvar 'DWGNAME) 14 4)

 

Or if you wanted to stick to DIESEL:

 

(menucmd "m=$(substr,$(getvar,dwgname),14,4)")

------------------------------------------------------------------------

Hi Lee...

 

 

the code you gave is right.. but the problem is using this in Inset Command.. below is the output..

 

Command: -INSERT

 

Enter block name or [?] : (substr (getvar 'DWGNAME) 14 4)

 

"(substr (getvar 'DWGNAME) 14 4).dwg": Can't find file in search path:

C:\Program Files\AutoCAD 2008\fonts\

C:\Program Files\AutoCAD 2008\help\

C:\Program Files\AutoCAD 2008\Express\

C:\Program Files\AutoCAD 2008\drv\

C:\Program Files\AutoCAD 2008\

*Invalid*

 

Insert command need drawing name... i want to use string so that i can use this in a loop...

 

let me know your thoughts...

 

cheers

 

Prav

Link to comment
Share on other sites

Try to write it like:

 

(substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)) 

 

Regards,

----------------------------------------------------------------------

hi msasu

 

Code - (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4))

give below output.......... and it gives error.. cant put this in a loop..!!:(:(

 

Command: (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4))

"5099221_DD03_5514_001_00"

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