×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Add image to drafting journal

Add image to drafting journal

Add image to drafting journal

(OP)
Hi guys,
I'm looking for NX Api function to add image into drafting sheet. Any idea?

RE: Add image to drafting journal

While in Drafting with a Drawing sheet displayed, go to...

Insert -> Image...

...where you will be able to insert either a .jpg, .png or .tif formatted image file onto the face of the drawing. Once placed, you will be able to drag it to the desired location, rotate at 90° increments, resize the image or change it's aspect ratio (after toggling OFF the aspect ratio lock icon) using the handles shown when editing the image. Note that this image is static and will NOT update if the original image file is edited.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.

RE: Add image to drafting journal

(OP)
Is there a NX Open function to do this? I want to make this proces automatic with journal (VB)

RE: Add image to drafting journal

I suspect not. It uses an older set of user interface tools which are not supported via journaling. Now there still might be an explicit NX Open call but doing a quick search of the NX Open functions I couldn't find anything that looks like it would address this.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.

RE: Add image to drafting journal

Edit this to suit your needs.

CODE

'eng-tips thread561-335144: Add image to drafting journal: Add image to drafting journal
'import image to drafting sheet

Option Strict Off  
Imports System  
Imports NXOpen  
Imports NXOpen.UF  

Module Module1  

    Sub Main()  

        Dim theSession As Session = Session.GetSession()  
        Dim ufs As UFSession = UFSession.GetUFSession  
        Dim workPart As Part = theSession.Parts.Work  

        Dim imageFile As String = "C:\temp\test.jpg"  
        Dim sheetTag As Tag = Tag.Null  
        Dim imageCoordinates(2) As Double  
        imageCoordinates(0) = 0  
        imageCoordinates(1) = 0  
        imageCoordinates(2) = 0  
        Dim imageTag As Tag = Tag.Null  
        ufs.Drf.CreateImageFromFile(imageFile, sheetTag, imageCoordinates, imageTag)  

        If imageTag.Equals(Tag.Null) Then  
 'image was not imported
        End If  

    End Sub  


    Public Function GetUnloadOption(ByVal dummy As String) As Integer  

 'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination  

    End Function  

End Module 

www.nxjournaling.com

RE: Add image to drafting journal

(OP)
It works, great man ! After test I will post my script at nxjournaling.com

RE: Add image to drafting journal

(OP)
It works perfectly, but...
When it inserts image, journal changes the size (or scale) of the picture. In format A4 it's ok, but in A3, A2 it's 2 times bigger. (Or mayby in A4 is 2 times smaller)
I am also wonder if its possible to define image size and image name during inserting image into drafting (with image name i would have chance to check if image is jet in drafting)
ufs.Drf.imageData? ufs.Drf.askImageData?
I'm using NX 8.0.3.4.

RE: Add image to drafting journal

I'm unable to duplicate the scaling issue. I've added some code that reports the image dimensions, then scales the image to be 1/2 of the original width.

I've been looking at the initialize image data function in the help file, but I don't see an obvious way to associate that to the image that is being imported. I'll look into it more as I get time.

CODE

Option Strict Off  
Imports System  
Imports NXOpen  
Imports NXOpen.UF  

Module Module1  

    Sub Main()  

        Dim theSession As Session = Session.GetSession()  
        Dim ufs As UFSession = UFSession.GetUFSession  
        Dim workPart As Part = theSession.Parts.Work  
        Dim lw As ListingWindow = theSession.ListingWindow  
        lw.Open()  

        Dim imageFile As String = "C:\temp\test.jpg"  
        Dim sheetTag As Tag = Tag.Null  
        Dim imageCoordinates(2) As Double  
        imageCoordinates(0) = 0  
        imageCoordinates(1) = 0  
        imageCoordinates(2) = 0  
        Dim imageTag As Tag = Tag.Null  

        Dim myImageData As UFDrf.ImageData  

        ufs.Drf.CreateImageFromFile(imageFile, sheetTag, imageCoordinates, imageTag)  

        If imageTag.Equals(Tag.Null) Then  
 'image was not imported
        Else  
            ufs.Drf.AskImageData(imageTag, myImageData)  
            lw.WriteLine("initial settings")  
            lw.WriteLine("original image height: " & myImageData.height.ToString)  
            lw.WriteLine("original image width: " & myImageData.width.ToString)  
            lw.WriteLine("aspect ratio locked: " & myImageData.aspect_ratio_locked.ToString)  
            lw.WriteLine("name: " & myImageData.image_name)  
            lw.WriteLine("")  
 'lock the aspect ratio
            ufs.Drf.SetImageAspectRatioLock(imageTag, True)  
 'resize width to be 1/2 original width
            ufs.Drf.SetImageWidth(imageTag, myImageData.width / 2)  
        End If  

        lw.Close()  

    End Sub  


    Public Function GetUnloadOption(ByVal dummy As String) As Integer  

 'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination  

    End Function  

End Module 

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources