Jump to content

Recommended Posts

Posted

Hello!

 

A little background, first. I have some large number of MrSid (sid files) and coresponding sdw file to tell us informations about where and how the image should be inserted. Such a file is presented below:

1.50000000000000 (X scale, pixel size in meters)

0.00000000000000 (affinity - Y-scale in X dir.)

0.00000000000000 (affinity - X-scale in Y dir.)

-1.50000000000000 (Y scale)

1934001.50000000000000 (X coordinate of the upper left pixel)

1187698.50000000000000 (Y coordinate of the upper left pixel)

 

What I would like to build is a "database" that may be searched by a lisp routine. The workflow is as follows:

Command: Src_img

Please choose a point:

are to be inserted>

 

Now, while everything is trivial in this list, I seem to have a hard time retrieving the size of exotic file types (as sid) as it appears in the Autocad environment (wold size, if you wish). For other files I use a trick found on web (VBA):

 

Set objFolder = obj_Shell.Namespace(FilePth)
Set objFile = objFolder.ParseName(FileName)
objFile.ExtendedProperty("Dimensions")

 

This gives us the size, in pixels. Having the scales presented before, computing coordinate of bottom right corner is, again, trivial.

 

The question, now:

Is there a way that you know about to get the size of a sid image (pixels or world size) using lisp or vba? I would go as far as to recursively search the folders for sid files, load them, retrieve the bottom-right corner, unload, step to next.

 

By the way, I have already downloaded the sdk from LizardTech and I'll see what I can get from there.

 

Any insight is greatly appreciated!

Have a great day!

Nick

 

PS I give you so much informations just to avoid reading things that I already know about. Sorry! :)

  • 4 weeks later...
Posted

Just being here for some ObjectARX info and I have remembered that there was no answer to this. I did this (on Autocad Land Desktop 2007):

 

- an excel sheet (refered by EXCSheet in code) that holds full paths and names for all images on column 1

- FILEDIA set to 0

 

   With EXCSheet
       i = 4
       Do
RetryIns:
           ThisDrawing.SendCommand ("MAPIINSERT" & vbCrLf)
           ThisDrawing.SendCommand ("""" & .Cells(i, 1).Value & """" & vbCrLf)
           DoEvents
           Sleep 2000 ' maybe less
           ThisDrawing.SendCommand ("N" & vbCrLf) ' answer no

           ' this is he only image in the drawing (empty drawing)
           For Each a In ThisDrawing.ModelSpace
               If (TypeOf a Is AcadRasterImage) Then
                   Set the_img = a
                   insp = the_img.Origin ' insertion may fail to place image 
                   If (insp(0) = 0) And (insp(1) = 0) Then
                       the_img.Delete ' if so, we should retry
                       GoTo RetryIns
                   End If
                   
                   
                   Call the_img.GetBoundingBox(minp, maxp)
                   ' you may save bounding box here
                   scl_ty = ThisDrawing.GetVariable("INSUNITS")
                   Call ThisDrawing.SetVariable("INSUNITS", 0)                    
                   ' save here the_img.Rotation and the_img.ScaleFactor
                   Call ThisDrawing.SetVariable("INSUNITS", scl_ty)
                   ' maybe you need maximum/ minimum values... this is the place
                   the_img.Delete ' no need for this image any more
                   Exit For
               End If
           Next a
           
           i = i + 1
       Loop Until .Cells(i, 1).Value = ""
   End With
   

 

The code may look odd, as the parts that save values to excel sheet are stripped, but this is the general idea.

 

Best regards,

Nick

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...