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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CreatePolygonsFromSelection help

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AndyColmes Posted - May 24 2014 : 08:22:34
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

7   L A T E S T    R E P L I E S    (Newest First)
AndyColmes Posted - May 24 2014 : 23:25:07
Thank you William.
w2m Posted - May 24 2014 : 14:03:49
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
AndyColmes Posted - May 24 2014 : 13:06:14
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)?
w2m Posted - May 24 2014 : 12:53:21
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
AndyColmes Posted - May 24 2014 : 11:10:38
How do I get the hobj of the polygon created by CreatePolygonsFromSelection then?
AndyColmes Posted - May 24 2014 : 08:48:18
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.
w2m Posted - May 24 2014 : 08:38:22
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