CorelDraw X6-19, vs 2021 DXF Import Macro Layer & (Set Position X, Y)

CorelDraw X21 SetPosition on a DXF import macro is not compatible with X6-X19 versions.

Working X19 script code that gives the "Run-time error '91' Object variable or with block variable not set" in X21

Version X19 origin is 0,0 bottom left by default without any other settings.

Would like correct X21 SETPOSITION code.  

The  ActiveDocument.ReferencePoint = cdrBottomLeft   does not seem to help.

Thank you in Advance


ActivePage.GuidesLayer.Editable = False
ActivePage.GuidesLayer.Editable = True
Dim impopt As StructImportOptions
Set impopt = CreateStructImportOptions
impopt.MaintainLayers = True
Dim impflt As ImportFilter
' Set the path for Drill time DXF file
Set impflt = ActivePage.Layers("DT").ImportEx("C:\wellsite\d6unit\zDT.DXF", cdrDXF, impopt)
With impflt
.Projection = 0 ' FilterDXFLib.dxfTop
.AutoReduceNodes = False
.Scaling = 1 ' FilterDXFLib.dxfEnglish
.Finish
End With
Dim s1 As Shape
Set s1 = ActiveShape
' ****************************** Track1
' Set begining of Drill Time Curve 5" per 100 ft
s1.SetPosition 0.241, 55.681    ' Run-time error '91'  Object variable or with block variable not set
' ******************************

Parents
No Data
Reply
  • Solved:  In earlier version x6-2019 I recorded the scripts 6 years ago and got lucky.  Corel picked up the layer name on import.  In 2021 you need to create the layer first thing.  Then import the DXF,  at a specific SetPosition X, Y   (0,0 btm left)  Depending on the version of DXF, poly lines are generally under 100 segments and segments are joined.   In my case the poly lines are near 120" . The last code lines group the segments, and thus dash lines can set and unbroken  top to bottom.     Yes,   Set s1 = ActiveLayer.Shapes.Last  works.

      Creating the layer before the import is the solution for ver 2021.   2021 no longer picks up the layer name in the DXF on import.  Thank you

    Sub xSPcreate()
    ' Recorded 12/8/2021
    Dim lr1 As Layer
    Set lr1 = ActivePage.CreateLayer("SP")
    lr1.Name = "SP"
    Dim impopt As StructImportOptions
    Set impopt = CreateStructImportOptions
    With impopt.ColorConversionOptions
    .SourceColorProfileList = "sRGB IEC61966-2.1,U.S. Web Coated (SWOP) v2,Dot Gain 20%"
    .TargetColorProfileList = "sRGB IEC61966-2.1,U.S. Web Coated (SWOP) v2,Dot Gain 20%"
    End With
    Dim impflt As ImportFilter
    Set impflt = lr1.ImportEx("C:\wellsite\d6unit\lasSP.DXF", cdrDXF, impopt)
    With impflt
    .Projection = 0 ' FilterDXFLib.dxfTop
    .AutoReduceNodes = False
    .Scaling = 1 ' FilterDXFLib.dxfEnglish
    .Finish
    End With
    Dim s1 As Shape
    Set s1 = ActiveShape
    s1.SetPosition 0.241, 69.681
    Dim grp1 As ShapeRange
    Set grp1 = s1.UngroupEx
    grp1.SetOutlineProperties 0.013, Color:=CreateRGBColor(0, 0, 255)
    grp1.SetOutlineProperties 0.014, OutlineStyles(8), CreateCMYKColor(100, 0, 100, 0), LineCaps:=cdrOutlineSquareLineCaps, DashDotLength:=0#
    End Sub

Children
No Data