highlight an object in cadPictBox
Moderators: SDS, support, admin
-
- Posts: 8
- Joined: 10 Jul 2019, 05:36
Re: Find a location of specif text
Hi,
I want to highlight an object in cadPictBox by select blockname or how to know this object is selected.
How can I do it ?
I want to highlight an object in cadPictBox by select blockname or how to know this object is selected.
How can I do it ?
-
- Posts: 8
- Joined: 10 Jul 2019, 05:36
highlight an object in cadPictBox
please help me some questions
1/ I want to highlight an object in cadPictBox when I select it in treeview. ex: block, text...
2/ when my clients open a cad file, it shows many objects in cadPictBox. how to config some objects allow selection and some not. ex: allow select block, text; not allow select line...
1/ I want to highlight an object in cadPictBox when I select it in treeview. ex: block, text...
2/ when my clients open a cad file, it shows many objects in cadPictBox. how to config some objects allow selection and some not. ex: allow select block, text; not allow select line...
Re: highlight an object in cadPictBox
Hello,
Mikhail
Could you please specify what you mean by highlighting? Is it changing of the entity line type and/or color or anything else?CoffeeShop wrote: ↑10 Jul 2019, 16:161/ I want to highlight an object in cadPictBox when I select it in treeview. ex: block, text...
You should use a CADImage.Selector.DoSelectEntity method that allows to show visual selection only for a certain CADEntity and should check the entity type prior to calling this method:CoffeeShop wrote: ↑10 Jul 2019, 16:162/ when my clients open a cad file, it shows many objects in cadPictBox. how to config some objects allow selection and some not. ex: allow select block, text; not allow select line...
Code: Select all
CADEntity ent;
...
if (ent.EntType == EntityType.Text)
CADImage.Selector.DoSelectEntity(ent);
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Find a location of specif text
Do you want to highlight CADInsert object(s) by a given block name?CoffeeShop wrote: ↑10 Jul 2019, 05:47Hi,
I want to highlight an object in cadPictBox by select blockname or how to know this object is selected.
How can I do it ?
To know whether a certain object is selected, use a CADEntity.Selected property.
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 8
- Joined: 10 Jul 2019, 05:36
Re: highlight an object in cadPictBox
Hello,
The following method applies a new color to all the CADInsert objects of a given block that are located on the current layout:
Mikhail
The following method applies a new color to all the CADInsert objects of a given block that are located on the current layout:
Code: Select all
public static void ChangeBlockColor(CADImage drawing, string blockName, Color newColor)
{
CADBlock block = drawing.Converter.BlockByName(blockName);
if (block != null)
{
block.Entities.ForEach(entity => entity.Color = CADConst.clByBlock);
drawing.Converter.Loads(block);
List<CADEntity> inserts = drawing.CurrentLayout.Entities.FindAll(ent => ent.EntType == EntityType.Insert);
List<CADEntity> blockInserts = inserts.FindAll(ent => (ent as CADInsert).Block.Name == blockName);
foreach (CADEntity insert in blockInserts)
{
insert.Color = newColor;
drawing.Converter.Loads(insert);
}
}
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 8
- Joined: 10 Jul 2019, 05:36
Re: highlight an object in cadPictBox
Thanks Mikhail.
It works ok.
I can change color of Text object, but it not work on MText.
I saw every object has a handle number. Is this unique on cad file?
It works ok.
I can change color of Text object, but it not work on MText.
I saw every object has a handle number. Is this unique on cad file?
Code: Select all
Shared Function ChangeColorByText(cadImage As CADImage, objType As EntityType, _text As String, newColor As Color) As Boolean
If cadImage Is Nothing Then Return False
For i As Integer = 0 To cadImage.CurrentLayout.Entities.Count - 1
If cadImage.CurrentLayout.Entities(i).EntType = objType Then
Dim entity As CADEntity = cadImage.CurrentLayout.Entities(i)
Select Case entity.EntType
Case EntityType.Text
Dim cadText As CADText = CType(entity, CADText)
If cadText.Text.ToLower = _text.ToLower Then
cadText.Color = newColor
Return True
End If
Case EntityType.MText
Dim cadMText As CADMText = CType(entity, CADMText)
If cadMText.Text.ToLower = _text.ToLower Then
cadMText.Color = newColor
Return True
End If
End Select
End If
Next
Return False
End Function
Re: highlight an object in cadPictBox
Hello,
You are welcome.
The code you posted actually cannot change a color of entity because of the missing line which should go right after assigning a new color (or changing any other property of CADEntity derivatives):
or
Mikhail
You are welcome.
The code you posted actually cannot change a color of entity because of the missing line which should go right after assigning a new color (or changing any other property of CADEntity derivatives):
Code: Select all
cadImage.Converter.Loads(cadText)
Code: Select all
cadImage.Converter.Loads(cadMText)
Are you sure that the condition cadMText.Text.ToLower = _text.ToLower is satisfied?I can change color of Text object, but it not work on MText.
Yes, CADEntity.Handle value is unique for each object within a CAD file.I saw every object has a handle number. Is this unique on cad file?
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support