Papao
Guest
Bye to all,
can you tell me if you can insert in dft environment, all the images in a folder automatically?
Thank you.
can you tell me if you can insert in dft environment, all the images in a folder automatically?
Thank you.
dim objapp as solidedgeframework.application = nothing
dim objdft as solidedgedraft.draftdocument = nothing
dim objsheet as solidedgedraft.sheet = nothing
objapp = marshal.getactiveobject("solidedge.application")
objdft = objapp.activedocument
objsheet = objdft.activesheet
dim objimages as solidedgedraft.images2d = objsheet.images2d
dim objimage as solidedgedraft.image2d = objimages.addimage(false,"nomeimmagine")
objimage.setorigin(x, y) 'x ed y sono le coordinate dove deve essere posizionata l'immagine
objimage.height = h 'h è l'altezza dell'immagine
objimage.width = w 'w è la larghezza dell'immagine
dim objapp as solidedgeframework.application
dim objdft as solidedgedraft.draftdocument
dim objsheet as solidedgedraft.sheet
set objapp = getactiveobject("solidedge.application")
set objdft = objapp.activedocument
set objsheet = objdft.activesheet
dim objimages as solidedgedraft.images2d
dim objimage as solidedgedraft.image2d
set objimages = objsheet.images2d
set objimage = objimages.addimage(false,"nomeimmagine")
call objimage.setorigin(x, y) 'x ed y sono le coordinate dove deve essere posizionata l'immagine
set objimage.height = h 'h è l'altezza dell'immagine
set objimage.width = w 'w è la larghezza dell'immagine
Sorry I meant it is a double-type property that represents the size of the image in meters. if you want 100 mm wide image you will need to use@be_on_edgethanks for the connection to the guide of the sdk of if, but in the guide the two values "width" & "height" are "properties" and the "double" is a "data type".
When you talk about object you refer to "image2d"?
set objimage.width = 0.1
maybe not needed, vb6 was a strange hybrid as syntax in some cases you used the set in others not, I don't remember why motivoOkay, I understand, but it seems strange that you have to assign the value with the "set" directive... only that I do not use vb6 anymore for a century... I will go to refresh my memory.... That doesn't hurt in the summer.![]()
Yes, indeed, I'm curious. . .maybe not needed, vb6 was a strange hybrid as syntax in some cases you used the set in others not, I don't remember why motivo
set objapp = getactiveobject("solidedge.application")
' codice vba
sub createimage2d()
on error goto createtoolpalette_error
dim oapp as solidedgeframework.application
set oapp = getobject(, "solidedge.application")
oapp.screenupdating = false
dim oimage as solidedgeframeworksupport.image2d
set oimage = oapp.activedocument.activesheet.images2d.addimage(false, "percorso completo dell'immagine")
oimage.setorigin 0.1, 0.1
oapp.screenupdating = true
set oimage = nothing
set oapp = nothing
on error goto 0
exit sub
createtoolpalette_error:
msgbox "errore " & err.number & " (" & err.description & ") nella procedura createimage2d, linea " & erl & "."
end sub
dim app : set app = getobject(,"solidedge.application")
app.screenupdating = false
dim image : set image = app.activedocument.activesheet.images2d.addimage(false, "percorso completo del file")
' call image.setorigin(0.1, 0.1)
' oppure
image.setorigin 0.1, 0.1
app.screenupdating = true
# activex interface
use win32::ole;
use win32::ole::variant;
# use existing instance if solidedge is already running
eval {$solidedge = win32::ole->getactiveobject('solidedge.application')};
die "solidedge not installed" if $@;
unless (defined $solidedge) {
$solidedge = win32::ole->new('solidedge.application')
or die "oops, cannot start solidedge";
}
$doc = $solidedge->activedocument();
$img = $doc->activesheet->images2d->addimage(false, "percorso completo del file");
$img-setorigin(0.1, 0.1);
import win32com.client, time, win32con
app = win32com.client.dispatch("solidedge.application")
if app is not none:
img = app.activedocument.activesheet.images2d.addimage(false, "percorso completo del file")
img.setorigin(0.1, 0.1)
else:
print("errore! solidedge non trovato!")
the correct code is:I'm sorry to disappoint you reddish, but I haven't written anything in vb6 yet, except to try what Francis suggested: Unfortunately I can devote a few minutes a day and not always.. .
I asked the vb6 because he's the only one I know a little, and I couldn't understand the code that francesco had originally posted.
However testing the code, the following line goes wrong and the libraries I think I have activated them allCode:set objapp = getactiveobject("solidedge.application")
set objapp = getobject(,"solidedge.application")
this is the code line I entered for the path and inside contains one or more jpg type files
set oimage = oapp.activedocument.activesheet.images2d.addimage(false, "c:\users\paolo\desktop\solid edge\parte1\")
you did not put the file name to add; you will need to use the addimage method for each image contained in the folder. something like this:thank you guys, very kind as always... reddish too much I would say no
However I think I'm wrong because the code in vba returns the following error:View attachment 71893this is the code line I entered for the path and inside contains one or more jpg type filesCode:set oimage = oapp.activedocument.activesheet.images2d.addimage(false, "c:\users\paolo\desktop\solid edge\parte1\")
strfiles = dir("c:\users\paolo\desktop\solid edge\parte1\")
x = 0.1
while strfiles <> ""
set oimage = oapp.activedocument.activesheet.images2d.addimage(false, strfiles)
oimage.setorigin x, 0.1
x = x + 0.1
strfiles = dir
wend