Author Topic: reading xdata from selected dimension  (Read 2412 times)

0 Members and 1 Guest are viewing this topic.

WOWENS

  • Newt
  • Posts: 59
reading xdata from selected dimension
« on: November 30, 2012, 11:39:27 AM »
what im trying to do is get the override dimlfac for the selected dimension. i was reading that the override was stored in the xdata my problem is i dont know how to read the xdata. this is what i tried so far but as you can see i dont know what im doing and help would be great.

Code: [Select]
If AcadObject.GetType.Name.ToUpper Like "*DIMENSION*" Then
                                Dim MyDim As Dimension = AcadObject
                                Dim dDimLfac As Double = 0

                                If MyDim.XData <> Nothing Then
                                    For Each MyTypedValue As TypedValue In MyDim.XData
                                        If MyTypedValue.TypeCode = 1040 Then
                                            dDimLfac = MyTypedValue.Value
                                            Exit For
                                        End If
                                    Next
                                End If
                            End If

WOWENS

  • Newt
  • Posts: 59
Re: reading xdata from selected dimension
« Reply #1 on: November 30, 2012, 03:39:55 PM »
well this is what i ended up with still thinking theres a better way

Code: [Select]
If MyDim.XData <> Nothing Then
                                                Dim NextLoop As Boolean = False
                                                For Each MyTypedValue As TypedValue In MyDim.XData
                                                    If MyTypedValue.TypeCode = 1070 Then
                                                        If MyTypedValue.Value = 144 Then
                                                            NextLoop = True
                                                        End If
                                                    ElseIf NextLoop = True And MyTypedValue.TypeCode = 1040 Then
                                                        If MyDim.Dimlfac = MyTypedValue.Value Then
                                                            dDLF = MyTypedValue.Value
                                                            Exit For
                                                        End If
                                                    End If
                                                Next
                                            End If

fixo

  • Guest
Re: reading xdata from selected dimension
« Reply #2 on: November 30, 2012, 04:12:18 PM »
If you still using AcadApplication this should work too
Code: [Select]
dim acEnt as acadentity= nothing
.................................................
If TypeOf (acEnt) Is AcadDimension Then           
                Dim MyDim As AcadDimension = CType(acEnt, AcadDimension)
                Dim dDimLfac As Double = New Double
                Dim xt As Object = New Object
                Dim xd As Object = New Object
                MyDim.GetXData("ACAD", xt, xd)
                Dim xtype() As Int16 = DirectCast(xt, Int16())
                Dim xdata() As Object = DirectCast(xd, Object())

                For i As Integer = LBound(xtype) To UBound(xtype)
                    If xtype(i) = 1040 Then
                        dDimLfac = CDbl(xdata(i))
                        Exit For
                    End If
                Next
                MsgBox("DIMLFAC is set to " + dDimLfac.ToString())

Jeff H

  • Needs a day job
  • Posts: 6144
Re: reading xdata from selected dimension
« Reply #3 on: November 30, 2012, 04:41:24 PM »
Why not use Dimension.Dimlfac?
 
It matches whats in the xdata
 
 

WOWENS

  • Newt
  • Posts: 59
Re: reading xdata from selected dimension
« Reply #4 on: November 30, 2012, 05:14:32 PM »
Jeff,
you are correct in some way the problem is this..if you set your dimlfac with the dimension style interface box and dimension something then list it..it shows no dimlfac override but if you set your dimlfac from the command line and then dimension something and list that dimension is shows a dimlfac override. but your right typical you could do that.

WOWENS

  • Newt
  • Posts: 59
Re: reading xdata from selected dimension
« Reply #5 on: November 30, 2012, 05:20:09 PM »
Fixo,
Im trying to stay away from the AcadApplication when i can. but thank you for the code i will give it a try.

Jeff H

  • Needs a day job
  • Posts: 6144
Re: reading xdata from selected dimension
« Reply #6 on: November 30, 2012, 08:00:27 PM »
well this is what i ended up with still thinking theres a better way

Code: [Select]
If MyDim.XData <> Nothing Then
                                                Dim NextLoop As Boolean = False
                                                For Each MyTypedValue As TypedValue In MyDim.XData
                                                    If MyTypedValue.TypeCode = 1070 Then
                                                        If MyTypedValue.Value = 144 Then
                                                            NextLoop = True
                                                        End If
                                                    ElseIf NextLoop = True And MyTypedValue.TypeCode = 1040 Then
                                                        If MyDim.Dimlfac = MyTypedValue.Value Then
                                                            dDLF = MyTypedValue.Value
                                                            Exit For
                                                        End If
                                                    End If
                                                Next
                                            End If
I still have no  idea what you are trying to accomplish, but looking at that I guess your wanting to know if it is "overriden".
You might want to be careful with that approach because as you mentioned changing the dimlfac from the command line it will show a override in list command,
but if you select it and in properties palette change the "Dim Scale Linear" to the same as one defined in style and list it again it will still show as overriden with value matching the styles, if you use a grip edit then list it the overrides will not show up in list.
 
Depending on when you checked the value your code would
-assign dDLF to overriden value
--assign dDLF to same value as defined in style
---would never reach line to assign dDLF
 
So maybe the safest bet would be to check if the Dimension.dimlfac equals its  DimStyleTableRecord.Dimlfac