DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Save screen as image

Started by aqua, May 16, 2008, 10:33:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aqua

Designcad 13.13

Can anyone shed any light as to why the following macro doesn't work.

I want to "Save Drawing as Image - Screen"

Once upon a time it worked - now it doesn't save either the jpg or bmp image.

Regards Frank



'FTM-17/5/2008
sys(470)=1
>Save
{
  }

a=0
a=sys(600)
b=0
b=sys(601)
c=0
c=sys(602)
d=0
d=sys(603)

newa=a-((b-a)*1/100)
newb=b-((d-c)*1/100)
newc=c+((b-a)*1/100)
newd=d+((d-c)*1/100)

'Automate drawing name entry

Fullname$ = SYS$(2)
Namelen = len(Fullname$) ' get number of characters in it
k = Namelen ' broken interpreter kludge

for j = 1 to Namelen
A$ = MID$(FullName$, k, 1)
If A$ = "\" then
lastslash = K+1 ' broken interpreter kludge
exit for
end if
k =k - 1 ' broken interpreter kludge
next
Shortname$ = MID$(FullName$, lastslash, Namelen-Lastslash+1-4)



Existingdrawingpath$ = sys$(20)
Divider$ = "\"

Filetype$ = ".bmp"
text$ = Existingdrawingpath$ + Divider$ + shortname$ + Filetype$
message "bmp text$ = ", text$

>SaveBMP
{
  <PointXYZ [newa,newb,0]
  <PointXYZ [newc,newd,0]
  <Filename [text$]
  <Type 0
  }

Filetype$ = ".jpg"
text$ = Existingdrawingpath$ + Divider$ + shortname$ + Filetype$
message "jpg text$ = ", text$

>SaveBMP
{
  <PointXYZ [newa,newb,0]
  <PointXYZ [newc,newd,0]
  <Filename [text$]
  <Type 0
  }


Message "Both a BMP and JPG version of your drawing have been created and saved as", Shortname$, "in", Existingdrawingpath$, ". Note: Printing scale will depend on printer and paper size"


DrollTroll

Seems to work fine for me, Frank. Make sure you've got write permissions to the target directory.

Do you get any kind of error message, or just no files created? If no files, try a search on the filenames to see if they're going somewhere else for some reason.
25 years with DesignCAD

dcadRob

This code is heavily dependent on the filename. What is the filename and directory that you are using? Did it stop working after you moved to a new directory or started using a different naming pattern?

aqua

Designcad 13.13

Guys,

Sorry for the delay - the index says I posted the last meassge, so I didn't know there were any replies.

I don't get any error messages, just simply no image. Search does not find anything.
I have added messages to confirm the file path and now I get an image - but it is a snap shot of part of the Designcad toolbar - not the drawing.

The file name is what ever the drawing is, the code for this hasn't changed.
And the file path is determined from the default drawing directory.
If the drawing came from a different location, it should still save the images to the default directory.
If images exist, it should over write them, if they don't, it should create new ones.

Regards Frank



'FTM-17/5/2008
sys(470)=1
>Save
{
  }

a=0
a=sys(600)
b=0
b=sys(601)
c=0
c=sys(602)
d=0
d=sys(603)

newa=a-((b-a)*1/100)
newb=b-((d-c)*1/100)
newc=c+((b-a)*1/100)
newd=d+((d-c)*1/100)

'Automate drawing name entry

Fullname$ = SYS$(2)
Namelen = len(Fullname$) ' get number of characters in it
k = Namelen ' broken interpreter kludge

for j = 1 to Namelen
A$ = MID$(FullName$, k, 1)
If A$ = "\" then
lastslash = K+1 ' broken interpreter kludge
exit for
end if
k =k - 1 ' broken interpreter kludge
next
Shortname$ = MID$(FullName$, lastslash, Namelen-Lastslash+1-4)



Existingdrawingpath$ = sys$(20)
Divider$ = "\"

Filetype$ = ".bmp"
text$ = Existingdrawingpath$ + Divider$ + shortname$ + Filetype$
message "bmp text$ = ", text$

>SaveBMP
{
  <PointXYZ [newa,newb,0]
  <PointXYZ [newc,newd,0]
  <Filename [text$]
  <Type 0
  }

Filetype$ = ".jpg"
text$ = Existingdrawingpath$ + Divider$ + shortname$ + Filetype$
message "jpg text$ = ", text$

>SaveBMP
{
  <PointXYZ [newa,newb,0]
  <PointXYZ [newc,newd,0]
  <Filename [text$]
  <Type 0
  }


Message "Both a BMP and JPG version of your drawing have been created and saved as", Shortname$, "in", Existingdrawingpath$, ". Note: Printing scale will depend on printer and paper size"


dcadRob

So what are the values for:
a,b,c,d, newa, newb, newc, newd
If you get a picture of the toolbar, then these are probably not what you expect.

Adding messages produces a picture? What are your values for:
Fullname$
Shortname$
Existingdrawingpath$

DrollTroll

Frank,

What happens if you just use

>SaveBmp
{
<Filename [text$]
<Type 0
}

and don't set any points? That *should* save the entire active view as an image.
25 years with DesignCAD

aqua

Guys

I have solved the problem by adding zoom code before saving the image.
Discovered for example that you can't save the whole drawing as an image unless it is fully shown on the screen. That was why I would some times get the tool bars included in the image, or no image at all.

I have three different functions:

Save drawing as image
Save screen as image
Save set area as image


Not sure why I added the 1/100 extra bit, could have been borrowed from other macros, or there might have been an issue with capturing the edge of the screen.

Thanks for assistance.


The new Save screen as image is as follows


'FTM-30/5/2008
sys(470)=1
sys(36)=1
>Save
{
  }

'Min X
a=0
a=sys(600)
'Max X
b=0
b=sys(601)
'min Y
c=0
c=sys(602)
'Max y
d=0
d=sys(603)

newa=a-((b-a)*1/100)
newb=b+((b-a)*1/100)
newc=c-((d-c)*1/100)
newd=d+((d-c)*1/100)

'Automate drawing name entry

Fullname$ = SYS$(2)
Namelen = len(Fullname$) ' get number of characters in it
k = Namelen ' broken interpreter kludge

for j = 1 to Namelen
A$ = MID$(FullName$, k, 1)
If A$ = "\" then
lastslash = K+1 ' broken interpreter kludge
exit for
end if
k =k - 1 ' broken interpreter kludge
next
Shortname$ = MID$(FullName$, lastslash, Namelen-Lastslash+1-4)



Existingdrawingpath$ = sys$(20)
Divider$ = "\"

Filetype$ = ".bmp"
text$ = Existingdrawingpath$ + Divider$ + shortname$ + Filetype$

>ZoomWindow
{
  <PointXYZ [newa,newc,0]
  <PointXYZ [newb,newd,0]
}

>SaveBMP
{
  <PointXYZ [newa,newc,0]
  <PointXYZ [newb,newd,0]
  <Filename [text$]
  <Type 0
  }

Filetype$ = ".jpg"
text$ = Existingdrawingpath$ + Divider$ + shortname$ + Filetype$

>SaveBMP
{
  <PointXYZ [newa,newc,0]
  <PointXYZ [newb,newd,0]
  <Filename [text$]
  <Type 0
  }


>ZoomPrevious
{
  }

sys(36)=0
Message "Both a BMP and JPG version of your drawing have been created and saved as", Shortname$, "in", Existingdrawingpath$, ". Note: Printing scale will depend on printer and paper size"