도형 생성을 한컴 파이썬에서 구현할 수 있는 방법이 따로 있을까요?

아래 매크로를 분석해서 만들고 있는데…

계속 점 하나만 생성되어서…

질문을 드립니다…

function OnScriptMacro_중국어1성()
{
HAction.GetDefault(“DrawObjCreatorRectangle”, HParameterSet.HShapeObject.HSet);
with (HParameterSet.HShapeObject)
{
ShapeDrawRectType.Type = 50;
ShapeDrawFillAttr.GradationAlpha = 0;
ShapeDrawFillAttr.Type = BrushType(“NullBrush|WinBrush”);
ShapeDrawFillAttr.WinBrushAlpha = 0;
ShapeDrawFillAttr.WinBrushFaceStyle = HatchStyle(“None”);
ShapeDrawFillAttr.WinBrushHatchColor = RGBColor(0, 0, 0);
ShapeDrawFillAttr.WinBrushFaceColor = RGBColor(255, 255, 255);
ShapeDrawFillAttr.WindowsBrush = 1;
ShapeDrawFillAttr.GradationBrush = 0;
ShapeDrawFillAttr.ImageBrush = 0;
ShapeDrawFillAttr.ImageAlpha = 0;
ShapeDrawLineAttr.Alpha = 0;
ShapeDrawLineAttr.OutLineStyle = HwpOutLineStyle(“Normal”);
ShapeDrawLineAttr.TailFill = 1;
ShapeDrawLineAttr.HeadFill = 1;
ShapeDrawLineAttr.TailSize = EndSize(“SmallSmall”);
ShapeDrawLineAttr.HeadSize = EndSize(“SmallSmall”);
ShapeDrawLineAttr.EndCap = 1;
ShapeDrawLineAttr.TailStyle = EndStyle(“Normal”);
ShapeDrawLineAttr.HeadStyle = EndStyle(“Normal”);
ShapeDrawLineAttr.Width = MiliToHwpUnit(0.1);
ShapeDrawLineAttr.Style = HwpLineType(“Solid”);
ShapeDrawLineAttr.Color = RGBColor(255, 255, 0);
ShapeDrawLayOut.CreateItemArray(“CreatePt”, 8);
ShapeDrawLayOut.CreatePt.Item(0) = 0;
ShapeDrawLayOut.CreatePt.Item(1) = 0;
ShapeDrawLayOut.CreatePt.Item(2) = 20409;
ShapeDrawLayOut.CreatePt.Item(3) = 0;
ShapeDrawLayOut.CreatePt.Item(4) = 20409;
ShapeDrawLayOut.CreatePt.Item(5) = 20409;
ShapeDrawLayOut.CreatePt.Item(6) = 0;
ShapeDrawLayOut.CreatePt.Item(7) = 20409;
ShapeDrawLayOut.CreateNumPt = 4;
TreatAsChar = 1;
TextWrap = TextWrapType(“InFrontOfText”);
VertOffset = MiliToHwpUnit(0.0);
VertAlign = VAlign(“Top”);
VertRelTo = VertRel(“Para”);
HorzOffset = MiliToHwpUnit(0.0);
HorzAlign = HAlign(“Justify”);
HorzRelTo = HorzRel(“Para”);
HeightRelTo = HeightRel(“Absolute”);
Height = 20409;
WidthRelTo = WidthRel(“Absolute”);
Width = 20409;
NumberingType = Numbering(“Figure”);
ShapeDrawShadow.ShadowType = DrawShadowType(“None”);
ShapeDrawShadow.ShadowColor = RGBColor(178, 178, 178);
ShapeDrawShadow.ShadowOffsetX = MiliToHwpUnit(0.0);
ShapeDrawShadow.ShadowOffsetY = MiliToHwpUnit(0.0);
ShapeDrawShadow.ShadowAlpha = 0;
HSet.SetItem(“ShapeType”, 0);
TextFlow = TextFlowType(“BothSides”);
ShapeListProperites.TextDirection = TextDir(“Nomal”);
ShapeListProperites.LineWrap = 0;
ShapeListProperites.VertAlign = VAlign(“Center”);
ShapeListProperites.MarginBottom = MiliToHwpUnit(1.0);
ShapeListProperites.MarginRight = MiliToHwpUnit(1.0);
ShapeListProperites.MarginTop = MiliToHwpUnit(1.0);
ShapeListProperites.MarginLeft = MiliToHwpUnit(1.0);
ShapeListProperites.CtrlData.Name = “”;
AdjustTextbox = 1;
ShapeCreationMode = 0;
ShapeCreationType = 1;
}
HAction.Execute(“DrawObjCreatorRectangle”, HParameterSet.HShapeObject.HSet);
HAction.GetDefault(“DrawObjCreatorObject”, HParameterSet.HShapeObject.HSet);
with (HParameterSet.HShapeObject)
{
HorzRelTo = HorzRel(“Para”);
VertRelTo = VertRel(“Para”);
TreatAsChar = 1;
ShapeDrawLayOut.CreateNumPt = 4;
ShapeDrawLayOut.CreateItemArray(“CreatePt”, 8);
ShapeDrawLayOut.CreatePt.Item(0) = 0;
ShapeDrawLayOut.CreatePt.Item(1) = 0;
ShapeDrawLayOut.CreatePt.Item(2) = 20409;
ShapeDrawLayOut.CreatePt.Item(3) = 0;
ShapeDrawLayOut.CreatePt.Item(4) = 20409;
ShapeDrawLayOut.CreatePt.Item(5) = 20409;
ShapeDrawLayOut.CreatePt.Item(6) = 0;
ShapeDrawLayOut.CreatePt.Item(7) = 20409;
ShapeDrawLineAttr.Color = RGBColor(255, 255, 0);
ShapeDrawLineAttr.HeadSize = EndSize(“SmallSmall”);
ShapeDrawLineAttr.TailSize = EndSize(“SmallSmall”);
ShapeDrawFillAttr.GradationAlpha = 0;
ShapeDrawFillAttr.WindowsBrush = 1;
ShapeDrawFillAttr.ImageAlpha = 0;
ShapeDrawFillAttr.ImageBrush = 0;
ShapeDrawFillAttr.GradationBrush = 0;
ShapeDrawRectType.Type = 50;
HSet.SetItem(“ShapeType”, 0);
ShapeDrawShadow.ShadowAlpha = 0;
ShapeDrawShadow.ShadowOffsetY = MiliToHwpUnit(0.0);
ShapeDrawShadow.ShadowOffsetX = MiliToHwpUnit(0.0);
ShapeDrawShadow.ShadowColor = RGBColor(178, 178, 178);
ShapeDrawShadow.ShadowType = DrawShadowType(“None”);
NumberingType = Numbering(“Figure”);
ShapeListProperites.CtrlData.Name = “”;
ShapeCreationType = 1;
ShapeCreationMode = 0;
AdjustTextbox = 1;
}
HAction.Execute(“DrawObjCreatorObject”, HParameterSet.HShapeObject.HSet);
}

function OnScriptMacro_중국어1성()
{
HAction.GetDefault(“DrawObjCreatorRectangle”, HParameterSet.HShapeObject.HSet);
with (HParameterSet.HShapeObject)
{
ShapeDrawRectType.Type = 50;
ShapeDrawFillAttr.GradationAlpha = 0;
ShapeDrawFillAttr.Type = BrushType(“NullBrush|WinBrush”);
ShapeDrawFillAttr.WinBrushAlpha = 0;
ShapeDrawFillAttr.WinBrushFaceStyle = HatchStyle(“None”);
ShapeDrawFillAttr.WinBrushHatchColor = RGBColor(0, 0, 0);
ShapeDrawFillAttr.WinBrushFaceColor = RGBColor(255, 102, 0);
ShapeDrawFillAttr.WindowsBrush = 1;
ShapeDrawFillAttr.GradationBrush = 0;
ShapeDrawFillAttr.ImageBrush = 0;
ShapeDrawFillAttr.ImageAlpha = 0;
ShapeDrawLineAttr.Alpha = 0;
ShapeDrawLineAttr.OutLineStyle = HwpOutLineStyle(“Normal”);
ShapeDrawLineAttr.TailFill = 1;
ShapeDrawLineAttr.HeadFill = 1;
ShapeDrawLineAttr.TailSize = EndSize(“SmallSmall”);
ShapeDrawLineAttr.HeadSize = EndSize(“SmallSmall”);
ShapeDrawLineAttr.EndCap = 1;
ShapeDrawLineAttr.TailStyle = EndStyle(“Normal”);
ShapeDrawLineAttr.HeadStyle = EndStyle(“Normal”);
ShapeDrawLineAttr.Width = MiliToHwpUnit(1.0);
ShapeDrawLineAttr.Style = HwpLineType(“Solid”);
ShapeDrawLineAttr.Color = RGBColor(255, 255, 0);
ShapeDrawLayOut.CreateItemArray(“CreatePt”, 8);
ShapeDrawLayOut.CreatePt.Item(0) = 0;
ShapeDrawLayOut.CreatePt.Item(1) = 0;
ShapeDrawLayOut.CreatePt.Item(2) = 14173;
ShapeDrawLayOut.CreatePt.Item(3) = 0;
ShapeDrawLayOut.CreatePt.Item(4) = 14173;
ShapeDrawLayOut.CreatePt.Item(5) = 5669;
ShapeDrawLayOut.CreatePt.Item(6) = 0;
ShapeDrawLayOut.CreatePt.Item(7) = 5669;
ShapeDrawLayOut.CreateNumPt = 4;
TreatAsChar = 1;
TextWrap = TextWrapType(“InFrontOfText”);
VertOffset = MiliToHwpUnit(0.0);
VertAlign = VAlign(“Top”);
VertRelTo = VertRel(“Para”);
HorzOffset = MiliToHwpUnit(0.0);
HorzAlign = HAlign(“Justify”);
HorzRelTo = HorzRel(“Para”);
HeightRelTo = HeightRel(“Absolute”);
Height = 5669;
WidthRelTo = WidthRel(“Absolute”);
Width = 14173;
NumberingType = Numbering(“Figure”);
ShapeDrawShadow.ShadowType = DrawShadowType(“None”);
ShapeDrawShadow.ShadowColor = RGBColor(178, 178, 178);
ShapeDrawShadow.ShadowOffsetX = MiliToHwpUnit(0.0);
ShapeDrawShadow.ShadowOffsetY = MiliToHwpUnit(0.0);
HSet.SetItem(“ShapeType”, 0);
TextFlow = TextFlowType(“BothSides”);
ShapeListProperites.TextDirection = TextDir(“Nomal”);
ShapeListProperites.LineWrap = LineWrapType(“Break”);
ShapeListProperites.VertAlign = VAlign(“Center”);
ShapeListProperites.MarginBottom = MiliToHwpUnit(1.0);
ShapeListProperites.MarginRight = MiliToHwpUnit(1.0);
ShapeListProperites.MarginTop = MiliToHwpUnit(1.0);
ShapeListProperites.MarginLeft = MiliToHwpUnit(1.0);
AdjustTextbox = 1;
ShapeCreationMode = 0;
ShapeCreationType = 1;
}
HAction.Execute(“DrawObjCreatorRectangle”, HParameterSet.HShapeObject.HSet);
HAction.GetDefault(“DrawObjCreatorObject”, HParameterSet.HShapeObject.HSet);
with (HParameterSet.HShapeObject)
{
Width = 14173;
Height = 5669;
HorzRelTo = HorzRel(“Para”);
VertRelTo = VertRel(“Para”);
ShapeDrawLayOut.CreateNumPt = 4;
ShapeDrawLayOut.CreateItemArray(“CreatePt”, 8);
ShapeDrawLayOut.CreatePt.Item(0) = 0;
ShapeDrawLayOut.CreatePt.Item(1) = 0;
ShapeDrawLayOut.CreatePt.Item(2) = 14173;
ShapeDrawLayOut.CreatePt.Item(3) = 0;
ShapeDrawLayOut.CreatePt.Item(4) = 14173;
ShapeDrawLayOut.CreatePt.Item(5) = 5669;
ShapeDrawLayOut.CreatePt.Item(6) = 0;
ShapeDrawLayOut.CreatePt.Item(7) = 5669;
ShapeDrawLineAttr.Color = RGBColor(255, 255, 0);
ShapeDrawLineAttr.Width = MiliToHwpUnit(1.0);
ShapeDrawLineAttr.HeadSize = EndSize(“SmallSmall”);
ShapeDrawLineAttr.TailSize = EndSize(“SmallSmall”);
ShapeDrawFillAttr.GradationAlpha = 0;
ShapeDrawFillAttr.WinBrushFaceColor = RGBColor(255, 102, 0);
ShapeDrawFillAttr.WindowsBrush = 1;
ShapeDrawFillAttr.ImageAlpha = 0;
ShapeDrawFillAttr.ImageBrush = 0;
ShapeDrawFillAttr.GradationBrush = 0;
ShapeDrawRectType.Type = 50;
HSet.SetItem(“ShapeType”, 0);
ShapeDrawShadow.ShadowOffsetY = MiliToHwpUnit(0.0);
ShapeDrawShadow.ShadowOffsetX = MiliToHwpUnit(0.0);
ShapeDrawShadow.ShadowColor = RGBColor(178, 178, 178);
ShapeDrawShadow.ShadowType = DrawShadowType(“None”);
NumberingType = Numbering(“Figure”);
ShapeCreationType = 1;
ShapeCreationMode = 0;
}
HAction.Execute(“DrawObjCreatorObject”, HParameterSet.HShapeObject.HSet);
}

안녕하세요 ^^
음 아래와 같이 네모를 만드는 파이썬 소스코드 공유드립니다.
참고하시어 작업하시면 될것 같습니다.
감사합니다.

import win32com.client as win32 
hwp=win32.gencache.EnsureDispatch("HWPFrame.HwpObject")
hwp.XHwpWindows.Active_XHwpWindow.Visible = 1

act = hwp.CreateAction("DrawObjCreatorRectangle");
set = hwp.CreateSet("ShapeObject");
act.GetDefault(set);
            
            
set.SetItem("Width", 4800);
set.SetItem("WidthRelTo", 4);
set.SetItem("Height", 2400);
set.SetItem("HeightRelTo", 2);
set.SetItem("HorzRelTo", 3);
set.SetItem("HorzAlign", 0);
set.SetItem("HorzOffset", 0);
set.SetItem("VertRelTo", 2);
set.SetItem("VertAlign", 0);
set.SetItem("VertOffset", 0);
set.SetItem("TextWrap", 3);


layoutSet = set.CreateItemSet("ShapeDrawLayOut", "DrawLayOut");
pt = layoutSet.CreateItemArray("CreatePt", 8);
pt.SetItem(0 * 2 + 0, 0);
pt.SetItem(0 * 2 + 1, 0);
pt.SetItem(1 * 2 + 0, 20409);
pt.SetItem(1 * 2 + 1, 0);
pt.SetItem(2 * 2 + 0, 20409);
pt.SetItem(2 * 2 + 1, 20409);
pt.SetItem(3 * 2 + 0, 0);
pt.SetItem(3 * 2 + 1, 20409);
layoutSet.SetItem("CreateNumPt", 4);

lineAttr = set.CreateItemSet("ShapeDrawLineAttr", "DrawLineAttr");
lineAttr.SetItem("Color", 0);
lineAttr.SetItem("Style", 1);
lineAttr.SetItem("Width", 28);
lineAttr.SetItem("EndCap", 0);
lineAttr.SetItem("HeadStyle", 0);
lineAttr.SetItem("TailStyle", 1);
lineAttr.SetItem("HeadSize", 4);
lineAttr.SetItem("TailSize", 4);
lineAttr.SetItem("HeadFill", 1);
lineAttr.SetItem("TailFill", 1);
lineAttr.SetItem("OutLineStyle", 0);
lineAttr.SetItem("Alpha", 0);

set.SetItem("TextFlow", 0);
set.SetItem("NumberingType", 1);
set.SetItem("AdjustTextbox", 1);
    
act.Execute(set);
1개의 좋아요

제가 만든 코드에서 도저히 높이가… 조절이 안됬는데…
한번 시도해보겠습니다!

감사합니다!!

1개의 좋아요