Author Topic: bugs for a sticker  (Read 3771 times)

0 Members and 1 Guest are viewing this topic.

nekitip

  • Guest
bugs for a sticker
« on: September 11, 2014, 09:28:12 AM »
*List of bugs we find, and workarounds we try. For forum sticker, if there is a will to do it. Share and help others.

Selection problem
As an end user, use AutoCAD to:
1) Select 20 000-30 000 (same) objects with mouse at once
2) Deselect about half part of previous selection using mouse and holding SHIFT key.
3) Notice that one CPU core is now fully busy and stays busy forever.
4) Press ESC key and now CPU goes to 0% usage.
*observable on 2013, 2015

Hatch object problem
From .NET side, problem of reacting to impliedselectionchanged
1) user opens drawing and creates a hatch object
2) user selects hatch
3) impliedselectionchanged event is fired and your subscribed handler runs
4) if handler immediately starts transaction, opens object, and reads area, assembly is crashed, and later, Autocad itself.
*observable on 2013, 2015
proposed solution 1): on every impliedselectionchanged, addhandler to application.idle, and there remove idle handler, and do the business

(add yours experience, and moderators - please put this in some nice form)

BlackBox

  • King Gator
  • Posts: 3770
Re: bugs for a sticker
« Reply #1 on: September 11, 2014, 09:32:18 AM »
...

4) if handler immediately starts transaction, opens object, and reads area, assembly is crashed, and later, Autocad itself.
*observable on 2013, 2015
proposed solution 1): on every impliedselectionchanged, addhandler to application.idle, and there remove idle handler, and do the business

Consider what context you're in when you open the Hatch DbObject... You haven't posted your code, but perhaps you've neglected a preceding DocumentLock? :?
"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6150
Re: bugs for a sticker
« Reply #2 on: September 11, 2014, 10:01:02 AM »
*List of bugs we find, and workarounds we try. For forum sticker, if there is a will to do it. Share and help others.

Selection problem
As an end user, use AutoCAD to:
1) Select 20 000-30 000 (same) objects with mouse at once
2) Deselect about half part of previous selection using mouse and holding SHIFT key.
3) Notice that one CPU core is now fully busy and stays busy forever.
4) Press ESC key and now CPU goes to 0% usage.
*observable on 2013, 2015

Hatch object problem
From .NET side, problem of reacting to impliedselectionchanged
1) user opens drawing and creates a hatch object
2) user selects hatch
3) impliedselectionchanged event is fired and your subscribed handler runs
4) if handler immediately starts transaction, opens object, and reads area, assembly is crashed, and later, Autocad itself.
*observable on 2013, 2015
proposed solution 1): on every impliedselectionchanged, addhandler to application.idle, and there remove idle handler, and do the business

(add yours experience, and moderators - please put this in some nice form)
Use a OpenCloseTransaction in a event handler

nekitip

  • Guest
Re: bugs for a sticker
« Reply #3 on: September 11, 2014, 11:35:36 AM »
I was thinking about having a place just to post known bug descriptions and solutions, eventually with few lines of code to demonstrate. If we start to debate here, then we have a real possibility to jam this topic and make it unreadable, so it was my fault to post here without acutally get consensus about bug before.
Let moderators of this forum think for a way to arrange this to be clean and easy to read and write some guide rules.

Since Jeff and Blackbox have already asked here, I'm posting here to demonstrate this last bug, will post entire listing so it's easy to copy+paste (and convert to C#). Maybe this was a way to go even first time, so everyone can test it.
Moderators can later rearange this to suite rules.

So to test the last one I've described, use this quick code in a way of:
open new autocad, new file, load app, draw rectancle, draw hatch, delete rectancle, start app with "mytest" command, and set a breakpoint to see that the hatch area is not populated.
Jeff and Blackbox, can you please confirm. And, please, contribute if you have a better solution than me.
Code - vb.net: [Select]
  1. Imports System
  2. Imports Autodesk.AutoCAD.Runtime
  3. Imports Autodesk.AutoCAD.ApplicationServices
  4. Imports Autodesk.AutoCAD.DatabaseServices
  5. Imports Autodesk.AutoCAD.Geometry
  6. Imports Autodesk.AutoCAD.EditorInput
  7.  
  8. Imports System.ComponentModel
  9. Imports System.Collections.Specialized
  10. Imports System.Collections.ObjectModel
  11. Imports System.Linq
  12.  
  13. <Assembly: CommandClass(GetType(tmpdel.MyCommands))>
  14. <Assembly: ExtensionApplication(GetType(tmpdel.MyPlugin))>
  15.  
  16.  
  17. Namespace tmpdel
  18.     Public Class MyPlugin
  19.         Implements IExtensionApplication
  20.         Public Sub Initialize() Implements IExtensionApplication.Initialize
  21.         End Sub
  22.         Public Sub Terminate() Implements IExtensionApplication.Terminate
  23.         End Sub
  24.     End Class
  25.  
  26.     Public Class MyCommands
  27.  
  28.         <CommandMethod("mytest")> _
  29.         Public Sub MyCommand()
  30.             AddHandler Application.DocumentManager.MdiActiveDocument.ImpliedSelectionChanged, (AddressOf sectionch)
  31.         End Sub
  32.  
  33.         Public Sub sectionch(ByVal o As Object, ByVal e As EventArgs)
  34.  
  35.             Dim db As Database = HostApplicationServices.WorkingDatabase()
  36.             Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db)
  37.             Using l As DocumentLock = doc.LockDocument()
  38.                 Using trans As OpenCloseTransaction = db.TransactionManager.StartOpenCloseTransaction()
  39.                     Dim h As Hatch = trans.GetObject(get_selected_oids.First, OpenMode.ForRead)
  40.                           'set breakpoint here to see that the hatch area property is not ready
  41.                     Dim area As Double = h.Area
  42.                     trans.Commit()
  43.                 End Using
  44.             End Using
  45.         End Sub
  46.  
  47.  
  48.         Public Function get_selected_oids() As List(Of ObjectId)
  49.             Dim retval As New List(Of ObjectId)
  50.             Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
  51.             '' WARNING! THIS WILL SELECT ALL OBJECTS!!!
  52.             Dim psr As PromptSelectionResult = ed.SelectAll
  53.             If psr.Status = PromptStatus.OK Then
  54.                 retval = psr.Value.GetObjectIds.ToList()
  55.             End If
  56.             Return retval
  57.         End Function
  58.   End Class
  59. End Namespace
  60.  

nekitip

  • Guest
Re: bugs for a sticker
« Reply #4 on: September 11, 2014, 11:59:12 AM »
Twisted Hatch problem
End user can produce hatch that has normal parameters, and then in next step, stretch it in a way that it will produce eInvalidInput error on parameter read.
1) create two rectangles like on picture, and hatch first
2) delete first rectangle
3) move left upper corner like on the picture.
4) notice how object property toolbox is not telling anything is wrong, and in fact it will even show wrong area.
5) if add-in tries to read area, it will crash
*observable on 2015 (and possibly on any autocad where hatch has its own boundaries)
proposed solution: on reading objects parameters, always assume that autocad will bring something undocumented and use try catch.
« Last Edit: September 11, 2014, 01:59:32 PM by nekitip »

BlackBox

  • King Gator
  • Posts: 3770
Re: bugs for a sticker
« Reply #5 on: September 11, 2014, 12:11:24 PM »
... on reading objects parameters, always assume that autocad will bring something undocumented and use try catch.

... You don't? :roll:



 :-P
"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6150
Re: bugs for a sticker
« Reply #6 on: September 11, 2014, 01:18:34 PM »
I was thinking about having a place just to post known bug descriptions and solutions, eventually with few lines of code to demonstrate. If we start to debate here, then we have a real possibility to jam this topic and make it unreadable, so it was my fault to post here without acutally get consensus about bug before.
Let moderators of this forum think for a way to arrange this to be clean and easy to read and write some guide rules.

Probably would want make sure you got a bug first and give more info before placing in a thread that is labeled as it is confirmed.

There are different hatch patterns types, and system variables, HPBOUND, HPASSOC, that could effect it.

Just looking at your selection method how do you know you even have an Hatch object?


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: bugs for a sticker
« Reply #7 on: September 11, 2014, 04:37:44 PM »
*List of bugs we find, and workarounds we try. For forum sticker, if there is a will to do it. Share and help others.

Selection problem
As an end user, use AutoCAD to:
1) Select 20 000-30 000 (same) objects with mouse at once
2) Deselect about half part of previous selection using mouse and holding SHIFT key.
3) Notice that one CPU core is now fully busy and stays busy forever.
4) Press ESC key and now CPU goes to 0% usage.
*observable on 2013, 2015


I am unable to reproduce this result at the command line with AutoCAD2014, AutoCAD2015.

Does it happen at the command-line for you or in your code ?

//---------------------
If you believe this behaviour is a 'bug', have you reported it to AutoDESK ??

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: bugs for a sticker
« Reply #8 on: September 11, 2014, 04:49:01 PM »
I got it after a bit of messing with hatch until its edges could be used to calculate a border.

That's something to check and they have information in docs and of course pretty vague.

sybold

  • Newt
  • Posts: 62
Re: bugs for a sticker
« Reply #9 on: September 12, 2014, 05:59:34 AM »
the selection problem is because of the propeties pallete being open i think

nekitip

  • Guest
Re: bugs for a sticker
« Reply #10 on: December 15, 2014, 05:29:58 AM »
Unexpected line in overrule
Sometimes when you use overrule, you need to override worlddraw
Code - vb.net: [Select]
  1. Public Overrides Function WorldDraw(drawable As Drawable, wd As WorldDraw) As Boolean
Here you can find out everything that is moving, even if it is not in DB
like:
Code - vb.net: [Select]
  1. Public Overrides Function WorldDraw(drawable As Drawable, wd As WorldDraw) As Boolean
  2.                 If wd.IsDragging Then
  3.                     Dim ent As Entity = DirectCast(drawable, Entity) 'filtering already for Entity
  4.                        'do something
  5.                 End If
  6.                 Return MyBase.WorldDraw(drawable, wd)
  7.             End Function

Expected behaviour is that whatever is dragging will pop up here.
However, prepare that sometimes unexpedted, nonexisting objects may appear.
For example, if user pastes text, (PASTECLIP), than an unknown polyline will appear here and trigger override and If-then test.

EDIT: also, this particular overrule is acting different in 32bit and 64bit, and different in autocad 2015 then in earlier versions
« Last Edit: December 22, 2014, 11:06:31 AM by nekitip »

nekitip

  • Guest
Re: bugs for a sticker
« Reply #11 on: December 20, 2014, 09:11:42 AM »
Incorrect polyline Area value returned by .NET API
(EDIT: and some other curves, like SPLINE..., but circles, arcs seems OK, so... careful...)
To reproduce:
draw polyline in a form of number 8 in autocad, read entity Area property in .NET and returning value is wrong.
It is wrong for all self-intersecting polylines and some (hard to tell which) of the non closed ones.
Shrot solution:
read values from COM object
Code - C#: [Select]
  1.             public static double GetArea(this Polyline pline)
  2.            {
  3.                dynamic pl = pline.AcadObject;
  4.                return (double)pl.Area;
  5.            }
  6.  
Longer solution:
since reading com this way is about two times slower, doesn't work well in overrules, then you can read only if you are sure object is self-intersected or non closed (some non closed plines are good for read directly from .NET but hard to tell when. Please share if you know solution)

Also, I ask everyone to share your findings about other unexpected and undocumented bugs and behaviour.

« Last Edit: December 20, 2014, 04:03:22 PM by nekitip »