• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

image insertion on dft

  • Thread starter Thread starter Papao
  • Start date Start date

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.
 
I guess you need a little vb...
image files to be inserted in the dft are contained within a folder called with the same file name (without extension).

Can you help me?
 
something like that (not proven code)
Code:
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
 
Last edited:
the code returns the syntax error on all variable statements;
I thought they missed the references to the bookstores but also activating them, I didn't solve it.
Maybe I didn't find the right one?
 
I haven't used vb6 for at least 10 years and was old already at '

You must definitely add references, in the statements remove the assignment of value but do it in a separate row, to assign the values you must probably add "set" in front of the instruction.

I would download visual studio community or visual studio code with which you open a world of possibilities.
Code:
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
 
@be_on_edge thanks 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"?
 
@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"?
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
Code:
set objimage.width = 0.1
 
Okay, 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. 😐
 
Okay, 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. 😐
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
 
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
Yes, indeed, I'm curious. . .

I was curious to see the code he wrote praying to understand what he wrote about different "things"... but mine is just a curiosity:)

Maybe I wrote too many times curious... Who's hot?
 
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 all
Code:
set objapp = getactiveobject("solidedge.application")
 
praying You didn't let me down. Don't worry.

What I was asking is just the lines of code you wrote and that give you error, I think reading the written code (one line or many that are) is more immediate than talking about it to understand if there are errors.

Anyway, this is the code you wrote @be_on_edge "revisited" and tested.
Code:
' 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
this is the same code in vbs
Code:
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
this same code in perl
Perl:
# 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);
this same code in python
Python:
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!")

😁
 
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 all
Code:
set objapp = getactiveobject("solidedge.application")
the correct code is:
Code:
set objapp = getobject(,"solidedge.application")
 
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:Cattura.webpthis is the code line I entered for the path and inside contains one or more jpg type files
Code:
set oimage = oapp.activedocument.activesheet.images2d.addimage(false, "c:\users\paolo\desktop\solid edge\parte1\")
 
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 files
Code:
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:

(untested code, images are inserted side by side every 100 mm)
Code:
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
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top