image file import and create outline of object
Is there a build in function or add on porgramme in bricscad that allow me to import image file( jpg,bmp or png) and creates an outline of the object. example --> [img]http://www.cadkas.com/paperausenlinien.png[/img]
Comments
-
Yoyo,
Here are two suggestions / solutions:
Solution 1: If you use our GeoTools add-on, there is a command called GT_BOUNDENT under the Draw Tools menu which will draw a bounding box around any set of selected objects, including raster image objects.
Solution 2: The complete source of this small tool is reproduced here.
Let me know how it works.
Regards
Rakesh Rao
http://rakeshrao.typepad.com;; | ---------------------------------------------------------------------------
;; | C:BoundEnt
;; | ---------------------------------------------------------------------------
;; | Function : Draw a closed rectangle polyline at the bounding box of the
;; | selected object(s).
;; | Argument :
;; | Return : None
;; | Updated : February 16, 2007
;; | Author : Rakesh Rao (www.coordsys.com)
;; | ---------------------------------------------------------------------------(defun c:BoundEnt ( / ent ename ss Lst LL UR OS )
(setvar "CMDECHO" 0)
(vl-load-com)(princ "\nSelect object(s) to enclose with bounding box:")
(setq OS (getvar "OSMODE"))
(setvar "OSMODE" 0)(setq ss (ssget))
(if ss
(progn
(setq
Lst (SS_BoundingBox ss)
LL (nth 0 Lst)
UR (nth 1 Lst)
)
(command "._Pline" LL (list (car LL) (cadr UR) 0.0) UR (list (car UR) (cadr LL) 0.0) "_Close")
(princ "\nA closed polyline rectangle was drawn covering the extent of the selected objects.")
))
(setvar "OSMODE" OS)
(prin1)
)
;; | -----------------------------------------------------------------------------
;; | SS_BoundingBox
;; | -----------------------------------------------------------------------------
;; | Function : Returns the selection set bounding box coordinates in the form
;; | of a list of Lower Left and Upper Right points.
;; | Arguments: 'ss' - Selection Set to examine
;; | Returns : 'Lst' - is a list of LL and UR
;; | Updated : June 10, 2005
;; | e-mail : rakesh.rao@4d-technologies.com
;; | Web : www.4d-technologies.com
;; | -----------------------------------------------------------------------------(defun SS_BoundingBox ( ss / ssl cnt llX llY urX urY ename cnt Lst LL UR _llX _llY _urX _urY )
(setq
ssl (sslength ss)
cnt 0
llX 1E20
llY 1E20
urX -1E20
urY -1E20
)
(repeat ssl
(setq
ename (ssname ss cnt)
cnt (1+ cnt)
Lst (GE_GetObjectBoundingBox ename)
LL (nth 0 Lst)
_llX (car LL)
_llY (cadr LL)
UR (nth 1 Lst)
_urX (car UR)
_urY (cadr UR)
)(if (< _llX llX)
(setq llX _llX)
)(if (< _llY llY)
(setq llY _llY)
)(if (> _urX urX)
(setq urX _urX)
)(if (> _urY urY)
(setq urY _urY)
)
)
(list (list llX llY 0.0) (list urX urY 0.0))
);; | ----------------------------------------------------------------------------
;; | GE_GetObjectBoundingBox
;; | ----------------------------------------------------------------------------
;; | Function : Returns the object bounding box coordinates in the form of a
;; | list of Lower Left and Upper Right points.
;; | Arguments: 'ename' - Object to examine
;; | Returns : 'Lst' - is a list of LL and UR
;; | Updated : April 28, 2000
;; | Comments : VL-function, works with AutoCAD 2000 only
;; | e-mail : rakesh.rao@4d-technologies.com
;; | Web : www.4d-technologies.com
;; | ----------------------------------------------------------------------------(defun GE_GetObjectBoundingBox(ename / ll ur vname )
(setq vname (vlax-ename->vla-object ename))
(vla-GetBoundingBox vname 'll 'ur)
(setq
ll (vlax-safearray->list ll)
ur (vlax-safearray->list ur)
)
(vlax-release-object vname)
(list ll ur)
)(princ "\nType 'BoundEnt' to start.")
(prin1)0 -
thanks rakeshfor both the solutions, as for solution 2 how do i input this script into bricscad? do i need to cut n paste into a txt file or?
0 -
Hello,
Copy the entire code into a text editor, save the file with a .LSP extension and you can load the Lisp into Bricscd using the appload command. You can then use the BOUNDENT command on the command line.
Regards
Rakesh Rao
www.4d-technologies.com0 -
just curious, were you able to get something to work?
0 -
just curious, were you able to get something to work?
0 -
daniel, im able to load the new function into briscad but unsure of how to use the new tools.
0 -
Hi Yoyo,
Whilst useful I don't think Rakesh's routine will provide you the result you seek. The Boundent routine I believe will simply place a bounding box around the extents of your image, which will be the same as the imageframe.
From your image example (http://www.cadkas.com/paperausenlinien.png) it looks like you want a routine that traces around the boundary of shapes within the image, which in your case would result in the word "Paper" being traced. This is quite a different excercise (raster to vector conversion).
There are a couple of applications available from the applications area that may fit your requirements. Take a look at Insyde Raster or Kalibronek under the applications general section http://www.bricscad.com/common/applications/applicationlist.jsp?estore.ApplicationCategory=8
If you only require to do this for a few images you could always just attach the image and trace around it yourself.
Regards,
Jason Bourhill
0 -
Just to add to Jason's comment, if you only have a few images to process, I have a routine that will import an image in as points, you could then connect the points with lines or polylines
0