Author Topic: Need Help Urget - will pay.  (Read 33597 times)

0 Members and 1 Guest are viewing this topic.

vnsharifi

  • Guest
Re: Need Help Urget - will pay.
« Reply #45 on: April 16, 2011, 07:50:29 PM »
I found this piece of code in VBA regarding SetXdata and GetXdata. My qeustion is why , when we setxdata to an object. It doesn't hold the
values , after closing the drawing. Am I missing something ? or it is that way.
Code: [Select]

Dim entry As AcadEntity
  Dim XDataType(0 To 2) As Integer
  Dim XData(0 To 2) As Variant
  Dim temp(20) As Variant
Sub getextendeddata()
For Each entry In ThisDrawing.ModelSpace
  entry.getXdata "Test_Application", XDataType, XData
    temp(1) = ""
    For i = 0 To 2
    temp(1) = temp(1) + XData(i) & vbCrLf
    Next
    MsgBox temp(1)
Next
End Sub
Sub setextendeddata()
For Each entry In ThisDrawing.ModelSpace
    XDataType(0) = 1001: XData(0) = "Test_Application"
    XDataType(1) = 1000: XData(1) = "A"
    XDataType(2) = 1000: XData(2) = "B"
    entry.setXdata XDataType, XData
Next
End Sub

vnsharifi

  • Guest
Re: Need Help Urget - will pay.
« Reply #46 on: April 16, 2011, 10:08:52 PM »
GentleMen,
I have another Question, I found the maximus fields per record in dictionaries is 9  . Is it true?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Need Help Urget - will pay.
« Reply #47 on: April 16, 2011, 10:31:09 PM »

The capacity of a Dictionary is the number of elements the Dictionary can hold. As elements are added to a Dictionary, the capacity is automatically increased as required by reallocating the internal array.

What is it you are trying to do ?

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.

vnsharifi

  • Guest
Re: Need Help Urget - will pay.
« Reply #48 on: April 16, 2011, 10:44:17 PM »

The capacity of a Dictionary is the number of elements the Dictionary can hold. As elements are added to a Dictionary, the capacity is automatically increased as required by reallocating the internal array.

What is it you are trying to do ?



Kerry, thank you for reading and listening. Trying to see if it is possible to keep the database inside the drawing instead of outside.
By using dictionaries. I need 80 fields per record . But more than 9 , It gives me error. I usually test in vba . Then move it to Vb.net.
Below is code in VBA.



Code: [Select]

Public Sub writeXrec1()
  Dim oDict As AcadDictionary
  Dim oXRec As AcadXRecord
  Dim dxfCode(0 To 80) As Integer
  Dim dxfData(0 To 80)
    Set oDict = ThisDrawing.Dictionaries.Add("SampleTest")
     For i = 0 To 1000
      Set oXRec = oDict.AddXRecord("Record" + Trim(str(i + 1)))
      For J = 0 To 80
        dxfCode(J) = J + 1: dxfData(J) = Trim(str(J)) + "value"
      Next J
      oXRec.SetXRecordData dxfCode, dxfData
    Next i
  MsgBox "DONE"
End Sub




Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Need Help Urgently - will pay.
« Reply #49 on: April 16, 2011, 10:51:47 PM »
Quote
Trying to see if it is possible to keep the database inside the drawing instead of outside.

Why ?
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.

vnsharifi

  • Guest
Re: Need Help Urget - will pay.
« Reply #50 on: April 16, 2011, 10:57:50 PM »

Quote
Trying to see if it is possible to keep the database inside the drawing instead of outside.

Why ?

1- I did a speed test for writing 1000 records (each record 9 fields). It was so fast inside autocad .
2- If I go with  external database, If users want to transfer files to each other, They have to transfer 2 files. One "dwg" and one "MDB".



Jeff H

  • Needs a day job
  • Posts: 6150
Re: Need Help Urget - will pay.
« Reply #51 on: April 16, 2011, 11:06:34 PM »
Quote
ObjectARX, .NET and ObjectDBX modules

XDATA and extension dictionaries provide a means of augmenting database objects with data and other objects (via hard ownership). Both the XDATA facilities and extension dictionaries are intended to be used by multiple applications as needed. XDATA has a limitation of 16K bytes per object, to be shared by all applications.

For objects that are accessible by all applications, such as entities in block table records and symbol table records, applications should not consume more than 2K bytes of XDATA, and must not consume more than 4K bytes of XDATA. If they need more data than this, consider moving the data to a custom object or an AcDbXrecord in the extension dictionary.

Extension dictionary entries have no maximum size restriction, but there is a memory tradeoff in using extension dictionaries in AutoCAD. Each extension dictionary entry consumes a minimum of 250 bytes of overhead beyond the object state during program execution, whereas each REGAPP in an objects's XDATA consumes about 40 bytes of overhead.

Some objects are private by nature; they are meant to be manipulated only by the application that creates and manages them. Using XDATA and extension dictionaries on private objects is not restricted.




vnsharifi

  • Guest
Re: Need Help Urget - will pay.
« Reply #52 on: April 16, 2011, 11:17:00 PM »
Quote

Each extension dictionary entry consumes a minimum of 250 bytes of overhead beyond the object state during program execution,





Thanks Jeff for considering ,  it doesn't tell  about field limitation in each record. I Know we could have unlimited records in a dictionary.I tested it.If you try the code I submitted. It doesn't allow more than 9 fileds. Even with Bolean data type. If You confirm this test I guess I have to stick with External Database.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Need Help Urget - will pay.
« Reply #53 on: April 16, 2011, 11:26:43 PM »
If You confirm this test I guess I have to stick with External Database.
I just realized I do not know how to build or load VBA.

Just so you know if you save ObjecID's in a ExtensionDictionary, when you open the drawing AutoCAD will update ObjectIds--(ObjectId value is its address which contains a pointer to the actual object)
to reflect the new memory location.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Need Urgent Help - will pay.
« Reply #54 on: April 16, 2011, 11:37:16 PM »

Quote
Trying to see if it is possible to keep the database inside the drawing instead of outside.

Why ?

1- I did a speed test for writing 1000 records (each record 9 fields). It was so fast inside autocad .
2- If I go with  external database, If users want to transfer files to each other, They have to transfer 2 files. One "dwg" and one "MDB".




That doesn't answer the question.


Why do you want an internal dictionary ?


Please consider this :
How will you transfer the information to the shop floor ?

Why do you want a database ?

At what stage in the drawing design will the data extracted from the drawing be usable in any real manner?

How often is each profile likely be changed?

If you analyse your data is it generally several profiles with the specific end conditions repeated many times for varying lengths ?

If you want an external database it's data can be updated at any time from the drawing.

//--------

Because you have not provided sufficient information to indicate  to anyone here what your real intention is you are making it VERY difficult for anyone to actually help in any way other than teach you programming.

... also, you seem to be jumping all over the place with your testing and code snips.
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.

vnsharifi

  • Guest
Re: Need Help Urget - will pay.
« Reply #55 on: April 17, 2011, 12:27:31 AM »
If You confirm this test I guess I have to stick with External Database.
I just realized I do not know how to build or load VBA.

Here you go Jeff: I made it vb.net.
Code: [Select]

Imports Autodesk.AutoCAD.Interop.Common
Module testDictionaries
    Dim i, J As Integer
    Dim countdic As Integer
    Dim dicname As String
    Dim oDict As AcadDictionary
    Dim oXRec As AcadXRecord
    Dim no_of_records As Integer
    Public Sub create_records_in_Dictionary()
        no_of_records = InputBox("number of fiels per record?")
        Dim dxfCode(no_of_records) As Int16
        Dim dxfData(no_of_records) As Object
        oDict = ThisDrawing.Dictionaries.Add("SampleTest")
        For i = 0 To 1000
            oXRec = oDict.AddXRecord("Record" + Trim(Str(i + 1)))
            For J = 0 To no_of_records
                dxfCode(J) = J + 1 : dxfData(J) = Trim(Str(J)) + "value"
            Next J

            oXRec.SetXRecordData(dxfCode, dxfData)

        Next i
        MsgBox("DONE")
    End Sub
    Public Sub SHOW_ALL_dictionary_names_in_file()
        countdic = ThisDrawing.Dictionaries.Count
        dicname = ""
        For i = 0 To countdic - 1
            Try
                oDict = ThisDrawing.Dictionaries.Item(i)
                If Left(oDict.Name, 5) <> "ACAD_" Or Trim(oDict.Name) = "" Then
                    dicname = dicname + oDict.Name + vbCrLf
                End If
            Catch ex As Exception
                GoTo 100
            End Try
100:    Next
        MsgBox(dicname)
    End Sub
    Public Sub DELETE_extra_DICTIONARY()
        Dim oDict As AcadDictionary
        countdic = ThisDrawing.Dictionaries.Count
        For i = 0 To countdic - 1
            Try
                oDict = ThisDrawing.Dictionaries.Item(i)
                If Left(oDict.Name, 5) <> "ACAD_" Or Trim(oDict.Name) = "" Then
                    ThisDrawing.Dictionaries.Item(i).Delete()
                End If
            Catch ex As Exception
                GoTo 200
            End Try
200:    Next
    End Sub
  End Module



vnsharifi

  • Guest
Re: Need Urgent Help - will pay.
« Reply #56 on: April 17, 2011, 12:31:40 AM »


Ok Kerry. You are right. I stick with external Database. I am so frustrated and you just wake me up.
Today I just worked and worked. My kids and family are upset with me.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Need Help Urget - will pay.
« Reply #57 on: April 17, 2011, 12:47:58 AM »
No, I'm not right or correct ; I never made a suggestion ... all I did was ask some questions so we can understand what you are trying to do.

I find it amusing how you have not really answered questions or posted the main block or sample drawings.


I'll try again :

What is the primary goal/purpose of the application you are designing ?
What are any secondary goals ?
How do you intend to achieve these goals ?

Try to answer these without using programming function terms.

Regards,
 
« Last Edit: April 17, 2011, 12:55:54 AM by Kerry »
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.

vnsharifi

  • Guest
Re: Need Help Urget - will pay.
« Reply #58 on: April 17, 2011, 01:43:24 AM »
Quote
Linking Circles, Part 1: Using .NET events to relate AutoCAD geometry

I used those online convertors to make a vb. Attached please find the the file. I have no idea about Namespaces and Assemply . and get some
error which don't know how to fix them. Can some body help me. to have erro free code .So I can dig in. Thanks.

vnsharifi

  • Guest
Re: Need Help Urget - will pay.
« Reply #59 on: April 17, 2011, 02:11:32 AM »


Quote
I find it amusing how you have not really answered questions or posted the main block or sample drawings.
Reply # 21 has the one of 40 Blocks which I made.Like I said in my project description in same reply. All drawings are handsketch.
there is no electronic drawings. I am going to give them this utility.
They just bought Autocad. everything used to be  marked on hardcopy archtiect drawing ,manualy
and input in Excel.


Quote
What is the primary goal/purpose of the application you are designing ?
Like I said in Reply #21, To combine multiple tags where the  fields in their records are the same.
To reduce shop work and make life easier for foreman to find Tags on Job.

Quote
What are any secondary goals ?
Having a nicer drawing instead of a handmade drawing. Right now after they get the project. General contactor give them a copy of
architect drawing and they start putting Labels on that drawing manually and they put data in excel seperately for each label.
since  this is a manual job they don't keep track of similar lables.
I mean it is quite possible 2 bundles of fibergalss are exactly the same but with 2 different Tags on it. for evertag shop operator has to reset machine.


Quote
How do you intend to achieve these goals ?
Really don't know. Database point of view I have no problem . I am expert in that matter. I finished a lot of project .
Just Autocad point of view.I am confused. But I explained in detail what I need. But don't know How to achieve that inside autocad.

Thanks again for listening and paying attention.