ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CreatePolygonsFromSelection help
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndyColmes

USA
351 Posts

Posted - May 24 2014 :  08:22:34  Show Profile  Reply
I am trying to create an object from a polygon selection with the following, but I get "Invalid Object Index" apparently hobj is not valid:

hobj := ImageEnVect1.CreatePolygonsFromSelection;
ImageEnVect1.AddSelObject(hobj);
ImageEnVect1.Update;

Where did I go wrong?

Thanks for your help in advance.

Andy

w2m

USA
1990 Posts

Posted - May 24 2014 :  08:38:22  Show Profile  Reply
hobj probably is -1 because CreatePolygonsFromSelection is not a function. It is a procedure. I am surprised you do not get a compiler warning or hint.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom Commercial ImageEn Development
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - May 24 2014 :  08:48:18  Show Profile  Reply
I was surprised that I did not get a compiler warning as well or maybe I missed it. I guess I don't have to call AddSelObject after CreatePolygonsFromSelection.
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - May 24 2014 :  11:10:38  Show Profile  Reply
How do I get the hobj of the polygon created by CreatePolygonsFromSelection then?
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 24 2014 :  12:53:21  Show Profile  Reply
There are several different ways:
You can use SelObjects, GetObjFromID, GetObjFromIndex and GetObjFromName.
// Sets pen color to clRed for all selected objects.
for i:=0 to ImageEnVect1.SelObjectsCount-1 do
  ImageEnVect1.ObjPenColor[ ImageEnVect1.SelObjects[i] ] := clGreen;

// changes to red pen color for each object
for i := 0 to ImageEnVect1.ObjectsCount - 1 do
begin
  hobj := ImageEnVect1.GetObjFromIndex( i );
  ImageEnVect1.ObjPenColor[ hobj ] := clRed;
end;


// set pen color to clRed for the first object that has ObjName[]='Jack'
var
  hobj:integer;
begin
...
  hobj:=ImageEnVect1.GetObjFromName('Jack');
  ImageEnVect1.ObjPenColor[hobj]:=clRed;
..
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom Commercial ImageEn Development
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - May 24 2014 :  13:06:14  Show Profile  Reply
Thanks William. But calling CreatePolygonsFromSelection should create a polygon object and can I assume that the created object is selected (so I can use your first method of SelObjectsCount)?
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 24 2014 :  14:03:49  Show Profile  Reply
Andy... I suggest you try two things before asking a question.
1. Look at the help file... in this case ImageEnVect.Selectiuons.
2. Try some of your own code, then if it fails ask a question and post your code along with the question.
function IsSelObject(hobj: integer): boolean;

Description
IsSelObject returns true if hobj object is selected.
The last inserted object is always selected.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom Commercial ImageEn Development
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - May 24 2014 :  23:25:07  Show Profile  Reply
Thank you William.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: