Try to scale a Image in a Sketch

Try to scale a Image in a Sketch

mecanicu
Advocate Advocate
392 Views
1 Reply
Message 1 of 2

Try to scale a Image in a Sketch

mecanicu
Advocate
Advocate

Hello!

I'm try to scale a image that i imported throw insert image command. But I don't know how to scale it. The scale factor need's to be 1.35.

Here is the code i have: 

Sub Main()
    ' ***Change path to point to the desired bmp file.
    Dim strImagePath As String
    strImagePath = "C:\Temp\1.jpg"

    ' Create a new part document, using the default part template.
    Dim oPartDoc As PartDocument
     oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
                ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))

    ' Set a reference to the component definition.
    Dim oCompDef As PartComponentDefinition
     oCompDef = oPartDoc.ComponentDefinition

    ' Create a new sketch on the X-Y work plane.
    Dim oDecalSketch As PlanarSketch
    oDecalSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))

    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
     oTransGeom = ThisApplication.TransientGeometry
    Dim oCenter As Point2d
     oCenter = oTransGeom.CreatePoint2d(0, 0)

    ' Add a sketch image
    Dim oSketchImage As SketchImage
     oSketchImage = oDecalSketch.SketchImages.Add(strImagePath, oCenter)
	' Edit sketch
	oDecalSketch.Edit
	' Try set image Height & Width (better a scale factor)
	Dim iHeight As Double
     iHeight = oSketchImage.Height
	  iHeight = 10
	Dim iWidth As Double
     iWidth = oSketchImage.Width
	  iWidth = 20  

End Sub
0 Likes
Accepted solutions (1)
393 Views
1 Reply
Reply (1)
Message 2 of 2

mecanicu
Advocate
Advocate
Accepted solution

Nvm.
I resolve the problem. 🤦‍♂️

 

Sub Main()
    ' ***Change path to point to the desired bmp file.
    Dim strImagePath As String
    strImagePath = "C:\Temp\1.jpg"

    ' Create a new part document, using the default part template.
    Dim oPartDoc As PartDocument
     oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
                ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))

    ' Set a reference to the component definition.
    Dim oCompDef As PartComponentDefinition
     oCompDef = oPartDoc.ComponentDefinition

    ' Create a new sketch on the X-Y work plane.
    Dim oDecalSketch As PlanarSketch
    oDecalSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))

    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
     oTransGeom = ThisApplication.TransientGeometry
    Dim oCenter As Point2d
     oCenter = oTransGeom.CreatePoint2d(0, 0)

    ' Add a sketch image
    Dim oSketchImage As SketchImage
     oSketchImage = oDecalSketch.SketchImages.Add(strImagePath, oCenter)
	' Edit sketch
	oDecalSketch.Edit
	oSketchImage.Height = 30

End Sub
0 Likes