Product : Engine, Version : 5.0.1.1036, ArticleID : 41023857

HowTo : VDF problem in saving in other formats

Article41023857
TypeHowTo
ProductEngine
Version5.0.1.1036
Date Added2/14/2005
Submitted byNorbert Schulze-Kahley
Keywords

Subject

VDF problem in saving in other formats

Summary

VDF problem in saving in other formats

Solution

The vdf file you sent me, is not produced correctly. You had probably add some entities or blocks(with copy command for example) without copying all  necessary objects(like textstyle,dimstyle,layer) that belong to.

To be more specific in your drawing there are some "VDINSERTS" objects that have some dimensions in them. These dimensions have some Dimension Style Names called "grundriss","holme" etc, that have not added in the current document's database(you can see that the Dimstyles.Count property returns 1 only object which is the "STANDARD").

Notice also that some other formats (like dxf you mentioned) if they find an entity that uses a TextStyle or Dimstyle or layer that does not exist, they crash.
VectorDraw formats are not displaying them. Only for layers object, if the entity has an object that does not exist,is setting the default value("0"). If the "0" layer does not exist then VectorDraw does not display this entity.
 
So there are two ways of solving this problem.
1) When adding objects in the document, be sure that all the necessary objects in collections are added. For example when you are adding(or pasting) a "VDTEXT" object that has textstyle name "mytextstyle" and belongs to layer "mylayer", be sure that the specific layer and texstyle object exists.

2)We can make a function that can "cure" such drawings. There are two ways of doing this.

    a) By creating the object(textstyle,dimstyle,layer) and giving to it the default values. After running this function all the missing objects will be created. However the objects will not have the correct values of the original drawing.

    b) By setting the "missing" values to the defaults. After running this function, all the entities that have a missing object, they will take the standard values(which are "STANDARD" for the Dimstyle and TextStyle and "0" for the layer.

    However this solution as you can easily understand will not contain all the necessary values in order to display correct the drawing.

 

This is implemented with the following code:

 

Private Sub Fix_Tables()
   
    Dim blk As vdBlock
    Dim entblk As vdFigure
   
    Dim ent As vdFigure
    Dim layout As vdLayout
   

    'Search for every entity in every block
    Set blk = VDraw.ActiveDocument.Blocks.Start
    Do While Not blk Is Nothing
        For Each entblk In blk
            Fix_Entity entblk
        Next
        Set blk = VDraw.ActiveDocument.Blocks.Next
    Loop
   

    'Search for every entity in Model
    For Each ent In VDraw.ActiveDocument.Model.Entities
        Fix_Entity ent
    Next

    'Search for every entity in every layout    
    For Each layout In VDraw.ActiveDocument.LayOuts
        For Each ent In layout.Entities
            Fix_Entity ent
        Next
    Next
End Sub

 

'"Fix" the entity

Public Sub Fix_Entity(ent As vdFigure)
    Dim text As vdText
    Dim attrib As vdAttrib
    Dim dimension As vdDimension
       
    If VDraw.ActiveDocument.Layers.FindName(ent.LayerName) Is Nothing Then
        ent.LayerName = "0"
    End If
   
    Select Case ent.Type
        Case "VDTEXT"
            Set text = ent
            If VDraw.ActiveDocument.TextStyles.FindName(text.StyleName) Is Nothing Then
                text.StyleName = "STANDARD"
            End If
        Case "VDATTRIB"
            Set attrib = ent
            If VDraw.ActiveDocument.TextStyles.FindName(attrib.StyleName) Is Nothing Then
                attrib.StyleName = "STANDARD"
            End If
        Case "VDDIMENSION"
            Set dimension = ent
            If VDraw.ActiveDocument.DimStyles.FindName(dimension.StyleName) Is Nothing Then
                dimension.StyleName = "STANDARD"
            End If
    End Select
End Sub

 

So call the Fix_Tables() sub before saving the file.

 

If you have any further questions do not hesitate to contact us.