Author Topic: Dictionary project  (Read 5297 times)

0 Members and 1 Guest are viewing this topic.

Arch_Eric

  • Guest
Dictionary project
« on: May 28, 2008, 11:38:01 AM »
Before I started my next project, I wanted to get the experts opinion on it.

- Create a dictionary with keys:
  * Parent object - text entity to store number total
  * Calculation type - either area or sum
  * Child objects - polyline entities to calculate area or text entities to calculate sum
- Create a rector for regen and/or qsave/save to read the dictionary and do calculations
  * Alert - missing entities
- Create function to manage dictionary

I'm trying to make my square footage calculations automatic. I already have the code to calculate areas and add text entities. The reactor part I'm useless on, I'll have to do some research on reactors. And I've been trying to work with ssget to select entities by DXF code 5 (handle) but I can't seem to get it to work. I think I read somewhere that ssget doesn't work with code 5, which doesn't make sense to me. Is there a way to translate an entity handle to an ename?

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Dictionary project
« Reply #1 on: May 28, 2008, 11:41:47 AM »
You can use the built in function 'handent' to get the ename from the handle.

You can use mtext/attributes and fields to hold the value of square footages of plines.

I have put up a reactor here to area.
[ http://www.theswamp.org/index.php?topic=8710.0 ]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Arch_Eric

  • Guest
Re: Dictionary project
« Reply #2 on: May 28, 2008, 12:07:49 PM »
Doh! :ugly: How the hell did I miss handent...thanks for pointing that out. And thanks for the link  :-)

jbuzbee

  • Swamp Rat
  • Posts: 833
Re: Dictionary project
« Reply #3 on: May 28, 2008, 12:23:05 PM »
I'm confused.  What's the dictionary for?
James Buzbee
Windows 8

Arch_Eric

  • Guest
Re: Dictionary project
« Reply #4 on: May 28, 2008, 12:30:25 PM »
I was thinking of storing my handles and info in there, because I'll have more than one polyline for some area calculations, and 3+ handles to calculate the sums of the areas.

daron

  • Guest
Re: Dictionary project
« Reply #5 on: May 28, 2008, 02:26:50 PM »
When you get that complete, I'd love to "borrow" it from ya. I've got something similar to do.

Arch_Eric

  • Guest
Re: Dictionary project
« Reply #6 on: May 28, 2008, 04:05:33 PM »
I'm travelling down the dark path with this one.

I'm using... LData.  :|

daron

  • Guest
Re: Dictionary project
« Reply #7 on: May 28, 2008, 04:31:39 PM »
No biggie. I'll still take it.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Dictionary project
« Reply #8 on: May 28, 2008, 04:50:50 PM »
I'm travelling down the dark path with this one.

I'm using... LData.  :|
From all the posts I have seen, LData is not the desired road.  Maybe we can give you some better directions to the promised land.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

daron

  • Guest
Re: Dictionary project
« Reply #9 on: May 28, 2008, 04:57:01 PM »
We have, but the problem is that Ldata is too easy to use. What it should be is a wrapper (front-end) for xdata.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Dictionary project
« Reply #10 on: May 28, 2008, 05:03:54 PM »
We have, but the problem is that Ldata is too easy to use. What it should be is a wrapper (front-end) for xdata.
XData
Code: [Select]
    (defun MySetXData (Obj CodeList DataList / )
        ; Sets XData to an object.  Must number in code list must be 1001
       
        (vla-SetXData Obj
            (vlax-make-variant
                (vlax-safearray-fill
                    (vlax-make-safearray
                        vlax-vbInteger
                        (cons 0 (1- (length CodeList)))
                    )
                    CodeList
                )
            )
            (vlax-make-variant
                (vlax-safearray-fill
                    (vlax-make-safearray
                        vlax-vbVariant
                        (cons 0 (1- (length Datalist)))
                    )
                    DataList
                )
            )
        )
    )
;-----------------------------------------------------------------------------
    (defun MyGetXData (Obj DataName / CodeType DataType)
        ; Retrive XData for an object
       
        (vla-GetXData
            Obj
            (if DataName
                DataName
                ""
            )
            'CodeType
            'DataType
        )
        (if (and CodeType DataType)
            (mapcar
                '(lambda (a b)
                    (cons a (variant-value b))
                )
                (safearray-value CodeType)
                (safearray-value DataType)
            )
        )
    )
XRecords
Code: [Select]
    (defun MySetXRec (Obj CodeList DataList / )
        ; Sets XRecordData. Dxf numbers between 1-369, except 5, 100, 105.
        ; See help for types and numbers to use.
       
        (vla-SetXRecordData Obj
            (vlax-make-variant
                (vlax-safearray-fill
                    (vlax-make-safearray
                        vlax-vbInteger
                        (cons 0 (1- (length CodeList)))
                    )
                    CodeList
                )
            )
            (vlax-make-variant
                (vlax-safearray-fill
                    (vlax-make-safearray
                        vlax-vbVariant
                        (cons 0 (1- (length Datalist)))
                    )
                    DataList
                )
            )
        )
    )
;-----------------------------------------------------------------------------
    (defun MyGetXRec (Obj / CodeType DataType)
        ; Retrive XRecordData for an object
       
        (vla-GetXRecordData
            Obj
            'CodeType
            'DataType
        )
        (if (and CodeType DataType)
            (mapcar
                '(lambda (a b)
                    (cons a (variant-value b))
                )
                (safearray-value CodeType)
                (safearray-value DataType)
            )
        )
    )
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Arch_Eric

  • Guest
Re: Dictionary project
« Reply #11 on: May 28, 2008, 05:59:43 PM »
The only problems I could find on the net about LData was when moving a drawing from R14 to 2000 it would corrupt the drawing or something.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Dictionary project
« Reply #12 on: May 28, 2008, 07:18:57 PM »
The only problems I could find on the net about LData was when moving a drawing from R14 to 2000 it would corrupt the drawing or something.

[ http://discussion.autodesk.com/thread.jspa?messageID=1213664 ]
[ http://discussion.autodesk.com/thread.jspa?messageID=2045434 ]
[ http://discussion.autodesk.com/thread.jspa?messageID=4951203 ]

These are just opinions by people I have come to respect in the programming scheme of things, so I stay away.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

daron

  • Guest
Re: Dictionary project
« Reply #13 on: May 28, 2008, 10:55:08 PM »
Thanks Tim, I'll have to borrow those.

Arch_Eric

  • Guest
Re: Dictionary project
« Reply #14 on: May 28, 2008, 11:31:40 PM »
I'm not saying those guys aren't experts, but reading those posts, they say exactly the same thing. Someone asks about LData, somebody says avoid it like the plague. The person asks why and they say because LData didn't transfer from R14 to 2000 and because it's not accessible via VBA. I understand that and all, but that was 9 years ago, and while I'm not (yet) playing with VBA, I don't see why it should be avoided altogether. I'm fairly new to AutoLISP, and in no way want to piss off anybody that will help me learn. I'm just asking questions.  :angel:

I've already got my stuff working except for reactors, but I'm not really in a hurry for that. I'm just enjoying the fact it works.