# Identifier DrawLine is undefined

**URL:** <https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103>\
**Category:** Community & Industry Discussion\
**Tags:** include, unreal-engine, question\
**Created:** [October 22, 2021, 1:59am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103 "2021-10-22T01:59:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jWolf19833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jWolf19833](https://forums.unrealengine.com/u/jWolf19833)\
**Post date:** [October 22, 2021, 1:59am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103/1 "2021-10-22T01:59:33Z")

</div>

I’m currently getting the error that DrawLine() is undefined, which would normally just mean I forgot to include the header file where it’s defined. I looked up the include statement I needed in the documentation [here](https://docs.unrealengine.com/4.27/en-US/API/Runtime/UMG/Blueprint/UWidgetBlueprintLibrary/DrawLine/) and added the line: #include “Blueprint/WidgetBlueprintLibrary.h” to the top of my custom class header file. However, I still get the error that it’s undefined. I’ve also tried closing and re-opening Visual Studio/the engine and rebuilding the solution to see if that would fix it, but no such luck. Any ideas?

---

<div class="post-metadata">

**Author:** ![DevinSherry](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/devinsherry/32/1101099_2.png) [@DevinSherry](https://forums.unrealengine.com/u/DevinSherry)\
**Post date:** [October 22, 2021, 6:43am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103/2 "2021-10-22T06:43:24Z")

</div>

Hi,

Could you include the full error and also show the code snippet to give more context to the issue?

---

<div class="post-metadata">

**Author:** ![jWolf19833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jWolf19833](https://forums.unrealengine.com/u/jWolf19833)\
**Post date:** [October 30, 2021, 11:41am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103/3 "2021-10-30T11:41:39Z")

</div>

#pragma once

```
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Blueprint/WidgetBlueprintLibrary.h"

/**
 * 
 */
class SKETCHWITHDEPTH_API CPP_2D_Curve
{
protected:
	bool is_vertical;
	bool is_dirty;
	TArray<FVector2D> curve_points;
	FColor color;
	FVector4 bounding_box;

public:
	static const float ENDPOINT_SNAP_DISTANCE;

	CPP_2D_Curve();
	CPP_2D_Curve(const CPP_2D_Curve& c1);
	~CPP_2D_Curve();

	int add_curve_point(FVector2D p);
	TArray<FVector2D> get_curve_points();
	void clear_curve();
	void set_curve_color(FColor col);
	FVector2D get_start_point();
	FVector2D get_end_point();
	bool check_if_vertical();
	void draw_curve(FPaintContext &pc, FVector2D viewport_size);
};
```

---

<div class="post-metadata">

**Author:** ![jWolf19833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jWolf19833](https://forums.unrealengine.com/u/jWolf19833)\
**Post date:** [October 30, 2021, 11:41am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103/4 "2021-10-30T11:41:40Z")

</div>

I appear to need some practice with entering code snippets on this site… The above code is the header file for my custom class, the relevant part of the .cpp file is posted below:

```
#include "CPP_2D_Curve.h"

......

void CPP_2D_Curve::draw_curve(FPaintContext& pc, FVector2D viewport_size)
{
	for (int i = 1; i < curve_points.Num(); ++i)
	{
		DrawLine(); //Haven't put the parameters in yet, but this is the method I want to call
	}
}
```

---

<div class="post-metadata">

**Author:** ![jWolf19833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jWolf19833](https://forums.unrealengine.com/u/jWolf19833)\
**Post date:** [October 30, 2021, 11:41am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103/5 "2021-10-30T11:41:42Z")

</div>

The error I’m getting is the following (copied from the error list in visual studio):

Code: E0020  
Description: identifier “DrawLine” is undefined

---

<div class="post-metadata">

**Author:** ![jWolf19833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jWolf19833](https://forums.unrealengine.com/u/jWolf19833)\
**Post date:** [October 30, 2021, 11:41am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103/6 "2021-10-30T11:41:45Z")

</div>

Thought I already commented on this but I can’t see the comment anymore, so if you see duplicate posts, my apologies. The error is the following:

**Code:** E0020  
**Description:** identifier “DrawLine” is undefined

**Header File:**

```
#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Blueprint/WidgetBlueprintLibrary.h" // This is the include statement referenced in OP

/**
 * 
 */
class SKETCHWITHDEPTH_API CPP_2D_Curve
{

...
public:
...
	void draw_curve(FPaintContext &pc, FVector2D viewport_size);
};

```

**CPP File:**

```
// Fill out your copyright notice in the Description page of Project Settings.

#include "CPP_2D_Curve.h"

...

void CPP_2D_Curve::draw_curve(FPaintContext& pc, FVector2D viewport_size)
{
	for (int i = 1; i < curve_points.Num(); ++i)
	{
		DrawLine(); // Haven't added the parameters here yet, but this is the call that results in the error
	}
}
```

---

<div class="post-metadata">

**Author:** ![jWolf19833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jWolf19833](https://forums.unrealengine.com/u/jWolf19833)\
**Post date:** [October 30, 2021, 11:41am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103/7 "2021-10-30T11:41:48Z")

</div>

So I’ve tried to use the reply button twice now, and every time I reload the page my reply seems to disappear, so I guess I’ll post this in an answer instead. Also, ellipses are used in place of irrelevant code for the sake of brevity.

**Code:** E0020  
**Description:** identifier “DrawLine” is undefined

**Header File:**

```
#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "Blueprint/WidgetBlueprintLibrary.h" // This is the include statement referenced in OP

/**
 * 
 */
class SKETCHWITHDEPTH_API CPP_2D_Curve
{

...
public:
...
	void draw_curve(FPaintContext &pc, FVector2D viewport_size);
};

```

**CPP File:**

```
// Fill out your copyright notice in the Description page of Project Settings.

#include "CPP_2D_Curve.h"

...

void CPP_2D_Curve::draw_curve(FPaintContext& pc, FVector2D viewport_size)
{
	for (int i = 1; i < curve_points.Num(); ++i)
	{
		DrawLine(); // Haven't added the parameters here yet, but this is the call that results in the error
	}
}
```

---

<div class="post-metadata">

**Author:** ![jWolf19833](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jWolf19833](https://forums.unrealengine.com/u/jWolf19833)\
**Post date:** [October 30, 2021, 11:42am UTC](https://forums.unrealengine.com/t/identifier-drawline-is-undefined/490103/8 "2021-10-30T11:42:09Z")

</div>

Friend of mine offline figured this out for me; DrawLine is part of the UWidgetBlueprintLibrary namespace, so I needed to call UWidgetBlueprintLibrary::DrawLine() instead of just DrawLine().
