Zoom All/Extents and nearest entity to cursor
Moderators: SDS, support, admin
Zoom All/Extents and nearest entity to cursor
Hello, I have a pair of questions about CadImport.NET:
Ñ—How can I implement a "ZoomAll" or "ZoomExtents" function?
Ñ—How can I get the nearest entity to the mouse cursor position (without clicking)?
Thank you very much
Ñ—How can I implement a "ZoomAll" or "ZoomExtents" function?
Ñ—How can I get the nearest entity to the mouse cursor position (without clicking)?
Thank you very much
Hello Zebiya,
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">How can I implement a "ZoomAll" or "ZoomExtents" function?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Please find the following code in the <b>Viewer</b> demo.
Method <i>ResetScaling</i> is responsible on defining inner parameters for ZoomExtents functionality:
Method <i>DrawCADImage</i> draws image taking into account inner parameters specified by <i>ResetScaling</i>:
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">How can I get the nearest entity to the mouse cursor position (without clicking)?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Please add the following code into the <i>cadPictBox_MouseUp</i> method (<b>note</b>: this code would work only with extended version of the library):
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">How can I implement a "ZoomAll" or "ZoomExtents" function?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Please find the following code in the <b>Viewer</b> demo.
Method <i>ResetScaling</i> is responsible on defining inner parameters for ZoomExtents functionality:
Code: Select all
<font color="blue">Public Sub</font id="blue"> ResetScaling()
<font color="blue">Me</font id="blue">.scl = 1.0!
<font color="blue">Me</font id="blue">.prev_scale = 1.0!
<font color="blue">Me</font id="blue">.pos.X = ((<font color="blue">Me</font id="blue">.cadPictBox.ClientRectangle.Width - <font color="blue">Me</font id="blue">.curClRect.Width) / 2)
<font color="blue">Me</font id="blue">.pos.Y = ((<font color="blue">Me</font id="blue">.cadPictBox.ClientRectangle.Height - <font color="blue">Me</font id="blue">.curClRect.Height) / 2)
<font color="blue">Me</font id="blue">.cadPictBox.Invalidate()
<font color="blue">End Sub</font id="blue">
Code: Select all
<font color="blue">Public Sub</font id="blue"> DrawCADImage(<font color="blue">ByVal</font id="blue"> gr <font color="blue">As</font id="blue"> Graphics)
<font color="blue">If</font id="blue"> (<font color="blue">Not Me</font id="blue">.FCADImage <font color="blue">Is Nothing</font id="blue">) <font color="blue">Then
Try
Me</font id="blue">.deactiv = <font color="blue">False
Me</font id="blue">.Shift()
<font color="blue">Dim</font id="blue"> ef1 <font color="blue">As New</font id="blue"> RectangleF(<font color="blue">Me</font id="blue">.pos.X, <font color="blue">Me</font id="blue">.pos.Y, (<font color="blue">Me</font id="blue">.curClRect.Width * <font color="blue">Me</font id="blue">.scl), (<font color="blue">Me</font id="blue">.curClRect.Height * <font color="blue">Me</font id="blue">.scl))
<font color="blue">Me</font id="blue">.FCADImage.Draw(gr, ef1)
<font color="blue">Catch</font id="blue"> obj1 <font color="blue">As</font id="blue"> Exception
<font color="blue">End Try
End If
End Sub</font id="blue">
Please add the following code into the <i>cadPictBox_MouseUp</i> method (<b>note</b>: this code would work only with extended version of the library):
Code: Select all
<font color="blue">Public Sub</font id="blue"> cadPictBox_MouseUp(<font color="blue">ByVal</font id="blue"> sender <font color="blue">As</font id="blue"> System.Object, <font color="blue">ByVal</font id="blue"> e <font color="blue">As</font id="blue"> System.Windows.Forms.MouseEventArgs) <font color="blue">Handles</font id="blue"> cadPictBox.MouseUp
<font color="blue">Dim</font id="blue"> Ent <font color="blue">As</font id="blue"> CADEntity
...
Ent = FCADImage.SelectExt(e.X, e.Y)
<font color="blue">If Not</font id="blue"> (Ent <font color="blue">Is Nothing</font id="blue">) <font color="blue">Then</font id="blue">
Ent.Selected = <font color="blue">False</font id="blue">
FCADImage.ClearMarkers()
FCADImage.InvalidateSelectEntity(cadPictBox, Me.scl)
<font color="blue">End If</font id="blue">
...
Please post questions to the forum or write to support@cadsofttools.com
Thank you for your answer Sergey. I think it will be useful
However, when I use your last piece of code
I get a "NullReferenceException". If I control it with "try" statement, I never get any entity. "selected" is also not a member of "CadImport.CadEntity" and raises an error. FCADImage.ClearMarkers() is also not valid method. I am using CadImport.NET extended version
I want to use this in my <b>MouseMove</b> event, tracking which entity is under the mouse cursor at any time. The purpose of this is making a sort of "OSNAP" to the EndPoint of certain entities. I have already developed all the module, but I still cannot get the entity. PLEASE HELP! my boss will [B)] me! [:(]
One thing that I miss in CadSoftTools examples' code and documentation is the absolute lack of comments, Ñ—could you please comment a bit the code you posted? probably it would make some things clearer for me.
Thank you very much for your help
However, when I use your last piece of code
Code: Select all
Dim Ent As CADEntity
...
Ent = FCADImage.SelectExt(e.X, e.Y)
If Not (Ent Is Nothing) Then
Ent.Selected = False
FCADImage.ClearMarkers()
FCADImage.InvalidateSelectEntity(cadPictBox, Me.scl)
End If
...
I want to use this in my <b>MouseMove</b> event, tracking which entity is under the mouse cursor at any time. The purpose of this is making a sort of "OSNAP" to the EndPoint of certain entities. I have already developed all the module, but I still cannot get the entity. PLEASE HELP! my boss will [B)] me! [:(]
One thing that I miss in CadSoftTools examples' code and documentation is the absolute lack of comments, Ñ—could you please comment a bit the code you posted? probably it would make some things clearer for me.
Thank you very much for your help
Hello Zebiya,
It looks like you don't use extended version of <b>CAD Import .NET</b> or you use just the old one. If so, please contact us to info@cadsofttools.com.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">I want to use this in my <b>MouseMove</b> event, tracking which entity is under the mouse cursor at any time. The purpose of this is making a sort of "OSNAP" to the EndPoint of certain entities. I have already developed all the module, but I still cannot get the entity. PLEASE HELP! my boss will [B)] me! [:(] <hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We work on adding <b>OSNAP</b> feature. It will be available in some of future versions of the library. We will inform you when it will be ready.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">One thing that I miss in CadSoftTools examples' code and documentation is the absolute lack of comments, could you please comment a bit the code you posted? probably it would make some things clearer for me.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We do understand that documentation must be more informing and easy to use. But the question is that it is required to widen functionality first. That is why the most acceptable way for the moment is giving explanations online (via e-mail or by the forum).
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
It looks like you don't use extended version of <b>CAD Import .NET</b> or you use just the old one. If so, please contact us to info@cadsofttools.com.
Code: Select all
Ent = FCADImage.SelectExt(e.X, e.Y) <font color="green">'<i>SelectExt</i> returns nearest entity to the mouse cursor </font id="green">
<font color="blue">If Not</font id="blue"> (Ent <font color="blue">Is Nothing</font id="blue">) <font color="blue">Then</font id="blue">
Ent.Selected = <font color="blue">False</font id="blue"> <font color="green"> '<i>Selected</i> defines whether entity is selected</font id="green">
FCADImage.ClearMarkers() '<font color="green"><i>ClearMarkers</i> removes all selecting markers from the inner collection</font id="green">
FCADImage.InvalidateSelectEntity(cadPictBox, Me.scl) '<font color="green"><i>InvalidateSelectEntity</i> - redraws selected entities (without markers)</font id="green">
<font color="blue">End If</font id="blue">
...
We work on adding <b>OSNAP</b> feature. It will be available in some of future versions of the library. We will inform you when it will be ready.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">One thing that I miss in CadSoftTools examples' code and documentation is the absolute lack of comments, could you please comment a bit the code you posted? probably it would make some things clearer for me.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We do understand that documentation must be more informing and easy to use. But the question is that it is required to widen functionality first. That is why the most acceptable way for the moment is giving explanations online (via e-mail or by the forum).
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by support</i>
<br />Hello Zebiya,
It looks like you don't use extended version of <b>CAD Import .NET</b> or you use just the old one. If so, please contact us to info@cadsofttools.com.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Thanks, I have already sent an email as you suggested. The cadimport.dll extended version that i have has date of 16/02/2007
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">We work on adding <b>OSNAP</b> feature. It will be available in some of future versions of the library. We will inform you when it will be ready.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
It would be great Ñ—could you give me an approximate forecast for the availability of this feature?
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
We do understand that documentation must be more informing and easy to use. But the question is that it is required to widen functionality first. That is why the most acceptable way for the moment is giving explanations online (via e-mail or by the forum).
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Of course, I understand... it was just a constructive suggestion. Thank you very much Sergey
<br />Hello Zebiya,
It looks like you don't use extended version of <b>CAD Import .NET</b> or you use just the old one. If so, please contact us to info@cadsofttools.com.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Thanks, I have already sent an email as you suggested. The cadimport.dll extended version that i have has date of 16/02/2007
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">We work on adding <b>OSNAP</b> feature. It will be available in some of future versions of the library. We will inform you when it will be ready.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
It would be great Ñ—could you give me an approximate forecast for the availability of this feature?
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
We do understand that documentation must be more informing and easy to use. But the question is that it is required to widen functionality first. That is why the most acceptable way for the moment is giving explanations online (via e-mail or by the forum).
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Of course, I understand... it was just a constructive suggestion. Thank you very much Sergey
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by zebiya</i>
<br /><blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by support</i>
<br />Hello Zebiya,
It looks like you don't use extended version of <b>CAD Import .NET</b> or you use just the old one. If so, please contact us to info@cadsofttools.com.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Thanks, I have already sent an email as you suggested. The cadimport.dll extended version that i have has date of 16/02/2007
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We had received your letter and answered it. Last version of <b>CAD Import .NET</b> is dated by the end of June, 2007.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">We work on adding <b>OSNAP</b> feature. It will be available in some of future versions of the library. We will inform you when it will be ready.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
It would be great Ñ—could you give me an approximate forecast for the availability of this feature?
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We plan to release it on September, 2007. But these are just plans. Life sometimes gives strange presents.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
<br /><blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by support</i>
<br />Hello Zebiya,
It looks like you don't use extended version of <b>CAD Import .NET</b> or you use just the old one. If so, please contact us to info@cadsofttools.com.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Thanks, I have already sent an email as you suggested. The cadimport.dll extended version that i have has date of 16/02/2007
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We had received your letter and answered it. Last version of <b>CAD Import .NET</b> is dated by the end of June, 2007.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">We work on adding <b>OSNAP</b> feature. It will be available in some of future versions of the library. We will inform you when it will be ready.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
It would be great Ñ—could you give me an approximate forecast for the availability of this feature?
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We plan to release it on September, 2007. But these are just plans. Life sometimes gives strange presents.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">...these are just plans. Life sometimes gives strange presents.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Good things, when unexpected, are twice good [;)]
Good things, when unexpected, are twice good [;)]