News:

The purpose of these forums is to discuss TurboCAD.  Please keep the discussion of other products to compatibility issues or how the other software can be used with TurboCAD.

Main Menu

Insert pictures from image manager

Started by drajer, April 21, 2021, 06:19:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

drajer

Has anybody tried to insert a picture via code from the picture manager?
drajer

nikkipollard

I know this is old - but incase someone does a search
This works in the macro recorder.

Option Explicit

'## example  add an  an image to the drawing'

Dim tcDraw
Set tcDraw = ActiveDrawing
' # add Reference to a Image Manager'
Dim Iman
Set Iman = CreateObject("TCIMAGE.TCImageManager")
Dim fileName
fileName = "C:\Users\User\Documents\turbo-original\RENDER\cobble2.jpg"
Dim imageName
imageName = "Cobble2"
' # add an image to the image manager'
Iman.AddImageStyle tcDraw, imageName, fileName, True
' # method Arguments
' # The drawing who owns the image manager usually the active drawing
' # The Image name - any string
' # File Name
' # Imbedded - Boolean - False for Imbedded
Dim imageID
imageID =  Iman.GetImageStyleCount(TCDraw)

' # add the image graphic to the Drawings graphic collection

Dim imageGraphic
Set imageGraphic = tcDraw.Graphics.Add(,"TCW90IMAGE")
'  # define vertices for Image
Dim verts
Set verts = imageGraphic.Vertices
With verts
.add 0,0,0
.Add 100, 0, 0
.Add 100, 100, 0
.Add 0, 100, 0
.Add 0, 0, 0
End With

' # set properties for the Image
        imageGraphic.Properties.Item("#$AUX@_ImageID").Value = imageID
' # show image - defaults to false  change it to true
imageGraphic.Properties.Item("#$AUX@_ShowImage").Value = True
imageGraphic.Properties.Item("#$AUX@_ShowClipped").Value = False

' ## Other Properties:
'    "#$AUX@_Contrast"
'    "#$AUX@_Transparency"
'    "#$AUX@_PPI"
'    "#$AUX@_OpaqueBackground"

imageGraphic.Draw

tcDraw.ActiveView.Refresh

Set tcDraw = Nothing
Set Iman = Nothing
Set verts = Nothing
Set imageGraphic = Nothing

Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h